Copilot commented on code in PR #17843:
URL: https://github.com/apache/iotdb/pull/17843#discussion_r3373109943


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java:
##########
@@ -4102,11 +4212,16 @@ private FieldReference getFieldReferenceForFillGroup(
     }
 
     private List<Expression> analyzeOrderBy(
-        Node node, List<SortItem> sortItems, Scope orderByScope) {
+        Node node,
+        List<SortItem> sortItems,
+        Scope sourceScope,
+        Scope orderByScope,
+        List<SelectAlias> selectAliases) {
       ImmutableList.Builder<Expression> orderByFieldsBuilder = 
ImmutableList.builder();
 
       for (SortItem item : sortItems) {
         Expression expression = item.getSortKey();
+        Scope expressionScope = sourceScope;

Review Comment:
   `analyzeOrderBy` now analyzes non-ordinal, non-alias ORDER BY expressions 
using `sourceScope` by default. That scope does not include the SELECT output 
fields, which contradicts the intent documented in 
`computeAndAssignOrderByScope` (ORDER BY should “see” both output and FROM 
fields) and changes prior behavior where expressions were analyzed against the 
ORDER BY scope. This can cause regressions for ORDER BY items that rely on 
output-field name resolution (including non-`AS` output names) when no explicit 
alias match is found.



-- 
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]

Reply via email to