github-actions[bot] commented on code in PR #66734:
URL: https://github.com/apache/doris/pull/66734#discussion_r3777630934
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########
@@ -121,22 +121,35 @@ public class FoldConstantRuleOnFE extends
AbstractExpressionRewriteRule
public static final FoldConstantRuleOnFE VISITOR_INSTANCE = new
FoldConstantRuleOnFE(true);
public static final FoldConstantRuleOnFE PATTERN_MATCH_INSTANCE = new
FoldConstantRuleOnFE(false);
+ private static final FoldConstantRuleOnFE CONTEXT_FREE_VISITOR_INSTANCE
+ = new FoldConstantRuleOnFE(true, false);
// record whether current expression is in an aggregate function with
distinct,
// if is, we will skip to fold constant
private static final ListenAggDistinct LISTEN_AGG_DISTINCT = new
ListenAggDistinct();
private static final CheckWhetherUnderAggDistinct NOT_UNDER_AGG_DISTINCT =
new CheckWhetherUnderAggDistinct();
private final boolean deepRewrite;
+ private final boolean foldContextDependentExpressions;
public FoldConstantRuleOnFE(boolean deepRewrite) {
+ this(deepRewrite, true);
+ }
+
+ private FoldConstantRuleOnFE(boolean deepRewrite, boolean
foldContextDependentExpressions) {
this.deepRewrite = deepRewrite;
+ this.foldContextDependentExpressions = foldContextDependentExpressions;
}
public static Expression evaluate(Expression expression,
ExpressionRewriteContext expressionRewriteContext) {
return VISITOR_INSTANCE.rewrite(expression, expressionRewriteContext);
}
+ /** Evaluate expressions that do not require a rewrite or connection
context. */
+ public static Expression evaluateWithoutContext(Expression expression) {
Review Comment:
[P1] Keep unresolved context-dependent children out of literal-only folds
The context-free entry point still crashes for a context-dependent
expression nested under `password`, for example:
```sql
select c1 from (select 1) t
lateral view stack(password(KEY test_db.test_key), 1) s as c1;
```
Reduced analysis tree:
```text
Stack(rows = Password(EncryptKeyRef("test_db", "test_key")), value = 1)
```
This row expression is deterministic, so `Stack.getNumRows()` calls
`evaluateWithoutContext`. The visitor preserves `EncryptKeyRef`, but
`visitPassword()` neither rewrites nor checks that child; it immediately
requires a `StringLikeLiteral` and throws `IllegalArgumentException` before
Stack can return its documented row-count `AnalysisException`. The direct KEY
and `CAST(KEY ... AS INT)` regressions in the existing thread do not enter this
wrapper-specific path. Please make this literal-only visitor return the
unresolved expression when a context-dependent descendant remains (while
preserving ordinary context-aware folding), and add this nested negative case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]