@@ -706,7 +706,8 @@ pub fn try_type_union_resolution_with_struct(
706706///
707707/// When comparing numeric values and strings, both values will be coerced to
708708/// strings. For example when comparing `'2' > 1`, the arguments will be
709- /// coerced to `Utf8` for comparison
709+ /// coerced to `Utf8` for comparison. Cubestore: No, they get coerced to
710+ /// numeric. Same with strings and booleans.
710711pub fn comparison_coercion ( lhs_type : & DataType , rhs_type : & DataType ) -> Option < DataType > {
711712 if lhs_type == rhs_type {
712713 // same type => equality is possible
@@ -721,7 +722,7 @@ pub fn comparison_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<D
721722 . or_else ( || null_coercion ( lhs_type, rhs_type) )
722723 // TODO upgrade DF: Look at non-comparison coercions and figure out desirable behavior
723724 . or_else ( || string_numeric_coercion_as_numeric ( lhs_type, rhs_type) )
724- . or_else ( || string_boolean_coercion ( lhs_type, rhs_type) )
725+ . or_else ( || string_boolean_coercion_as_boolean ( lhs_type, rhs_type) )
725726 . or_else ( || string_temporal_coercion ( lhs_type, rhs_type) )
726727 . or_else ( || binary_coercion ( lhs_type, rhs_type) )
727728 . or_else ( || struct_coercion ( lhs_type, rhs_type) )
@@ -820,6 +821,18 @@ fn string_numeric_coercion_as_numeric(
820821 None
821822}
822823
824+ fn string_boolean_coercion_as_boolean ( lhs_type : & DataType , rhs_type : & DataType ) -> Option < DataType > {
825+ use arrow:: datatypes:: DataType :: * ;
826+ match ( lhs_type, rhs_type) {
827+ ( Utf8 , Boolean ) => Some ( Boolean ) ,
828+ ( LargeUtf8 , Boolean ) => Some ( Boolean ) ,
829+ ( Boolean , Utf8 ) => Some ( Boolean ) ,
830+ ( Boolean , LargeUtf8 ) => Some ( Boolean ) ,
831+ _ => None ,
832+ }
833+ }
834+
835+
823836/// Coerce `lhs_type` and `rhs_type` to a common type for the purposes of a comparison operation
824837/// where one is boolean and one is `Utf8`/`LargeUtf8`.
825838fn string_boolean_coercion ( lhs_type : & DataType , rhs_type : & DataType ) -> Option < DataType > {
0 commit comments