adarshomrey opened a new pull request, #70307:
URL: https://github.com/apache/doris/pull/70307

   ### Background
   
   array_sort in Nereids takes a lambda comparator with two arguments (x, y). 
During translation (ExpressionTranslator.visitArraySort), each lambda argument 
is mapped to a ColumnRefExpr.
   
   ### What problem does this PR solve?
   
   Issue Number: close #69919
   
   Related PR: None
   
   PR Type: Bugfix
   
   Problem Summary:
   
   In visitArraySort, the second ColumnRefExpr was created as a copy of the 
first one and kept the first argument's name (`x`). So the second comparator 
argument was named `x` instead of `y`. This made a nested lambda read the wrong 
argument, and an alias function wrapping array_sort did not sort. The fix sets 
the second column's name from its own ArrayItemReference 
(`column2.setName(arrayItemReference.getName())`) and updates the comment.
   
   ### Details
   
   - **Frequency:** every array_sort call with a two-argument lambda comparator
   - **Root cause:** the second ColumnRefExpr copy kept the first argument's 
name
   - **Why existing tests missed it:** no FE unit test checked the argument 
names produced by visitArraySort
   - **Fix:** set the second ColumnRefExpr name from its own ArrayItemReference
   - **Test:** 
`ExpressionTranslatorTest#testArraySortKeepsComparatorArgumentNames` fails 
without the fix (`expected: <y> but was: <x>`) and passes with it


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to