Skip to content

Commit a26b531

Browse files
committed
* Fix apache#6102 - Simple Evaluation: string comparison with null always return success * Fix apache#6102 - Add simple integration test (cherry picked from commit e33681e)
1 parent ce7fdc0 commit a26b531

File tree

6 files changed

+315
-22
lines changed

6 files changed

+315
-22
lines changed

docs/hop-user-manual/modules/ROOT/pages/workflow/actions/simpleeval.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The green (success) hop will be called if the condition was evaluated successful
4848
|Field name|The field to evaluate
4949
|Type|Data type.
5050
2+|Success On
51+
|Success when source variable set| The action will always success if the source variable was set otherwise it will fail.
5152
|Success condition a|
5253
* If value equal to
5354
* If value different from
@@ -73,8 +74,8 @@ The green (success) hop will be called if the condition was evaluated successful
7374
|Source: Evaluate|Variable|Select this to evaluate a variable set before
7475
|Source: Variable name|e. g. {openvar}VAR1{closevar}|Enter the variable name using the usual syntax
7576
|Source: Type|String, Number etc.|The type of your variable
76-
|Success on: Success when variable set||When this option is selected, the true path is followed when the variable is set.
77-
Note: The workflow action checks if the variable is defined, so an empty or null value is also true.
77+
|Success on: Success when source variable set||When this option is selected, the true path is followed when the source variable is set.
78+
Note: The workflow action checks if the source variable is defined, so an empty or null value is also true.
7879
When testing this within Hop you need to delete the line with the variable in the variables section of the Execute a workflow window.
7980
And remember: Once this variable is set, the variable keeps existing, even when deleting it from the list.
8081
|Success On: Success condition|Equal/Non equal/etc.|Select the condition to be met for a successful result
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<workflow>
21+
<name>0010-simpleeval-stringequal-targetvar-unset</name>
22+
<name_sync_with_filename>Y</name_sync_with_filename>
23+
<description/>
24+
<extended_description/>
25+
<workflow_version/>
26+
<workflow_status>0</workflow_status>
27+
<created_user>-</created_user>
28+
<created_date>2025/12/01 18:27:46.025</created_date>
29+
<modified_user>-</modified_user>
30+
<modified_date>2025/12/01 18:27:46.025</modified_date>
31+
<parameters>
32+
<parameter>
33+
<name>src_var</name>
34+
<default_value>PLACEHOLDER</default_value>
35+
<description/>
36+
</parameter>
37+
<parameter>
38+
<name>wrk_var</name>
39+
<default_value/>
40+
<description/>
41+
</parameter>
42+
</parameters>
43+
<actions>
44+
<action>
45+
<name>Start</name>
46+
<description/>
47+
<type>SPECIAL</type>
48+
<attributes/>
49+
<DayOfMonth>1</DayOfMonth>
50+
<doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
51+
<hour>12</hour>
52+
<intervalMinutes>60</intervalMinutes>
53+
<intervalSeconds>0</intervalSeconds>
54+
<minutes>0</minutes>
55+
<repeat>N</repeat>
56+
<schedulerType>0</schedulerType>
57+
<weekDay>1</weekDay>
58+
<parallel>N</parallel>
59+
<xloc>48</xloc>
60+
<yloc>128</yloc>
61+
<attributes_hac/>
62+
</action>
63+
<action>
64+
<name>Simple evaluation</name>
65+
<description/>
66+
<type>SIMPLE_EVAL</type>
67+
<attributes/>
68+
<comparevalue>${wrk_var}</comparevalue>
69+
<fieldtype>string</fieldtype>
70+
<successbooleancondition>true</successbooleancondition>
71+
<successcondition>equal</successcondition>
72+
<successnumbercondition>equal</successnumbercondition>
73+
<successwhenvarset>N</successwhenvarset>
74+
<valuetype>variable</valuetype>
75+
<variablename>${src_var}</variablename>
76+
<parallel>N</parallel>
77+
<xloc>384</xloc>
78+
<yloc>128</yloc>
79+
<attributes_hac/>
80+
</action>
81+
<action>
82+
<name>Write to log</name>
83+
<description/>
84+
<type>WRITE_TO_LOG</type>
85+
<attributes/>
86+
<loglevel>Basic</loglevel>
87+
<logmessage>variable 1 src_var :${src_var}
88+
variable 2 wrk_var:${wrk_var}</logmessage>
89+
<logsubject/>
90+
<parallel>N</parallel>
91+
<xloc>208</xloc>
92+
<yloc>128</yloc>
93+
<attributes_hac/>
94+
</action>
95+
<action>
96+
<name>Success</name>
97+
<description/>
98+
<type>SUCCESS</type>
99+
<attributes/>
100+
<parallel>N</parallel>
101+
<xloc>656</xloc>
102+
<yloc>128</yloc>
103+
<attributes_hac/>
104+
</action>
105+
<action>
106+
<name>Abort workflow</name>
107+
<description/>
108+
<type>ABORT</type>
109+
<attributes/>
110+
<always_log_rows>N</always_log_rows>
111+
<parallel>N</parallel>
112+
<xloc>384</xloc>
113+
<yloc>256</yloc>
114+
<attributes_hac/>
115+
</action>
116+
<action>
117+
<name>Write to log 2</name>
118+
<description/>
119+
<type>WRITE_TO_LOG</type>
120+
<attributes/>
121+
<loglevel>Basic</loglevel>
122+
<logmessage>Evaluation fails as expected: test passed</logmessage>
123+
<logsubject>Evaluation Result</logsubject>
124+
<parallel>N</parallel>
125+
<xloc>512</xloc>
126+
<yloc>128</yloc>
127+
<attributes_hac/>
128+
</action>
129+
</actions>
130+
<hops>
131+
<hop>
132+
<from>Start</from>
133+
<to>Write to log</to>
134+
<enabled>Y</enabled>
135+
<evaluation>Y</evaluation>
136+
<unconditional>Y</unconditional>
137+
</hop>
138+
<hop>
139+
<from>Write to log</from>
140+
<to>Simple evaluation</to>
141+
<enabled>Y</enabled>
142+
<evaluation>Y</evaluation>
143+
<unconditional>Y</unconditional>
144+
</hop>
145+
<hop>
146+
<from>Simple evaluation</from>
147+
<to>Abort workflow</to>
148+
<enabled>Y</enabled>
149+
<evaluation>Y</evaluation>
150+
<unconditional>N</unconditional>
151+
</hop>
152+
<hop>
153+
<from>Simple evaluation</from>
154+
<to>Write to log 2</to>
155+
<enabled>Y</enabled>
156+
<evaluation>N</evaluation>
157+
<unconditional>N</unconditional>
158+
</hop>
159+
<hop>
160+
<from>Write to log 2</from>
161+
<to>Success</to>
162+
<enabled>Y</enabled>
163+
<evaluation>Y</evaluation>
164+
<unconditional>N</unconditional>
165+
</hop>
166+
</hops>
167+
<notepads>
168+
</notepads>
169+
<attributes/>
170+
</workflow>
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<workflow>
21+
<name>main-0010-simpleval</name>
22+
<name_sync_with_filename>Y</name_sync_with_filename>
23+
<description/>
24+
<extended_description/>
25+
<workflow_version/>
26+
<created_user>-</created_user>
27+
<created_date>2021/05/05 18:31:44.849</created_date>
28+
<modified_user>-</modified_user>
29+
<modified_date>2021/05/05 18:31:44.849</modified_date>
30+
<parameters>
31+
</parameters>
32+
<actions>
33+
<action>
34+
<name>Start</name>
35+
<description/>
36+
<type>SPECIAL</type>
37+
<attributes/>
38+
<DayOfMonth>1</DayOfMonth>
39+
<doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
40+
<hour>12</hour>
41+
<intervalMinutes>60</intervalMinutes>
42+
<intervalSeconds>0</intervalSeconds>
43+
<minutes>0</minutes>
44+
<repeat>N</repeat>
45+
<schedulerType>0</schedulerType>
46+
<weekDay>1</weekDay>
47+
<parallel>N</parallel>
48+
<xloc>128</xloc>
49+
<yloc>96</yloc>
50+
<attributes_hac/>
51+
</action>
52+
<action>
53+
<name>0010-simpleeval-stringequal-targetvar-unset.hwf</name>
54+
<description/>
55+
<type>WORKFLOW</type>
56+
<attributes/>
57+
<add_date>N</add_date>
58+
<add_time>N</add_time>
59+
<create_parent_folder>N</create_parent_folder>
60+
<exec_per_row>N</exec_per_row>
61+
<filename>${PROJECT_HOME}/0010-simpleeval-stringequal-targetvar-unset.hwf</filename>
62+
<loglevel>Nothing</loglevel>
63+
<parameters>
64+
<pass_all_parameters>Y</pass_all_parameters>
65+
</parameters>
66+
<params_from_previous>N</params_from_previous>
67+
<run_configuration>local</run_configuration>
68+
<set_append_logfile>N</set_append_logfile>
69+
<set_logfile>N</set_logfile>
70+
<wait_until_finished>Y</wait_until_finished>
71+
<parallel>N</parallel>
72+
<xloc>368</xloc>
73+
<yloc>96</yloc>
74+
<attributes_hac/>
75+
</action>
76+
<action>
77+
<name>Success</name>
78+
<description/>
79+
<type>SUCCESS</type>
80+
<attributes/>
81+
<parallel>N</parallel>
82+
<xloc>656</xloc>
83+
<yloc>96</yloc>
84+
<attributes_hac/>
85+
</action>
86+
<action>
87+
<name>Abort workflow</name>
88+
<description/>
89+
<type>ABORT</type>
90+
<attributes/>
91+
<always_log_rows>N</always_log_rows>
92+
<message>Simple eval: String comparison to unset variable failed</message>
93+
<parallel>N</parallel>
94+
<xloc>368</xloc>
95+
<yloc>224</yloc>
96+
<attributes_hac/>
97+
</action>
98+
</actions>
99+
<hops>
100+
<hop>
101+
<from>Start</from>
102+
<to>0010-simpleeval-stringequal-targetvar-unset.hwf</to>
103+
<enabled>Y</enabled>
104+
<evaluation>Y</evaluation>
105+
<unconditional>Y</unconditional>
106+
</hop>
107+
<hop>
108+
<from>0010-simpleeval-stringequal-targetvar-unset.hwf</from>
109+
<to>Success</to>
110+
<enabled>Y</enabled>
111+
<evaluation>Y</evaluation>
112+
<unconditional>N</unconditional>
113+
</hop>
114+
<hop>
115+
<from>0010-simpleeval-stringequal-targetvar-unset.hwf</from>
116+
<to>Abort workflow</to>
117+
<enabled>Y</enabled>
118+
<evaluation>N</evaluation>
119+
<unconditional>N</unconditional>
120+
</hop>
121+
</hops>
122+
<notepads>
123+
</notepads>
124+
<attributes/>
125+
</workflow>

plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEval.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,7 @@ public Result execute(Result previousResult, int nr) throws HopException {
451451
success = (sourcevalue.equals(realCompareValue));
452452
if (valueType == ValueType.VARIABLE && !success && Utils.isEmpty(realCompareValue)) {
453453
// make the empty value evaluate to true when compared to a not set variable
454-
String key = StringUtil.getVariableName(variableName);
455-
if (System.getProperty(key) == null) {
454+
if (resolve(variableName) == null) {
456455
success = true;
457456
}
458457
}

plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_en_US.properties

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ ActionSimpleEval.SuccessWhenNotEndWith.Label=If value not end with
6969
ActionSimpleEval.SuccessWhenNotInList.Label=if value not in list
7070
ActionSimpleEval.SuccessWhenNotStartWith.Label=If value not start with
7171
ActionSimpleEval.SuccessWhenRegExp.Label=If value valid regex
72-
ActionSimpleEval.successWhenSet.Label=Success if variable set
73-
ActionSimpleEval.SuccessWhenSet.Label=Success when variable set
74-
ActionSimpleEval.SuccessWhenSet.Tooltip=Success when the variable is set
75-
ActionSimpleEval.successWhenSet.Tooltip=The action will success if the variable was set\notherwise it will fail.
72+
ActionSimpleEval.SuccessWhenSet.Label=Success when source variable set
73+
ActionSimpleEval.SuccessWhenSet.Tooltip=The action will always success if the source variable was set\notherwise it will fail.
7674
ActionSimpleEval.SuccessWhenSmallOrEqualThan.Label=If value is smaller or equal
7775
ActionSimpleEval.SuccessWhenSmallThan.Label=If value is small than
7876
ActionSimpleEval.SuccessWhenStartWith.Label=If value starts with

plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_it_IT.properties

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@
2020
ActionSimpleEval.CheckingVariable=Controllo della variabile [{0}] ...
2121
ActionSimpleEval.CompareValue.Label=Valore
2222
ActionSimpleEval.CompareValue.Tooltip=Valore
23-
ActionSimpleEval.Error.FieldNotExist=impossibile trovare il campo [{0}] nel precedente risultato di action\!
24-
ActionSimpleEval.Error.IncorrectDates=Date incorrette\! {0} (min) deve essere prima di {1} (max)\!
25-
ActionSimpleEval.Error.IncorrectNumbers=Numeri incorretti\! [{0}] (min) deve essere prima di [{1}] (max)\!
26-
ActionSimpleEval.Error.NoRows=Il risultato precedente \u00E8 vuoto\!
23+
ActionSimpleEval.Error.FieldNotExist=impossibile trovare il campo [{0}] nell''insieme dei risultati precedente\!
24+
ActionSimpleEval.Error.IncorrectDates=Date non corrette\! {0} (min) deve essere prima di {1} (max)\!
25+
ActionSimpleEval.Error.IncorrectNumbers=Numeri non corretti\! [{0}] (min) deve essere prima di [{1}] (max)\!
26+
ActionSimpleEval.Error.NoRows=L''insieme dei precedente \u00E8 vuoto\!
2727
ActionSimpleEval.Error.UnparsableBoolean=Errore nella conversione al valore boolean [{0}]\! Errore {1}
2828
ActionSimpleEval.Error.UnparsableDate=Impossibile convertire il valore {0} in data\!
2929
ActionSimpleEval.Error.UnparsableNumber=Impossibile convertire il valore [{0}] in numero\! {1}
30-
ActionSimpleEval.Error.VariableMissing=Manca il nome della variabile\!
31-
ActionSimpleEval.EvalPreviousField.Label=Campo dal precedente risultato
30+
ActionSimpleEval.Error.VariableMissing=Nome variabile mancante\!
31+
ActionSimpleEval.EvalPreviousField.Label=Campo dal precedente insieme dei risultati
3232
ActionSimpleEval.EvalVariable.Label=Variabile
3333
ActionSimpleEval.FieldName.Label=Nome campo
3434
ActionSimpleEval.FieldName.Tooltip=Nome campo
3535
ActionSimpleEval.FieldType.Label=Tipo
3636
ActionSimpleEval.FieldTypeBoolean.Label=Booleano
37-
ActionSimpleEval.FieldTypeDateTime.Label=Data e orario
37+
ActionSimpleEval.FieldTypeDateTime.Label=Data e ora
3838
ActionSimpleEval.FieldTypeNumber.Label=Numero
3939
ActionSimpleEval.FieldTypeString.Label=Stringa
40-
ActionSimpleEval.Log.ArgFromPrevious.Found=Trovate [{0}] righe dal precedente risultato
41-
ActionSimpleEval.Log.CompareWithValue=Comparazione del valore entrante [{0}] col valore [{1}]...
42-
ActionSimpleEval.Log.CompareWithValues=Comparazione del valore entrante [{0}] (min) e [{1}] (max)...
40+
ActionSimpleEval.Log.ArgFromPrevious.Found=Trovate [{0}] righe dall''insieme dei risultati precedente
41+
ActionSimpleEval.Log.CompareWithValue=Confronto del valore entrante [{0}] col valore [{1}]...
42+
ActionSimpleEval.Log.CompareWithValues=Confronto del valore entrante [{0}] (min) e [{1}] (max)...
4343
ActionSimpleEval.Log.ValueToevaluate=Il valore da valutare \u00E8 {0}
4444
ActionSimpleEval.Mask.Label=Maschera
4545
ActionSimpleEval.MaxValue.Label=Max
@@ -67,8 +67,8 @@ ActionSimpleEval.SuccessWhenNotEndWith.Label=Se il valore non finisce con
6767
ActionSimpleEval.SuccessWhenNotInList.Label=se il valore non \u00E8 nella lista
6868
ActionSimpleEval.SuccessWhenNotStartWith.Label=Se il valore non inizia con
6969
ActionSimpleEval.SuccessWhenRegExp.Label=Se il valore \u00E8 una regex valida
70-
ActionSimpleEval.SuccessWhenSet.Label=Successo se la variabile \u00E8 impostata
71-
ActionSimpleEval.SuccessWhenSet.Tooltip=La action avr\u00E0 successo se la variabile \u00E8 stata impostata, altrimenti fallir\u00E0.
70+
ActionSimpleEval.SuccessWhenSet.Label=Successo se variabile sorgente impostata
71+
ActionSimpleEval.SuccessWhenSet.Tooltip=La action avr\u00E0 sempre successo se la variabile sorgente \u00E8 stato impostata, altrimenti fallir\u00E0.
7272
ActionSimpleEval.SuccessWhenSmallOrEqualThan.Label=Se il valore \u00E8 minore o uguale
7373
ActionSimpleEval.SuccessWhenSmallThan.Label=Se il valore \u00E8 minore di
7474
ActionSimpleEval.SuccessWhenStartWith.Label=Se il valore inizia con
@@ -78,5 +78,5 @@ ActionSimpleEval.Title=Valutazione semplice
7878
ActionSimpleEval.ValueType.Label=Valuta
7979
ActionSimpleEval.Variable.Label=Nome variabile
8080
ActionSimpleEval.Variable.Tooltip=Nome variabile
81-
ActionSimpleEval.VariableNotSet=ActionSimpleEval.VariableNotSet\=Variabile [{0}] non \u00E8 stata impostata\!
82-
ActionSimpleEval.VariableSet=ActionSimpleEval.VariableNotSet\=Variabile [{0}] \u00E8 stata impostata\!
81+
ActionSimpleEval.VariableNotSet=ActionSimpleEval.VariableNotSet\=Variabile [{0}] non impostata\!
82+
ActionSimpleEval.VariableSet=ActionSimpleEval.VariableNotSet\=Variabile [{0}] impostata\!

0 commit comments

Comments
 (0)