github-actions[bot] commented on code in PR #66785:
URL: https://github.com/apache/doris/pull/66785#discussion_r3792022602
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########
@@ -501,6 +502,9 @@ public Expression visitCast(Cast cast,
ExpressionRewriteContext context) {
}
Expression child = cast.child();
DataType dataType = cast.getDataType();
+ if (!CheckCast.check(child.getDataType(), dataType,
SessionVariable.enableStrictCast())) {
+ return cast;
Review Comment:
This early return relies on a later `CheckCast`, but validation currently
happens after rules that can erase constant expressions. For example:
`Sort(CAST(CAST(20240229112233 AS BIGINT) AS TIMESTAMPTZ(6)))`
is processed by `EliminateOrderByConstant` before expression normalization;
because the invalid deterministic cast is still `isConstant()`, the sort key is
removed and `CheckCast` never sees it. Similarly,
`NormalizeAggregate.eliminateGroupByConstant` folds a GROUP BY-only occurrence,
treats the unchanged cast as constant, and removes it before validation. Thus
the corresponding `ORDER BY` and `GROUP BY` queries can be accepted while the
projected expression in the new regression errors. The default fast `INSERT ...
VALUES` analyzer also invokes this folder without any `CheckCast` and skips
normal rewrite, so that path fails only during BE execution. Please enforce
cast legality before constant-expression elimination/translation, and add
regressions for these paths.
--
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]