Skip to content

Commit 9ed1915

Browse files
committed
feat[expr-common]: support regex and LIKE coercion on REE<Dict> types
The coerce_fn applied to REE values needs to be the higher-level coerce function so that any REE value can be coerced (not just primitive types). Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
1 parent 42cd2fa commit 9ed1915

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

datafusion/expr-common/src/type_coercion/binary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ pub fn like_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTyp
17671767
string_coercion(lhs_type, rhs_type)
17681768
.or_else(|| binary_to_string_coercion(lhs_type, rhs_type))
17691769
.or_else(|| dictionary_coercion(lhs_type, rhs_type, false, string_coercion))
1770-
.or_else(|| ree_coercion(lhs_type, rhs_type, false, string_coercion))
1770+
.or_else(|| ree_coercion(lhs_type, rhs_type, false, like_coercion))
17711771
.or_else(|| regex_null_coercion(lhs_type, rhs_type))
17721772
.or_else(|| null_coercion(lhs_type, rhs_type))
17731773
}
@@ -1788,7 +1788,7 @@ fn regex_null_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataT
17881788
pub fn regex_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
17891789
string_coercion(lhs_type, rhs_type)
17901790
.or_else(|| dictionary_coercion(lhs_type, rhs_type, false, string_coercion))
1791-
.or_else(|| ree_coercion(lhs_type, rhs_type, false, string_coercion))
1791+
.or_else(|| ree_coercion(lhs_type, rhs_type, false, regex_coercion))
17921792
.or_else(|| regex_null_coercion(lhs_type, rhs_type))
17931793
}
17941794

datafusion/sqllogictest/test_files/run_end_encoded.slt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,21 @@ FROM sensor_readings;
6767
23 23
6868
24 24
6969
25 25
70+
71+
# Regex / LIKE match against an REE column whose values are themselves Dictionary-encoded
72+
query BB rowsort
73+
SELECT
74+
arrow_cast(
75+
arrow_cast(sensor_id, 'Dictionary(UInt32, Utf8)'),
76+
'RunEndEncoded("run_ends": non-null Int32, "values": Dictionary(UInt32, Utf8))'
77+
) ~ 'sensor_A',
78+
arrow_cast(
79+
arrow_cast(sensor_id, 'Dictionary(UInt32, Utf8)'),
80+
'RunEndEncoded("run_ends": non-null Int32, "values": Dictionary(UInt32, Utf8))'
81+
) LIKE 'sensor_A'
82+
FROM sensor_readings;
83+
----
84+
false false
85+
true true
86+
true true
87+
true true

0 commit comments

Comments
 (0)