1fanwang commented on code in PR #5225:
URL: https://github.com/apache/calcite/pull/5225#discussion_r4359359529
##########
core/src/test/java/org/apache/calcite/test/JdbcTest.java:
##########
@@ -3391,6 +3391,14 @@ void testJoinWithTrimmingConfigs(boolean
enableTrimmingByConfig,
+ "store_id=0; grocery_sqft=null\n");
}
+ @Test void testOrderByAggregateAliasShadowing() {
Review Comment:
Done in
https://github.com/apache/calcite/commit/e15fedacd779cf8d632b17dd66229b2173a766e0.
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -8553,7 +8564,48 @@ private SqlNode nthSelectItem(int ordinal, final
SqlParserPos pos) {
// Create a copy of the expression with the position of the order
// item.
- return expr.clone(pos);
+ return reposition(expr, pos);
+ }
+
+ private SqlNode reposition(SqlNode node, SqlParserPos pos) {
+ SqlNode res = node.accept(new SqlShuttle() {
+ @Override public @Nullable SqlNode visit(SqlIdentifier id) {
+ return id.clone(pos);
+ }
+
+ @Override public @Nullable SqlNode visit(SqlLiteral literal) {
+ return literal.clone(pos);
+ }
+
+ @Override public @Nullable SqlNode visit(SqlDataTypeSpec type) {
+ return type.clone(pos);
+ }
+
+ @Override public @Nullable SqlNode visit(SqlDynamicParam param) {
+ return param.clone(pos);
+ }
+
+ @Override public @Nullable SqlNode visit(SqlIntervalQualifier
intervalQualifier) {
+ return intervalQualifier.clone(pos);
+ }
+
+ @Override public @Nullable SqlNode visit(SqlNodeList nodeList) {
+ SqlNodeList list = (SqlNodeList) super.visit(nodeList);
+ return list == null ? null : list.clone(pos);
+ }
+
+ @Override public @Nullable SqlNode visit(SqlCall call) {
+ if (call.isA(SqlKind.QUERY)
Review Comment:
Done in
https://github.com/apache/calcite/commit/e15fedacd779cf8d632b17dd66229b2173a766e0.
--
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]