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 4aa44925c3 add variable support for combination lookup update, fixes 
#6766 (#6767)
4aa44925c3 is described below

commit 4aa44925c35aee837aea82157097cc3422b8caef
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Thu Mar 12 08:21:20 2026 +0100

    add variable support for combination lookup update, fixes #6766 (#6767)
---
 .../combinationlookup/CombinationLookup.java       | 28 +++++++++-----
 .../combinationlookup/CombinationLookupDialog.java | 14 +++----
 .../combinationlookup/CombinationLookupMeta.java   | 44 ++++++++++++++--------
 3 files changed, 53 insertions(+), 33 deletions(-)

diff --git 
a/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookup.java
 
b/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookup.java
index 198a56b815..cb6928be61 100644
--- 
a/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookup.java
+++ 
b/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookup.java
@@ -87,10 +87,11 @@ public class CombinationLookup extends 
BaseTransform<CombinationLookupMeta, Comb
 
   private void determineTechKeyCreation() {
     String keyCreation = 
meta.getFields().getReturnFields().getTechKeyCreation();
-    if (meta.getDatabaseMeta().supportsAutoinc()
+    DatabaseMeta databaseMeta = 
getPipelineMeta().findDatabase(meta.getConnectionName(), variables);
+    if (databaseMeta.supportsAutoinc()
         && CombinationLookupMeta.CREATION_METHOD_AUTOINC.equals(keyCreation)) {
       setTechKeyCreation(CREATION_METHOD_AUTOINC);
-    } else if (meta.getDatabaseMeta().supportsSequences()
+    } else if (databaseMeta.supportsSequences()
         && CombinationLookupMeta.CREATION_METHOD_SEQUENCE.equals(keyCreation)) 
{
       setTechKeyCreation(CREATION_METHOD_SEQUENCE);
     } else {
@@ -233,7 +234,9 @@ public class CombinationLookup extends 
BaseTransform<CombinationLookupMeta, Comb
       lookupRow[lookupIndex] = row[rowIndex]; // KEYi = ?
       lookupIndex++;
 
-      if (meta.getDatabaseMeta().requiresCastToVariousForIsNull()
+      DatabaseMeta databaseMeta =
+          getPipelineMeta().findDatabase(meta.getConnectionName(), variables);
+      if (databaseMeta.requiresCastToVariousForIsNull()
           && rowMeta.getValueMeta(rowIndex).getType() == 
IValueMeta.TYPE_STRING) {
         lookupRow[lookupIndex] =
             rowMeta.getValueMeta(rowIndex).isNull(row[rowIndex]) ? null : 
"NotNull"; // KEYi IS
@@ -341,9 +344,11 @@ public class CombinationLookup extends 
BaseTransform<CombinationLookupMeta, Comb
       data.outputRowMeta = getInputRowMeta().clone();
       meta.getFields(data.outputRowMeta, getTransformName(), null, null, this, 
metadataProvider);
 
+      DatabaseMeta databaseMeta =
+          getPipelineMeta().findDatabase(meta.getConnectionName(), variables);
       data.schemaTable =
-          meta.getDatabaseMeta()
-              .getQuotedSchemaTableCombination(this, data.realSchemaName, 
data.realTableName);
+          databaseMeta.getQuotedSchemaTableCombination(
+              this, data.realSchemaName, data.realTableName);
 
       determineTechKeyCreation();
 
@@ -418,7 +423,7 @@ public class CombinationLookup extends 
BaseTransform<CombinationLookupMeta, Comb
    * retval: name of the key to return
    */
   public void setCombiLookup(IRowMeta inputRowMeta) throws 
HopDatabaseException {
-    DatabaseMeta databaseMeta = meta.getDatabaseMeta();
+    DatabaseMeta databaseMeta = 
getPipelineMeta().findDatabase(meta.getConnectionName(), variables);
     CFields fields = meta.getFields();
     List<KeyField> keyFields = fields.getKeyFields();
     ReturnFields returnFields = fields.getReturnFields();
@@ -495,7 +500,7 @@ public class CombinationLookup extends 
BaseTransform<CombinationLookupMeta, Comb
   public Long combiInsert(IRowMeta rowMeta, Object[] row, Long valKey, Long 
valCrc)
       throws HopDatabaseException {
     String debug = "Combination insert";
-    DatabaseMeta databaseMeta = meta.getDatabaseMeta();
+    DatabaseMeta databaseMeta = 
getPipelineMeta().findDatabase(meta.getConnectionName(), variables);
     CFields fields = meta.getFields();
     List<KeyField> keyFields = fields.getKeyFields();
     ReturnFields returnFields = fields.getReturnFields();
@@ -699,13 +704,15 @@ public class CombinationLookup extends 
BaseTransform<CombinationLookupMeta, Comb
       } else {
         data.cache = new HashMap<>();
       }
-      if (meta.getDatabaseMeta() == null) {
+      DatabaseMeta databaseMeta =
+          getPipelineMeta().findDatabase(meta.getConnectionName(), variables);
+      if (databaseMeta == null) {
         logError(
             BaseMessages.getString(
                 PKG, "CombinationLookup.Init.ConnectionMissing", 
getTransformName()));
         return false;
       }
-      data.db = new Database(this, this, meta.getDatabaseMeta());
+      data.db = new Database(this, this, databaseMeta);
       try {
         data.db.connect();
 
@@ -764,7 +771,8 @@ public class CombinationLookup extends 
BaseTransform<CombinationLookupMeta, Comb
         throw new HopConfigException(
             BaseMessages.getString(PKG, 
CONST_COMBINATION_LOOKUP_LOG_UNEXPECTED_ERROR));
       }
-      DatabaseMeta databaseMeta = meta.getDatabaseMeta();
+      DatabaseMeta databaseMeta =
+          getPipelineMeta().findDatabase(meta.getConnectionName(), variables);
       if (databaseMeta == null) {
         throw new HopConfigException(
             BaseMessages.getString(PKG, 
CONST_COMBINATION_LOOKUP_LOG_UNEXPECTED_ERROR));
diff --git 
a/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupDialog.java
 
b/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupDialog.java
index f4057cb7b2..2eba6899a4 100644
--- 
a/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupDialog.java
+++ 
b/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupDialog.java
@@ -142,10 +142,9 @@ public class CombinationLookupDialog extends 
BaseTransformDialog {
           }
         };
     backupChanged = input.hasChanged();
-    databaseMeta = input.getDatabaseMeta();
 
     // Connection line
-    wConnection = addConnectionLine(shell, wSpacer, input.getDatabaseMeta(), 
lsMod);
+    wConnection = addConnectionLine(shell, wSpacer, input.getConnectionName(), 
lsMod);
     wConnection.addSelectionListener(lsSelection);
     wConnection.addModifyListener(
         e -> {
@@ -657,7 +656,8 @@ public class CombinationLookupDialog extends 
BaseTransformDialog {
       // Determine the creation of the technical key for
       // backwards compatibility. Can probably be removed at
       // version 3.x or so (Sven Boden).
-      DatabaseMeta dbMeta = input.getDatabaseMeta();
+
+      DatabaseMeta dbMeta = 
pipelineMeta.findDatabase(input.getConnectionName(), variables);
       if (dbMeta == null || !dbMeta.supportsAutoinc()) {
         returnFields.setUseAutoIncrement(false);
       }
@@ -695,8 +695,8 @@ public class CombinationLookupDialog extends 
BaseTransformDialog {
     wTable.setText(Const.NVL(input.getTableName(), ""));
     wTk.setText(Const.NVL(returnFields.getTechnicalKeyField(), ""));
 
-    if (input.getDatabaseMeta() != null) {
-      wConnection.setText(input.getDatabaseMeta().getName());
+    if (input.getConnectionName() != null) {
+      wConnection.setText(input.getConnectionName());
     }
     wHashfield.setText(Const.NVL(input.getHashField(), ""));
 
@@ -765,7 +765,7 @@ public class CombinationLookupDialog extends 
BaseTransformDialog {
       fields.setSequenceFrom(null);
     }
 
-    in.setDatabaseMeta(findDatabase(wConnection.getText()));
+    in.setConnectionName(wConnection.getText());
     in.setCommitSize(Const.toInt(wCommit.getText(), 0));
     in.setCacheSize(Const.toInt(wCachesize.getText(), 0));
 
@@ -895,7 +895,7 @@ public class CombinationLookupDialog extends 
BaseTransformDialog {
                   shell,
                   SWT.NONE,
                   variables,
-                  info.getDatabaseMeta(),
+                  pipelineMeta.findDatabase(info.getConnectionName(), 
variables),
                   DbCache.getInstance(),
                   sql.getSql());
           sqledit.open();
diff --git 
a/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java
 
b/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java
index 04e1ff7271..2640b2083d 100644
--- 
a/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java
+++ 
b/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java
@@ -28,7 +28,6 @@ import org.apache.hop.core.annotations.ActionTransformType;
 import org.apache.hop.core.annotations.Transform;
 import org.apache.hop.core.database.Database;
 import org.apache.hop.core.database.DatabaseMeta;
-import org.apache.hop.core.exception.HopDatabaseException;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.exception.HopTransformException;
 import org.apache.hop.core.row.IRowMeta;
@@ -86,11 +85,10 @@ public class CombinationLookupMeta
   /** database connection */
   @HopMetadataProperty(
       key = "connection",
-      storeWithName = true,
       injectionKey = "CONNECTIONNAME",
       injectionKeyDescription = "CombinationLookup.Injection.CONNECTION_NAME",
       hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
-  private DatabaseMeta databaseMeta;
+  private String connectionName;
 
   /** replace fields with technical key? */
   @HopMetadataProperty(
@@ -158,7 +156,7 @@ public class CombinationLookupMeta
   public void setDefault() {
     schemaName = "";
     tableName = BaseMessages.getString(PKG, 
"CombinationLookupMeta.DimensionTableName.Label");
-    databaseMeta = null;
+    connectionName = null;
     commitSize = 100;
     cacheSize = DEFAULT_CACHE_SIZE;
     replaceFields = false;
@@ -209,6 +207,24 @@ public class CombinationLookupMeta
     CheckResult cr;
     String errorMessage = "";
 
+    DatabaseMeta databaseMeta = null;
+    try {
+      databaseMeta =
+          metadataProvider
+              .getSerializer(DatabaseMeta.class)
+              .load(variables.resolve(connectionName));
+    } catch (HopException e) {
+      cr =
+          new CheckResult(
+              ICheckResult.TYPE_RESULT_ERROR,
+              BaseMessages.getString(
+                  PKG,
+                  "TableInputMeta.CheckResult.DatabaseMetaError",
+                  variables.resolve(connectionName)),
+              transformMeta);
+      remarks.add(cr);
+    }
+
     if (databaseMeta != null) {
       Database db = new Database(loggingObject, variables, databaseMeta);
       try {
@@ -408,6 +424,10 @@ public class CombinationLookupMeta
       TransformMeta transformMeta,
       IRowMeta prev,
       IHopMetadataProvider metadataProvider) {
+
+    DatabaseMeta databaseMeta =
+        
getParentTransformMeta().getParentPipelineMeta().findDatabase(connectionName, 
variables);
+
     SqlStatement retval =
         new SqlStatement(transformMeta.getName(), databaseMeta, null); // 
default: nothing to do!
 
@@ -656,6 +676,10 @@ public class CombinationLookupMeta
       String[] output,
       IRowMeta info,
       IHopMetadataProvider metadataProvider) {
+
+    DatabaseMeta databaseMeta =
+        
getParentTransformMeta().getParentPipelineMeta().findDatabase(connectionName, 
variables);
+
     // The keys are read-only...
     for (int i = 0; i < fields.getKeyFields().size(); i++) {
       KeyField keyField = fields.getKeyFields().get(i);
@@ -699,16 +723,4 @@ public class CombinationLookupMeta
   public boolean supportsErrorHandling() {
     return true;
   }
-
-  protected IRowMeta getDatabaseTableFields(Database db, String schemaName, 
String tableName)
-      throws HopDatabaseException {
-    // First try without connecting to the database... (can be S L O W)
-    String schemaTable = databaseMeta.getQuotedSchemaTableCombination(db, 
schemaName, tableName);
-    IRowMeta extraFields = db.getTableFields(schemaTable);
-    if (extraFields == null) { // now we need to connect
-      db.connect();
-      extraFields = db.getTableFields(schemaTable);
-    }
-    return extraFields;
-  }
 }

Reply via email to