1fanwang commented on code in PR #5225:
URL: https://github.com/apache/calcite/pull/5225#discussion_r4359363472
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -5470,6 +5470,17 @@ private void validateOrderItem(SqlSelect select, SqlNode
orderItem) {
final SqlValidatorScope orderScope = getOrderScope(select);
validateExpr(orderItem, orderScope);
+
+ final RelDataType type = deriveType(orderScope, orderItem);
+ if (!type.isMeasure()) {
+ final SqlNode expanded = expandOrderExpr(select, orderItem);
+ // Validate in the SELECT scope rather than ORDER BY scope so that
+ // expressions expanded from SELECT-list aliases (e.g. an aggregate
referencing
+ // an alias that shadows a column) are checked for validity (such as
disallowing
+ // nested aggregates). Measures are skipped because measure expressions
are validated
+ // in MeasureScope and can reference other select items not present in
table scopes.
+ expanded.validate(this, getSelectScope(select));
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]