This is an automated email from the ASF dual-hosted git repository. lihaopeng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 8af8910e5df [Fix](temporary) temporarily forbid fold constant by BE for GeoFunctions (#34857) 8af8910e5df is described below commit 8af8910e5dfe262b0da6433161c610abf7f7d886 Author: zclllyybb <zhaochan...@selectdb.com> AuthorDate: Wed May 15 19:20:46 2024 +0800 [Fix](temporary) temporarily forbid fold constant by BE for GeoFunctions (#34857) --- .../rules/expression/rules/FoldConstantRuleOnBE.java | 14 +++++++++++--- .../expression/fold_constant/fold_constant_by_be.groovy | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java index e0e19bd19e2..d9e2187596b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java @@ -37,6 +37,7 @@ import org.apache.doris.nereids.trees.expressions.ArrayItemReference; import org.apache.doris.nereids.trees.expressions.Cast; import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.Match; +import org.apache.doris.nereids.trees.expressions.functions.BoundFunction; import org.apache.doris.nereids.trees.expressions.functions.generator.TableGeneratingFunction; import org.apache.doris.nereids.trees.expressions.functions.scalar.Sleep; import org.apache.doris.nereids.trees.expressions.literal.ArrayLiteral; @@ -140,6 +141,7 @@ public class FoldConstantRuleOnBE implements ExpressionPatternRuleFactory { if (root instanceof Alias) { rootWithoutAlias = ((Alias) root).child(); } + collectConst(rootWithoutAlias, constMap, staleConstTExprMap, idGenerator); if (constMap.isEmpty()) { return root; @@ -181,7 +183,7 @@ public class FoldConstantRuleOnBE implements ExpressionPatternRuleFactory { if (((Cast) expr).child().isNullLiteral()) { return; } - if (skipSleepFunction(((Cast) expr).child())) { + if (shouldSkipFold(((Cast) expr).child())) { return; } } @@ -202,7 +204,7 @@ public class FoldConstantRuleOnBE implements ExpressionPatternRuleFactory { // and ArrayItemReference translate, can't findColumnRef // Match need give more info rather then as left child a NULL, in // match_phrase_prefix/MATCH_PHRASE/MATCH_PHRASE/MATCH_ANY - if (skipSleepFunction(expr) || (expr instanceof TableGeneratingFunction) + if (shouldSkipFold(expr) || (expr instanceof TableGeneratingFunction) || (expr instanceof ArrayItemReference) || (expr instanceof Match)) { return; } @@ -230,7 +232,7 @@ public class FoldConstantRuleOnBE implements ExpressionPatternRuleFactory { } // if sleep(5) will cause rpc timeout - private static boolean skipSleepFunction(Expression expr) { + private static boolean shouldSkipFold(Expression expr) { if (expr instanceof Sleep) { Expression param = expr.child(0); if (param instanceof Cast) { @@ -239,6 +241,12 @@ public class FoldConstantRuleOnBE implements ExpressionPatternRuleFactory { if (param instanceof NumericLiteral) { return ((NumericLiteral) param).getDouble() >= 5.0; } + } else if (expr instanceof BoundFunction + && ((BoundFunction) expr).getName().toLowerCase().startsWith("st_")) { + // FIXME: remove this when we fixed serde of Geo types + LOG.warn("GeoFunction {} now don't support constant fold on BE", + ((BoundFunction) expr).getName()); + return true; } return false; } diff --git a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy index e1162c662b9..e09a554a3f8 100644 --- a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy +++ b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy @@ -40,4 +40,9 @@ suite("fold_constant_by_be") { sql """ INSERT INTO str_tb VALUES (2, repeat("test1111", 10000)); """ qt_sql_1 """ select length(v1) from str_tb; """ + + def res1 = sql " select /*+SET_VAR(enable_fold_constant_by_be=true)*/ ST_CIRCLE(121.510651, 31.234391, 1918.0); " + def res2 = sql " select /*+SET_VAR(enable_fold_constant_by_be=false)*/ ST_CIRCLE(121.510651, 31.234391, 1918.0); " + log.info("result: {}, {}", res1, res2) + assertEquals(res1[0][0], res2[0][0]) } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org