datafusion_expr::binary

Function type_union_resolution

Source
pub fn type_union_resolution(data_types: &[DataType]) -> Option<DataType>
Expand description

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.

This function doesn’t preserve correct field name and nullability for the struct type, we only care about data type.

Returns Option because we might want to continue on the code even if the data types are not coercible to the common type