Module binary

Module binary 

Source
Expand description

Coercion rules for matching argument types for binary operators

StructsΒ§

BinaryTypeCoercer
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Β§

TypeCategory πŸ”’

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_type and rhs_type to 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 &, |, or xorto arguments of lhs_type and rhs_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_type and rhs_type to a common type for the purposes of a comparison operation
comparison_coercion_numeric
Similar to comparison_coercion but 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_coercion but uses comparison_coercion_numeric which prefers numeric types over strings when both are present.
get_common_decimal_type πŸ”’
Coerce lhs_type and rhs_type to a common type.
get_wider_decimal_type πŸ”’
Returns a decimal [DataType] variant that can store any value from either lhs_decimal_type and rhs_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 of lhs_type and rhs_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_type and rhs_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_type can be casted to to_type, return to_type, otherwise return None.
string_numeric_coercion πŸ”’
Coerce lhs_type and rhs_type to a common type for the purposes of a comparison operation where one is numeric and one is Utf8/LargeUtf8.
string_numeric_coercion_as_numeric πŸ”’
Coerce lhs_type and rhs_type to a common type for the purposes of a comparison operation where one is numeric and one is Utf8/LargeUtf8.
string_temporal_coercion πŸ”’
Coerce lhs_type and rhs_type to a common type for the purposes of a comparison operation where one is temporal and one is Utf8View/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_type and rhs_type to a common type for type_union_resolution See type_union_resolution for more information.