xuzifu666 commented on code in PR #5240:
URL: https://github.com/apache/calcite/pull/5240#discussion_r3926031446
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -8393,94 +8532,6 @@ protected SqlNode expandDynamicStar(SqlIdentifier id,
SqlIdentifier fqId) {
return fqId;
}
- protected SqlNode expandCommonColumn(SqlSelect sqlSelect, SqlNode
selectItem,
Review Comment:
The common-column expansion logic (expandCommonColumn) lived as a protected
method of the static inner class Expander, so only its subclasses could call it
— SelectExpander (SELECT path) and ExtendedExpander (GROUP BY path). The ORDER
BY path runs in a different hierarchy (OrderExpressionExpander extends
SqlScopedShuttle) and had no access to it. That's the root cause of the bug:
without expansion, deptno resolves in both join inputs and fails with Column
'DEPTNO' is ambiguous.
Fix: Promote the method to an instance method of the outer SqlValidatorImpl,
making it callable from both hierarchies. A new wrapAlias flag was added:
SELECT/GROUP BY keep the AS wrapper as before (unchanged behavior), while ORDER
BY expands to a bare reference.
--
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]