Skip to content

Commit

Permalink
Synchronize After Merge - specify connection through variables #3839 (#…
Browse files Browse the repository at this point in the history
…3937)

* Synchronize After Merge - specify connection through variables #3839

* Add variable to the test, #3839

---------

Co-authored-by: Hans Van Akelyen <hans.van.akelyen@gmail.com>
  • Loading branch information
nadment and hansva committed May 16, 2024
1 parent 2cf44e4 commit b37a4d8
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 204 deletions.
152 changes: 67 additions & 85 deletions integration-tests/database/0013-synchronize-after-merge.hpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ limitations under the License.
<created_date>2021/04/30 11:01:28.333</created_date>
<modified_user>-</modified_user>
<modified_date>2021/04/30 11:01:28.333</modified_date>
<key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
<is_key_private>N</is_key_private>
</info>
<notepads>
</notepads>
Expand All @@ -57,69 +55,6 @@ limitations under the License.
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>source</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<field>
<name>key</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
<field>
<name>value</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
</fields>
<data>
<line>
<item>10</item>
<item>aa</item>
</line>
<line>
<item>20</item>
<item>bb</item>
</line>
<line>
<item>30</item>
<item>cc</item>
</line>
<line>
<item>40</item>
<item>dd</item>
</line>
<line>
<item>50</item>
<item>ee</item>
</line>
</data>
<attributes/>
<GUI>
<xloc>144</xloc>
<yloc>96</yloc>
</GUI>
</transform>
<transform>
<name>Merge rows (diff)</name>
<type>MergeRows</type>
Expand Down Expand Up @@ -159,7 +94,7 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
<connection>unit-test-db</connection>
<connection>${DATABASE_NAME}</connection>
<commit>100</commit>
<tablename_in_field>N</tablename_in_field>
<tablename_field/>
Expand Down Expand Up @@ -206,35 +141,70 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
<data>
<line>
<item>10</item>
<item>aa</item>
</line>
<line>
<item>30</item>
<item>cc</item>
</line>
<line>
<item>40</item>
<item>dd</item>
</line>
<line>
<item>50</item>
<item>e</item>
</line>
<line>
<item>60</item>
<item>ff</item>
</line>
</data>
<fields>
<field>
<name>key</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>key</name>
<type>String</type>
</field>
<field>
<name>value</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>value</name>
<type>String</type>
</field>
</fields>
<attributes/>
<GUI>
<xloc>336</xloc>
<yloc>224</yloc>
</GUI>
</transform>
<transform>
<name>source</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<data>
<line>
<item>10</item>
<item>aa</item>
</line>
<line>
<item>20</item>
<item>bb</item>
</line>
<line>
<item>30</item>
<item>cc</item>
Expand All @@ -245,17 +215,29 @@ limitations under the License.
</line>
<line>
<item>50</item>
<item>e</item>
</line>
<line>
<item>60</item>
<item>ff</item>
<item>ee</item>
</line>
</data>
<fields>
<field>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>key</name>
<type>String</type>
</field>
<field>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>value</name>
<type>String</type>
</field>
</fields>
<attributes/>
<GUI>
<xloc>336</xloc>
<yloc>224</yloc>
<xloc>144</xloc>
<yloc>96</yloc>
</GUI>
</transform>
<transform_error_handling>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,7 @@ public IRowMeta getRequiredFields(IVariables variables) throws HopException {
getParentTransformMeta().getParentPipelineMeta().findDatabase(connection, variables);

if (databaseMeta != null) {
Database db = new Database(loggingObject, variables, databaseMeta);
try {
try (Database db = new Database(loggingObject, variables, databaseMeta)) {
db.connect();

if (!Utils.isEmpty(realTableName)) {
Expand All @@ -647,8 +646,6 @@ public IRowMeta getRequiredFields(IVariables variables) throws HopException {
} catch (Exception e) {
throw new HopException(
BaseMessages.getString(PKG, "InsertUpdateMeta.Exception.ErrorGettingFields"), e);
} finally {
db.disconnect();
}
} else {
throw new HopException(
Expand Down
Loading

0 comments on commit b37a4d8

Please sign in to comment.