This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 4d9a3e950a #7219 (#7222)
4d9a3e950a is described below
commit 4d9a3e950a7279a5c5436e1a4a18c99c16ab7f41
Author: Bart Maertens <[email protected]>
AuthorDate: Sun Jun 7 11:09:42 2026 +0200
#7219 (#7222)
* fix inner loop variable. fixes #7219
* integration test for #7219
---
.../transforms/0102-sorted-merge-multi-copy.hpl | 172 +++++++++++++++++++++
.../datasets/golden-sorted-merge-multi-copy.csv | 3 +
.../main-0102-sorted-merge-multi-copy.hwf | 80 ++++++++++
.../dataset/golden-sorted-merge-multi-copy.json | 16 ++
.../0102-sorted-merge-multi-copy UNIT.json | 28 ++++
.../transforms/sortedmerge/SortedMerge.java | 2 +-
6 files changed, 300 insertions(+), 1 deletion(-)
diff --git a/integration-tests/transforms/0102-sorted-merge-multi-copy.hpl
b/integration-tests/transforms/0102-sorted-merge-multi-copy.hpl
new file mode 100644
index 0000000000..7de0219f6f
--- /dev/null
+++ b/integration-tests/transforms/0102-sorted-merge-multi-copy.hpl
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0102-sorted-merge-multi-copy</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Regression for issue #7219: Sort Rows (many copies) with few
rows into Sorted Merge.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/06/03 20:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/06/03 20:00:00.000</modified_date>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>input</from>
+ <to>Sort rows</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Sort rows</from>
+ <to>Sorted merge</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Sorted merge</from>
+ <to>validate</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>input</name>
+ <type>DataGrid</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <data>
+ <line>
+ <item>zebra</item>
+ </line>
+ <line>
+ <item>alpha</item>
+ </line>
+ </data>
+ <fields>
+ <field>
+ <length>-1</length>
+ <precision>-1</precision>
+ <currency/>
+ <set_empty_string>N</set_empty_string>
+ <name>field</name>
+ <format/>
+ <group/>
+ <decimal/>
+ <type>String</type>
+ </field>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>128</xloc>
+ <yloc>128</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Sort rows</name>
+ <type>SortRows</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>20</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <name>field</name>
+ <ascending>Y</ascending>
+ <case_sensitive>N</case_sensitive>
+ <collator_enabled>N</collator_enabled>
+ <collator_strength>0</collator_strength>
+ <presorted>N</presorted>
+ </field>
+ </fields>
+ <directory>${java.io.tmpdir}</directory>
+ <sort_prefix>out</sort_prefix>
+ <sort_size>1000000</sort_size>
+ <free_memory/>
+ <unique_rows>N</unique_rows>
+ <compress>N</compress>
+ <compress_variables/>
+ <attributes/>
+ <GUI>
+ <xloc>320</xloc>
+ <yloc>128</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Sorted merge</name>
+ <type>SortedMerge</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <name>field</name>
+ <ascending>Y</ascending>
+ </field>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>512</xloc>
+ <yloc>128</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>validate</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <attributes/>
+ <GUI>
+ <xloc>704</xloc>
+ <yloc>128</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git
a/integration-tests/transforms/datasets/golden-sorted-merge-multi-copy.csv
b/integration-tests/transforms/datasets/golden-sorted-merge-multi-copy.csv
new file mode 100644
index 0000000000..10b57871e0
--- /dev/null
+++ b/integration-tests/transforms/datasets/golden-sorted-merge-multi-copy.csv
@@ -0,0 +1,3 @@
+field
+alpha
+zebra
diff --git a/integration-tests/transforms/main-0102-sorted-merge-multi-copy.hwf
b/integration-tests/transforms/main-0102-sorted-merge-multi-copy.hwf
new file mode 100644
index 0000000000..a0bb62d13c
--- /dev/null
+++ b/integration-tests/transforms/main-0102-sorted-merge-multi-copy.hwf
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-0102-sorted-merge-multi-copy</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2026/06/03 20:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/06/03 20:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <DayOfMonth>1</DayOfMonth>
+ <doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
+ <hour>12</hour>
+ <intervalMinutes>60</intervalMinutes>
+ <intervalSeconds>0</intervalSeconds>
+ <minutes>0</minutes>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <weekDay>1</weekDay>
+ <parallel>N</parallel>
+ <xloc>96</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0102-sorted-merge-multi-copy UNIT</name>
+ <description/>
+ <type>RunPipelineTests</type>
+ <attributes/>
+ <test_names>
+ <test_name>
+ <name>0102-sorted-merge-multi-copy UNIT</name>
+ </test_name>
+ </test_names>
+ <parallel>N</parallel>
+ <xloc>288</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>0102-sorted-merge-multi-copy UNIT</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/integration-tests/transforms/metadata/dataset/golden-sorted-merge-multi-copy.json
b/integration-tests/transforms/metadata/dataset/golden-sorted-merge-multi-copy.json
new file mode 100644
index 0000000000..376a412c4f
--- /dev/null
+++
b/integration-tests/transforms/metadata/dataset/golden-sorted-merge-multi-copy.json
@@ -0,0 +1,16 @@
+{
+ "base_filename": "golden-sorted-merge-multi-copy.csv",
+ "name": "golden-sorted-merge-multi-copy",
+ "description": "",
+ "dataset_fields": [
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "field",
+ "field_format": ""
+ }
+ ],
+ "folder_name": ""
+}
diff --git
a/integration-tests/transforms/metadata/unit-test/0102-sorted-merge-multi-copy
UNIT.json
b/integration-tests/transforms/metadata/unit-test/0102-sorted-merge-multi-copy
UNIT.json
new file mode 100644
index 0000000000..9cb4d412fe
--- /dev/null
+++
b/integration-tests/transforms/metadata/unit-test/0102-sorted-merge-multi-copy
UNIT.json
@@ -0,0 +1,28 @@
+{
+ "database_replacements": [],
+ "autoOpening": true,
+ "description": "",
+ "persist_filename": "",
+ "test_type": "UNIT_TEST",
+ "variableValues": [],
+ "basePath": "${HOP_UNIT_TESTS_FOLDER}",
+ "golden_data_sets": [
+ {
+ "field_mappings": [
+ {
+ "transform_field": "field",
+ "data_set_field": "field"
+ }
+ ],
+ "field_order": [
+ "field"
+ ],
+ "data_set_name": "golden-sorted-merge-multi-copy",
+ "transform_name": "validate"
+ }
+ ],
+ "input_data_sets": [],
+ "name": "0102-sorted-merge-multi-copy UNIT",
+ "trans_test_tweaks": [],
+ "pipeline_filename": "./0102-sorted-merge-multi-copy.hpl"
+}
diff --git
a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java
b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java
index dbbdea382b..5606316fdc 100644
---
a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java
+++
b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java
@@ -142,7 +142,7 @@ public class SortedMerge extends
BaseTransform<SortedMergeMeta, SortedMergeData>
// Get the indexes of the specified sort fields...
data.fieldIndices = new int[meta.getMergeFields().size()];
for (int f = 0; f < data.fieldIndices.length; f++) {
- SortedMergeMeta.MergeField mergeField =
meta.getMergeFields().get(i);
+ SortedMergeMeta.MergeField mergeField =
meta.getMergeFields().get(f);
data.fieldIndices[f] =
data.rowMeta.indexOfValue(mergeField.getFieldName());
if (data.fieldIndices[f] < 0) {
throw new HopTransformException(