Skip to content

Commit

Permalink
fix: dont try to coerce list for regex match (apache#11646)
Browse files Browse the repository at this point in the history
* fix: dont try to coerce list for regex

* feat: add test for regex planning error

* fix: add error to prove during planning
  • Loading branch information
tshauck authored Jul 26, 2024
1 parent 64af410 commit cdf387e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion datafusion/expr/src/type_coercion/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,6 @@ pub fn like_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTyp
/// This is a union of string coercion rules and dictionary coercion rules
pub fn regex_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
string_coercion(lhs_type, rhs_type)
.or_else(|| list_coercion(lhs_type, rhs_type))
.or_else(|| dictionary_coercion(lhs_type, rhs_type, false))
}

Expand Down
1 change: 1 addition & 0 deletions datafusion/functions/src/regex/regexpmatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use std::sync::Arc;
pub struct RegexpMatchFunc {
signature: Signature,
}

impl Default for RegexpMatchFunc {
fn default() -> Self {
Self::new()
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sqllogictest/test_files/regexp.slt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ SELECT 'foo\nbar\nbaz' ~ 'bar';
----
true

statement error
Error during planning: Cannot infer common argument type for regex operation List(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata
: {} }) ~ List(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })
select [1,2] ~ [3];

query B
SELECT 'foo\nbar\nbaz' LIKE '%bar%';
----
Expand Down

0 comments on commit cdf387e

Please sign in to comment.