This is an automated email from the ASF dual-hosted git repository.
mcasters 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 9b31a6b588 zero rows handling similar to javascript transform and
initial version IT. fixes #6875 (#6879)
9b31a6b588 is described below
commit 9b31a6b588586d35d49906c8e24fa263d95741cb
Author: Bart Maertens <[email protected]>
AuthorDate: Thu Mar 26 09:38:47 2026 +0000
zero rows handling similar to javascript transform and initial version IT.
fixes #6875 (#6879)
---
.../scripting/0004-script-zero-rows-6875.hpl | 144 +++++++++++++++++++++
.../scripting/main-0004-script-zero-rows-6875.hwf | 98 ++++++++++++++
.../hop/pipeline/transforms/script/Script.java | 59 ++++-----
3 files changed, 270 insertions(+), 31 deletions(-)
diff --git a/integration-tests/scripting/0004-script-zero-rows-6875.hpl
b/integration-tests/scripting/0004-script-zero-rows-6875.hpl
new file mode 100644
index 0000000000..d04e602c6b
--- /dev/null
+++ b/integration-tests/scripting/0004-script-zero-rows-6875.hpl
@@ -0,0 +1,144 @@
+<?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>0004-script-zero-rows-6875</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Verify that a Groovy Script transform with type
'Transform Script' does not fail when the pipeline receives 0 rows
(GitHub #6875)</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/03/25 00:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/03/25 00:00:00.000</modified_date>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>0 rows</from>
+ <to>Process data</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Process data</from>
+ <to>Output</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>0 rows</name>
+ <type>RowGenerator</type>
+ <description>Generates a field called 'data' but with limit 0 so
no rows flow downstream</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <name>data</name>
+ <type>String</type>
+ <format/>
+ <currency/>
+ <decimal/>
+ <group/>
+ <nullif>test</nullif>
+ <length>-1</length>
+ <precision>-1</precision>
+ <set_empty_string>N</set_empty_string>
+ </field>
+ </fields>
+ <limit>0</limit>
+ <never_ending>N</never_ending>
+ <interval_in_ms>5000</interval_in_ms>
+ <row_time_field>now</row_time_field>
+ <last_time_field>FiveSecondsAgo</last_time_field>
+ <attributes/>
+ <GUI>
+ <xloc>112</xloc>
+ <yloc>96</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Process data</name>
+ <type>SuperScript</type>
+ <description>Groovy Transform Script that references field
'data' - must not fail with 0 input rows</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <length>-1</length>
+ <name>result</name>
+ <precision>-1</precision>
+ <rename>result</rename>
+ <replace>N</replace>
+ <scriptResult>N</scriptResult>
+ <type>String</type>
+ </field>
+ </fields>
+ <scriptLanguage>Groovy</scriptLanguage>
+ <scripts>
+ <script>
+ <scriptBody>result = data.toUpperCase()</scriptBody>
+ <scriptName>script1</scriptName>
+ <scriptType>0</scriptType>
+ </script>
+ </scripts>
+ <attributes/>
+ <GUI>
+ <xloc>304</xloc>
+ <yloc>96</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Output</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <attributes/>
+ <GUI>
+ <xloc>496</xloc>
+ <yloc>96</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/scripting/main-0004-script-zero-rows-6875.hwf
b/integration-tests/scripting/main-0004-script-zero-rows-6875.hwf
new file mode 100644
index 0000000000..4cd5473b41
--- /dev/null
+++ b/integration-tests/scripting/main-0004-script-zero-rows-6875.hwf
@@ -0,0 +1,98 @@
+<?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-0004-script-zero-rows-6875</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/03/25 00:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/03/25 00:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <nr>0</nr>
+ <xloc>128</xloc>
+ <yloc>96</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0004-script-zero-rows-6875.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0004-script-zero-rows-6875.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <follow_abort_remote>N</follow_abort_remote>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <nr>0</nr>
+ <xloc>304</xloc>
+ <yloc>96</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>0004-script-zero-rows-6875.hpl</to>
+ <from_nr>0</from_nr>
+ <to_nr>0</to_nr>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/Script.java
b/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/Script.java
index f1d1fa8906..914db120a1 100644
---
a/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/Script.java
+++
b/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/Script.java
@@ -611,41 +611,38 @@ public class Script extends BaseTransform<ScriptMeta,
ScriptData> implements ITr
}
}
- @Override
- public boolean processRow() throws HopException {
- Object[] r = getRow();
- if (r == null && !first) {
- // Modification for Additional End Function
- try {
- if (data.engine != null) {
-
- // Run the start and transformation scripts once if there are no
incoming rows
-
- // Checking for EndScript
- if (!Utils.isEmpty(strEndScript)) {
- data.engine.eval(strEndScript, bindings);
- if (isDetailed()) {
- logDetailed(("End Script found!"));
- }
- } else {
- if (isDetailed()) {
- logDetailed(("No end Script found!"));
- }
+ private void processEndOfStream() {
+ try {
+ if (bindings != null) {
+ // Checking for EndScript
+ if (!Utils.isEmpty(strEndScript)) {
+ data.engine.eval(strEndScript, bindings);
+ if (isDetailed()) {
+ logDetailed(("End Script found!"));
+ }
+ } else {
+ if (isDetailed()) {
+ logDetailed(("No end Script found!"));
}
}
- } catch (Exception e) {
- logError(BaseMessages.getString(PKG, "Script.Log.UnexpectedError") + "
: " + e);
- logError(
- BaseMessages.getString(PKG, "Script.Log.ErrorStackTrace")
- + Const.CR
- + Const.getStackTracker(e));
- setErrors(1);
- stopAll();
}
+ } catch (Exception e) {
+ logError(BaseMessages.getString(PKG, "Script.Log.UnexpectedError") + " :
" + e);
+ logError(
+ BaseMessages.getString(PKG, "Script.Log.ErrorStackTrace")
+ + Const.CR
+ + Const.getStackTracker(e));
+ setErrors(1);
+ stopAll();
+ }
+ }
- if (data.engine != null) {
- setOutputDone();
- }
+ @Override
+ public boolean processRow() throws HopException {
+ Object[] r = getRow();
+ if (r == null) {
+ processEndOfStream();
+ setOutputDone();
return false;
}