xuzifu666 commented on code in PR #5240:
URL: https://github.com/apache/calcite/pull/5240#discussion_r3943037168
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -5325,9 +5426,19 @@ protected void validateOrderList(SqlSelect select) {
final SqlValidatorScope orderScope = getOrderScope(select);
requireNonNull(orderScope, "orderScope");
+ // Expand unqualified common columns of NATURAL or USING joins before
+ // regular expansion, which would fail with an ambiguity error.
+ final SelectScope selectScope = getRawSelectScopeNonNull(select);
List<SqlNode> expandList = new ArrayList<>();
for (SqlNode orderItem : orderList) {
- SqlNode expandedOrderItem = expand(orderItem, orderScope);
+ SqlNode expandedCommon =
+ expandCommonColumnInOrderBy(orderItem, select, selectScope);
+ final SqlNode expandedOrderItem;
+ if (expandedCommon != orderItem) {
Review Comment:
Good catch! the if was redundant, since when `expandedCommon == orderItem`
both branches are identical. Simplified to a single expand(`expandedCommon`,
`orderScope`) call.
--
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]