[opt](Nereids) match predicate support array as first arg (#25172)
This commit is contained in:
@ -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<STRING>' but "
|
||||
+ "returns type '%s'.",
|
||||
left.toSql(), match.toSql(), left.getDataType()));
|
||||
}
|
||||
|
||||
@ -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"]
|
||||
|
||||
|
||||
@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user