You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/05/01 05:13:05 UTC

(datafusion) branch gh-readonly-queue/main/pr-21924-9bbc28b8111e970364186f674759028f9cd04feb created (now f3cebc5196)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-21924-9bbc28b8111e970364186f674759028f9cd04feb
in repository https://gitbox.apache.org/repos/asf/datafusion.git


      at f3cebc5196 feat[expr-common]: support regex and LIKE coercion on REE and Dict value types that require an extra coercion step (#21924)

This branch includes the following new commits:

     new f3cebc5196 feat[expr-common]: support regex and LIKE coercion on REE and Dict value types that require an extra coercion step (#21924)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


(datafusion) 01/01: feat[expr-common]: support regex and LIKE coercion on REE and Dict value types that require an extra coercion step (#21924)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-21924-9bbc28b8111e970364186f674759028f9cd04feb
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit f3cebc5196d9e229a52b24ee9890a455b11ceacb
Author: Alfonso Subiotto Marqués <al...@polarsignals.com>
AuthorDate: Fri May 1 07:12:42 2026 +0200

    feat[expr-common]: support regex and LIKE coercion on REE and Dict value types that require an extra coercion step (#21924)
    
    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).
    
    ## Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax. For example
    `Closes #123` indicates that this PR will close issue #123.
    -->
    
    - Closes #21923
    
    ## Rationale for this change
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    -->
    Queries were failing
    
    ## What changes are included in this PR?
    
    <!--
    There is no need to duplicate the description in the issue here but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    Correct unwrapping of REE values for regex/LIKE coercion
    
    ## Are these changes tested?
    
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they covered by existing tests)?
    -->
    Yes, with slt tests.
    
    ## Are there any user-facing changes?
    
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    -->
    Queries that would previously error now pass.
    
    <!--
    If there are any breaking changes to public APIs, please add the `api
    change` label.
    -->
    
    ---------
    
    Signed-off-by: Alfonso Subiotto Marques <al...@polarsignals.com>
---
 datafusion/expr-common/src/type_coercion/binary.rs     |  8 ++++----
 .../sqllogictest/test_files/regexp/regexp_like.slt     | 17 +++++++++++++++++
 datafusion/sqllogictest/test_files/run_end_encoded.slt | 18 ++++++++++++++++++
 3 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rs
index 1f02d6322a..c701eccb39 100644
--- a/datafusion/expr-common/src/type_coercion/binary.rs
+++ b/datafusion/expr-common/src/type_coercion/binary.rs
@@ -1766,8 +1766,8 @@ fn binary_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType>
 pub fn like_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
     string_coercion(lhs_type, rhs_type)
         .or_else(|| binary_to_string_coercion(lhs_type, rhs_type))
-        .or_else(|| dictionary_coercion(lhs_type, rhs_type, false, string_coercion))
-        .or_else(|| ree_coercion(lhs_type, rhs_type, false, string_coercion))
+        .or_else(|| dictionary_coercion(lhs_type, rhs_type, false, like_coercion))
+        .or_else(|| ree_coercion(lhs_type, rhs_type, false, like_coercion))
         .or_else(|| regex_null_coercion(lhs_type, rhs_type))
         .or_else(|| null_coercion(lhs_type, rhs_type))
 }
@@ -1787,8 +1787,8 @@ fn regex_null_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataT
 /// This is a union of string coercion rules, dictionary coercion rules, and REE coercion rules.
 pub fn regex_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
     string_coercion(lhs_type, rhs_type)
-        .or_else(|| dictionary_coercion(lhs_type, rhs_type, false, string_coercion))
-        .or_else(|| ree_coercion(lhs_type, rhs_type, false, string_coercion))
+        .or_else(|| dictionary_coercion(lhs_type, rhs_type, false, regex_coercion))
+        .or_else(|| ree_coercion(lhs_type, rhs_type, false, regex_coercion))
         .or_else(|| regex_null_coercion(lhs_type, rhs_type))
 }
 
diff --git a/datafusion/sqllogictest/test_files/regexp/regexp_like.slt b/datafusion/sqllogictest/test_files/regexp/regexp_like.slt
index 2b304c8de1..22d5066d5f 100644
--- a/datafusion/sqllogictest/test_files/regexp/regexp_like.slt
+++ b/datafusion/sqllogictest/test_files/regexp/regexp_like.slt
@@ -277,6 +277,23 @@ drop table strings
 statement ok
 drop table dict_table
 
+# Dict value types that themselves need further coercion against the literal
+statement ok
+create table dict_inner as
+select arrow_cast(arrow_cast(c, 'Binary'), 'Dictionary(UInt32, Binary)') as bin_col,
+       arrow_cast(arrow_cast(c, 'Dictionary(UInt32, Utf8)'),
+                  'Dictionary(Int32, Dictionary(UInt32, Utf8))') as nested_col
+from (values ('foo'), ('bar')) as t(c);
+
+query BB
+select bin_col LIKE 'foo', nested_col ~ 'foo' from dict_inner;
+----
+true true
+false false
+
+statement ok
+drop table dict_inner
+
 # Ensure that regexp_like is rewritten to use the (more optimized) regex operators
 statement ok
 create table regexp_test as values
diff --git a/datafusion/sqllogictest/test_files/run_end_encoded.slt b/datafusion/sqllogictest/test_files/run_end_encoded.slt
index 48932d2caa..b5909bc7c4 100644
--- a/datafusion/sqllogictest/test_files/run_end_encoded.slt
+++ b/datafusion/sqllogictest/test_files/run_end_encoded.slt
@@ -67,3 +67,21 @@ FROM sensor_readings;
 23 23
 24 24
 25 25
+
+# Regex / LIKE match against an REE column whose values are themselves Dictionary-encoded
+query BB rowsort
+SELECT
+    arrow_cast(
+        arrow_cast(sensor_id, 'Dictionary(UInt32, Utf8)'),
+        'RunEndEncoded("run_ends": non-null Int32, "values": Dictionary(UInt32, Utf8))'
+    ) ~ 'sensor_A',
+    arrow_cast(
+        arrow_cast(sensor_id, 'Dictionary(UInt32, Utf8)'),
+        'RunEndEncoded("run_ends": non-null Int32, "values": Dictionary(UInt32, Utf8))'
+    ) LIKE 'sensor_A'
+FROM sensor_readings;
+----
+false false
+true true
+true true
+true true


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org