Expand description
Coercion rules for matching argument types for binary operators
StructsΒ§
- Binary
Type Coercer - Provides type information about a binary expression, coercing different input types into a sensible output type.
- Signature π
- The type signature of an instantiation of binary operator expression such as
lhs + rhs
EnumsΒ§
- Type
Category π
FunctionsΒ§
- array_
coercion π - binary_
coercion π - Coercion rules for binary types (Binary/LargeBinary/BinaryView): If at least one argument is a binary type and both arguments can be coerced into a binary type, coerce to binary type.
- binary_
numeric_ coercion - Coerce
lhs_typeandrhs_typeto a common type where both are numeric - binary_
to_ string_ coercion - Coercion rules for binary (Binary/LargeBinary) to string (Utf8/LargeUtf8):
If one argument is binary and the other is a string then coerce to string
(e.g. for
like) - bitwise_
coercion π - Returns the output type of applying bitwise operations such as
&,|, orxorto arguments oflhs_typeandrhs_type. - both_
numeric_ πor_ null_ and_ numeric - Determine if at least of one of lhs and rhs is numeric, and the other must be NULL or numeric
- coerce_
fields π - returns the result of coercing two fields to a common type
- coerce_
list_ πchildren - Coerces two fields together, ensuring the field data (name and nullability) is correctly set.
- coerce_
numeric_ πtype_ to_ decimal32 - Convert the numeric data type to the decimal data type. We support signed and unsigned integer types and floating-point type.
- coerce_
numeric_ πtype_ to_ decimal64 - Convert the numeric data type to the decimal data type. We support signed and unsigned integer types and floating-point type.
- coerce_
numeric_ πtype_ to_ decimal128 - Convert the numeric data type to the decimal data type. We support signed and unsigned integer types and floating-point type.
- coerce_
numeric_ πtype_ to_ decimal256 - Convert the numeric data type to the decimal data type. We support signed and unsigned integer types and floating-point type.
- comparison_
coercion - Coerce
lhs_typeandrhs_typeto a common type for the purposes of a comparison operation - comparison_
coercion_ numeric - Similar to
comparison_coercionbut prefers numeric if compares with numeric and string - create_
decimal32_ πtype - create_
decimal64_ πtype - create_
decimal128_ πtype - create_
decimal256_ πtype - decimal_
coercion - Decimal coercion rules.
- dictionary_
comparison_ πcoercion - Coercion rules for Dictionaries: the type that both lhs and rhs can be casted to for the purpose of a computation.
- dictionary_
comparison_ πcoercion_ generic - Generic coercion rules for Dictionaries: the type that both lhs and rhs can be casted to for the purpose of a computation.
- dictionary_
comparison_ πcoercion_ numeric - Coercion rules for Dictionaries with numeric preference: similar to
dictionary_comparison_coercionbut usescomparison_coercion_numericwhich prefers numeric types over strings when both are present. - get_
common_ πdecimal_ type - Coerce
lhs_typeandrhs_typeto a common type. - get_
wider_ πdecimal_ type - Returns a decimal [
DataType] variant that can store any value from eitherlhs_decimal_typeandrhs_decimal_type - get_
wider_ πdecimal_ type_ cross_ variant - Handle cross-variant decimal widening by choosing the larger variant
- is_
decimal π - is_
time_ πwith_ valid_ unit - Checks if the TimeUnit associated with a Time32 or Time64 type is consistent, as Time32 can only be used to Second and Millisecond accuracy, while Time64 is exclusively used to Microsecond and Nanosecond accuracy
- like_
coercion - Coercion rules for like operations. This is a union of string coercion rules and dictionary coercion rules
- list_
coercion π - Coercion rules for list types.
- map_
coercion π - coerce two types if they are Maps by coercing their inner βentriesβ fieldsβ types using struct coercion
- math_
decimal_ πcoercion - Coercion rules for mathematics operators between decimal and non-decimal types.
- mathematics_
numerical_ πcoercion - Returns the output type of applying mathematics operations such as
+to arguments oflhs_typeandrhs_type. - null_
coercion π - Coercion rules from NULL type. Since NULL can be cast to any other type in arrow, either lhs or rhs is NULL, if NULL can be cast to type of the other side, the coercion is valid.
- numeric_
string_ πcoercion - numerical_
coercion π - A common set of numerical coercions that are applied for mathematical and binary ops
to
lhs_typeandrhs_type. - regex_
coercion - Coercion rules for regular expression comparison operations. This is a union of string coercion rules and dictionary coercion rules
- regex_
null_ πcoercion - Coercion rules for regular expression comparison operations with NULL input.
- string_
coercion - Coercion rules for string view types (Utf8/LargeUtf8/Utf8View): If at least one argument is a string view, we coerce to string view based on the observation that StringArray to StringViewArray is cheap but not vice versa.
- string_
concat_ πcoercion - Coercion rules for string concat. This is a union of string coercion rules and specified rules:
- string_
concat_ πinternal_ coercion - If
from_typecan be casted toto_type, returnto_type, otherwise returnNone. - string_
numeric_ πcoercion - Coerce
lhs_typeandrhs_typeto a common type for the purposes of a comparison operation where one is numeric and one isUtf8/LargeUtf8. - string_
numeric_ πcoercion_ as_ numeric - Coerce
lhs_typeandrhs_typeto a common type for the purposes of a comparison operation where one is numeric and one isUtf8/LargeUtf8. - string_
temporal_ πcoercion - Coerce
lhs_typeandrhs_typeto a common type for the purposes of a comparison operation where one is temporal and one isUtf8View/Utf8/LargeUtf8. - struct_
coercion π - temporal_
coercion π - temporal_
coercion_ πnonstrict_ timezone - Non-strict Timezone Coercion is useful in scenarios where we can guarantee a stable relationship between two timestamps of different timezones.
- temporal_
coercion_ πstrict_ timezone - Strict Timezone coercion is useful in scenarios where we cannot guarantee a stable relationship between two timestamps with different timezones or do not want implicit coercion between them.
- timeunit_
coercion π - try_
type_ union_ resolution - Handle type union resolution including struct type and others.
- try_
type_ union_ resolution_ with_ struct - type_
union_ resolution - Coerce dissimilar data types to a single data type. UNION, INTERSECT, EXCEPT, CASE, ARRAY, VALUES, and the GREATEST and LEAST functions are examples that has the similar resolution rules. See https://www.postgresql.org/docs/current/typeconv-union-case.html for more information. The rules in the document provide a clue, but adhering strictly to them doesnβt precisely align with the behavior of Postgres. Therefore, weβve made slight adjustments to the rules to better match the behavior of both Postgres and DuckDB. For example, we expect adjusted decimal precision and scale when coercing decimal types.
- type_
union_ πresolution_ coercion - Coerce
lhs_typeandrhs_typeto a common type for type_union_resolution See type_union_resolution for more information.