hansva opened a new issue, #9528:
URL: https://github.com/apache/hop/issues/9528

   ### Apache Hop version?
   
   2.20.0
   
   ### Java version?
   
   21
   
   ### Operating system
   
   Windows
   
   ### What happened?
   
   With a merge field set to descending (Ascending = N), Sorted merge compares 
the rows in ascending order. Two inputs 5, 3, 1 and 6, 4, 2 merge to 5, 3, 1, 
6, 4, 2 instead of 6, 5, 4, 3, 2, 1, without an error.
   
   Two cases work: ascending merges, and descending merges whose inputs come 
straight from a Sort rows on the same field. Sort rows marks the field 
descending in its output metadata, so the flag happens to reach Sorted merge. 
Descending input from anything else, such as a Table input with `ORDER BY … 
DESC`, a sorted file or a Data grid, merges wrongly.
   
   ### Cause
   
   `SortedMerge` sets the descending flag on `data.rowMeta`, a clone of the 
first input's row metadata. The comparator compares with each row's own 
metadata, `o1.getRowMeta()`, which is the input's original metadata and never 
gets the flag.
   
   ### How to reproduce
   
   1. Two Data grids with an Integer field `id`, one holding 5, 3, 1 and the 
other 6, 4, 2.
   2. Both into a Sorted merge on `id` with Ascending = N.
   3. The output is 5, 3, 1, 6, 4, 2.
   
   ### Proposed fix
   
   Compare with the metadata that carries the merge settings (`data.rowMeta`). 
Sorted merge already requires all its inputs to have the same layout, so one 
row metadata serves every input.
   
   ### Issue Priority
   
   Priority: 3
   
   ### Issue Component
   
   Component: Transforms


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