diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FunctionBinder.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FunctionBinder.java index 6488e5e76a..2c72170e78 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FunctionBinder.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FunctionBinder.java @@ -315,9 +315,11 @@ public class FunctionBinder extends AbstractExpressionRewriteRule { Expression left = match.left().accept(this, context); Expression right = match.right().accept(this, context); // check child type - if (!left.getDataType().isStringLikeType()) { + if (!left.getDataType().isStringLikeType() + && !(left.getDataType() instanceof ArrayType + && ((ArrayType) left.getDataType()).getItemType().isStringLikeType())) { throw new AnalysisException(String.format( - "left operand '%s' part of predicate " + "'%s' should return type 'STRING' but " + "left operand '%s' part of predicate " + "'%s' should return type 'STRING' or 'ARRAY' but " + "returns type '%s'.", left.toSql(), match.toSql(), left.getDataType())); } diff --git a/regression-test/data/inverted_index_p0/test_array_index.out b/regression-test/data/inverted_index_p0/test_array_index.out index c23617fbdb..b04af8fa44 100644 --- a/regression-test/data/inverted_index_p0/test_array_index.out +++ b/regression-test/data/inverted_index_p0/test_array_index.out @@ -69,3 +69,29 @@ -- !sql -- 2 [20, 30, 40] ["i", "love", "north korea"] +-- !sql -- +1 [10, 20, 30] ["i", "love", "china"] + +-- !sql -- +1 [10, 20, 30] ["i", "love", "china"] +2 [20, 30, 40] ["i", "love", "north korea"] + +-- !sql -- +2 [20, 30, 40] ["i", "love", "north korea"] + +-- !sql -- +2 [20, 30, 40] ["i", "love", "north korea"] + +-- !sql -- +1 [10, 20, 30] ["i", "love", "china"] + +-- !sql -- +1 [10, 20, 30] ["i", "love", "china"] +2 [20, 30, 40] ["i", "love", "north korea"] + +-- !sql -- +2 [20, 30, 40] ["i", "love", "north korea"] + +-- !sql -- +2 [20, 30, 40] ["i", "love", "north korea"] + diff --git a/regression-test/suites/inverted_index_p0/test_array_index.groovy b/regression-test/suites/inverted_index_p0/test_array_index.groovy index 7fd95f5ad1..6ecab7b517 100644 --- a/regression-test/suites/inverted_index_p0/test_array_index.groovy +++ b/regression-test/suites/inverted_index_p0/test_array_index.groovy @@ -65,9 +65,24 @@ suite("test_array_index"){ qt_sql "SELECT * FROM $indexTblName WHERE int_array element_eq 50 ORDER BY id;" qt_sql "SELECT * FROM $indexTblName WHERE int_array element_eq 60 ORDER BY id;" + sql "set enable_fallback_to_original_planner=false" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'china' ORDER BY id;" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'love' ORDER BY id;" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'north' ORDER BY id;" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'korea' ORDER BY id;" + sql "set enable_fallback_to_original_planner=true" + + sql " ALTER TABLE $indexTblName drop index c_array_idx; " qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'china' ORDER BY id;" qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'love' ORDER BY id;" qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'north' ORDER BY id;" qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'korea' ORDER BY id;" + + sql "set enable_fallback_to_original_planner=false" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'china' ORDER BY id;" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'love' ORDER BY id;" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'north' ORDER BY id;" + qt_sql "SELECT * FROM $indexTblName WHERE c_array MATCH 'korea' ORDER BY id;" + sql "set enable_fallback_to_original_planner=true" }