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.
Functions§
- 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) - comparison_
coercion - Coerce
lhs_typeandrhs_typeto a common type for comparison contexts — any context where two values are compared rather than unified. This includes binary comparison operators, IN lists, CASE/WHEN conditions, and BETWEEN. - decimal_
coercion - Decimal coercion rules.
- like_
coercion - Coercion rules for like operations. This is a union of string coercion rules, dictionary coercion rules, and REE coercion rules Note: list_coercion is intentionally NOT included here because LIKE is a string pattern matching operation and is not supported for nested types (List, Struct, etc.)
- regex_
coercion - Coercion rules for regular expression comparison operations. This is a union of string coercion rules, dictionary coercion rules, and REE coercion rules.
- 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.
- try_
type_ union_ resolution - Handle type union resolution including struct type and others.
- try_
type_ union_ resolution_ with_ struct - type_
union_ coercion - Coerce
lhs_typeandrhs_typeto a common type for type unification contexts — where two values must be brought to a common type but are not being compared. Examples: UNION, CASE THEN/ELSE branches, NVL2. For other contexts,comparison_coercionshould typically be used instead. - type_
union_ resolution - Coerce dissimilar data types to a single data type. ARRAY literals, VALUES, COALESCE, and array concatenation are examples of contexts that use this function. 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.