From b0edaa31e0f25b15ea66180ea29639162de3fb34 Mon Sep 17 00:00:00 2001 From: Jonathan Chen Date: Sat, 7 Feb 2026 12:22:24 -0600 Subject: [PATCH 1/2] Error at coercion --- .../expr-common/src/type_coercion/binary.rs | 3 ++- .../sqllogictest/test_files/type_coercion.slt | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rs index 9051f412bde9b..97ec54b298ed1 100644 --- a/datafusion/expr-common/src/type_coercion/binary.rs +++ b/datafusion/expr-common/src/type_coercion/binary.rs @@ -1793,9 +1793,10 @@ fn binary_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option /// 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.) pub fn like_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option { string_coercion(lhs_type, rhs_type) - .or_else(|| list_coercion(lhs_type, rhs_type)) .or_else(|| binary_to_string_coercion(lhs_type, rhs_type)) .or_else(|| dictionary_comparison_coercion(lhs_type, rhs_type, false)) .or_else(|| ree_comparison_coercion(lhs_type, rhs_type, false)) diff --git a/datafusion/sqllogictest/test_files/type_coercion.slt b/datafusion/sqllogictest/test_files/type_coercion.slt index e3baa8fedcf63..a3bce465a78e0 100644 --- a/datafusion/sqllogictest/test_files/type_coercion.slt +++ b/datafusion/sqllogictest/test_files/type_coercion.slt @@ -254,3 +254,30 @@ DROP TABLE orders; ######################################## ## Test type coercion with UNIONs end ## ######################################## + +# https://github.com/apache/datafusion/issues/15661 +# LIKE is a string pattern matching operator and is not supported for nested types. + +statement ok +CREATE TABLE t0(v0 BIGINT, v1 STRING, v2 BOOLEAN); + +statement ok +INSERT INTO t0(v0, v2) VALUES (123, true); + +query error There isn't a common type to coerce .* in .* expression +SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) NOT LIKE (REGEXP_MATCH(t0.v1, t0.v1, 'jH'))); + +query error There isn't a common type to coerce .* in .* expression +SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) NOT LIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); + +query error There isn't a common type to coerce .* in .* expression +SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) LIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); + +query error There isn't a common type to coerce .* in .* expression +SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) ILIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); + +query error There isn't a common type to coerce .* in .* expression +SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) NOT ILIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); + +statement ok +DROP TABLE t0; From 00908b969fc2a747928f4e7c5edcde9528539df7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 8 Feb 2026 03:08:37 -0600 Subject: [PATCH 2/2] simplify regexp --- datafusion/sqllogictest/test_files/type_coercion.slt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/datafusion/sqllogictest/test_files/type_coercion.slt b/datafusion/sqllogictest/test_files/type_coercion.slt index a3bce465a78e0..8ab5b63e697d6 100644 --- a/datafusion/sqllogictest/test_files/type_coercion.slt +++ b/datafusion/sqllogictest/test_files/type_coercion.slt @@ -268,16 +268,16 @@ query error There isn't a common type to coerce .* in .* expression SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) NOT LIKE (REGEXP_MATCH(t0.v1, t0.v1, 'jH'))); query error There isn't a common type to coerce .* in .* expression -SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) NOT LIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); +SELECT true FROM t0 WHERE (REGEXP_MATCH(t0.v1, t0.v1)) NOT LIKE []; query error There isn't a common type to coerce .* in .* expression -SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) LIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); +SELECT true FROM t0 WHERE (REGEXP_MATCH(t0.v1, t0.v1)) LIKE []; query error There isn't a common type to coerce .* in .* expression -SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) ILIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); +SELECT true FROM t0 WHERE (REGEXP_MATCH(t0.v1, t0.v1)) ILIKE []; query error There isn't a common type to coerce .* in .* expression -SELECT true FROM t0 WHERE ((REGEXP_MATCH(t0.v1, t0.v1)) NOT ILIKE (REGEXP_MATCH(t0.v1, t0.v1, 'i'))); +SELECT true FROM t0 WHERE (REGEXP_MATCH(t0.v1, t0.v1)) NOT ILIKE []; statement ok DROP TABLE t0;