bamaer commented on code in PR #9529:
URL: https://github.com/apache/hop/pull/9529#discussion_r4596640735


##########
plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java:
##########
@@ -160,10 +164,12 @@ private void getRowSortedFirstCall() throws 
HopTransformException {
         }
       }
 
+      // Compare with the metadata that carries the merge settings: the 
metadata of the rows only
+      // says how they are sorted when the transform before this one says so
       data.comparator =
           (o1, o2) -> {
             try {
-              return o1.getRowMeta().compare(o1.getRowData(), o2.getRowData(), 
data.fieldIndices);
+              return data.rowMeta.compare(o1.getRowData(), o2.getRowData(), 
data.fieldIndices);

Review Comment:
   **Blocker:** the merge setting now overrides the input's sort flag. As a 
result, Sort rows (descending) into a Sorted merge on Ascending = Y stops with 
an error. #9528 lists this case as working, and Get fields fills in Y, so 
existing pipelines are likely set up this way. `echo, charlie, alpha` + 
`foxtrot, delta, bravo` give `foxtrot … alpha` on main and `key=charlie comes 
after key=echo` here.
   
   Suggested fix: merge a field descending when the setting says N or the input 
already says descending (L162):
   ```java
   IValueMeta keyMeta = data.rowMeta.getValueMeta(data.fieldIndices[f]);
   keyMeta.setSortedDescending(!mergeField.isAscending() || 
keyMeta.isSortedDescending());
   ```
   That keeps main's output for this case and still fixes the Data grid case. 
The Verify warning, the error hint and the docs paragraph would then need 
rewording, and this case could go into 0129 as a third branch.



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