YiwenWu commented on code in PR #3797:
URL: https://github.com/apache/calcite/pull/3797#discussion_r1615584653
##########
core/src/main/java/org/apache/calcite/sql/util/SqlShuttle.java:
##########
@@ -135,6 +136,14 @@ public CallCopyingArgHandler(SqlCall call, boolean
alwaysCopy) {
if (newOperand != operand) {
update = true;
}
+
+ // Prevent nesting AS calls
+ if (i == 0 && expr instanceof SqlCall
Review Comment:
To avoid redundant `if` judgments, I suggest that the solution be more
targeted at the source `SqlValidatorImpl#expandExprFromJoin`.
For example:
```
boolean hasAlias = can judge the result from `sqlSelect` and `selectItem`
private static SqlNode expandExprFromJoin(SqlJoin join,
SqlIdentifier identifier, boolean hasAlias, SelectScope scope) {
....
SqlCall coalesce =
SqlStdOperatorTable.COALESCE.createCall(SqlParserPos.ZERO,
qualifiedNode.get(0),
qualifiedNode.get(1));
return hasAlias ? coalesce :
SqlStdOperatorTable.AS.createCall(SqlParserPos.ZERO,
coalesce, new SqlIdentifier(name, SqlParserPos.ZERO));
....
}
```
--
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]