{"record":{"id":"1085ea8af341a36f","repo":"pentaho/pentaho-kettle","slug":"the-same-column-can-t-be-inserted-into-the-target-row-twice","errorCode":null,"errorMessage":"The same column can't be inserted into the target row twice: ","messagePattern":"The same column can't be inserted into the target row twice: ","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/insertupdate/InsertUpdate.java","lineNumber":273,"sourceCode":"\n      setLookup( getInputRowMeta() );\n\n      data.insertRowMeta = new RowMeta();\n\n      // Insert the update fields: just names. Type doesn't matter!\n      for ( int i = 0; i < meta.getUpdateFields().length; i++ ) {\n        ValueMetaInterface insValue =\n          data.insertRowMeta.searchValueMeta( meta.getUpdateFields()[ i ].getUpdateLookup() );\n        if ( insValue == null ) {\n          // Don't add twice!\n\n          // we already checked that this value exists so it's probably safe to ignore lookup failure...\n          ValueMetaInterface insertValue =\n            getInputRowMeta().searchValueMeta( meta.getUpdateFields()[ i ].getUpdateStream() ).clone();\n          insertValue.setName( meta.getUpdateFields()[ i ].getUpdateLookup() );\n          data.insertRowMeta.addValueMeta( insertValue );\n        } else {\n          throw new KettleStepException( \"The same column can't be inserted into the target row twice: \"\n            + insValue.getName() ); // TODO i18n\n        }\n      }\n      data.db.prepareInsert(\n        data.insertRowMeta, environmentSubstitute( meta.getSchemaName() ), environmentSubstitute( meta\n          .getTableName() ) );\n\n      if ( !meta.isUpdateBypassed() ) {\n        List<String> updateColumns = new ArrayList<String>();\n        for ( int i = 0; i < meta.getUpdateFields().length; i++ ) {\n          if ( meta.getUpdateFields()[ i ].getUpdate().booleanValue() ) {\n            updateColumns.add( meta.getUpdateFields()[ i ].getUpdateLookup() );\n          }\n        }\n        prepareUpdate( getInputRowMeta() );\n      }\n    }\n","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/insertupdate/InsertUpdate.java#L255-L291","documentation":"The step builds the INSERT row by renaming each Update Stream value to its Update Lookup (target table column) name. If two update field entries map to the same target column, prepareInsert would fail, so the step pre-empts it by rejecting duplicate insert columns. Message is hardcoded English (not i18n).","triggerScenarios":"Two entries in the 'Update fields' grid have the same Update Lookup (table column) value, e.g. the same table column listed twice or mapped from two streams.","commonSituations":"Copy-pasted row in the update fields grid with the table field left unchanged; duplicate column mapping introduced by hand-edited step XML; mapping generated twice appending duplicates.","solutions":["Open the 'Update fields' grid and remove or re-map the duplicate entry so each Update Lookup (table column) is unique.","Use the Enter field mapping wizard to rebuild a correct one-to-one mapping.","If editing step XML or repository attributes directly, deduplicate the value_name entries.","Save and re-run; the check compares insert value names during row metadata construction."],"exampleFix":"// before (two entries both map to column \"qty\")\nfields[0].setUpdateLookup(\"qty\"); fields[1].setUpdateLookup(\"qty\");\n// after\nfields[0].setUpdateLookup(\"qty_in\"); fields[1].setUpdateLookup(\"qty_out\");","handlingStrategy":"validation","validationCode":"java.util.Set<String> seen = new java.util.HashSet<>();\nfor (InsertUpdateField uf : meta.getUpdateFields()) {\n  if (!seen.add(uf.getUpdateLookup()))\n    throw new IllegalStateException(\"Duplicate target column in update fields: \" + uf.getUpdateLookup());\n}","typeGuard":"boolean noDuplicateLookups(java.util.List<InsertUpdateField> fields) {\n  long distinct = fields.stream().map(InsertUpdateField::getUpdateLookup).distinct().count();\n  return distinct == fields.size();\n}","tryCatchPattern":"try { trans.execute(...); } catch (KettleStepException e) {\n  if (e.getMessage().startsWith(\"The same column can't be inserted\")) { /* dedupe update-fields grid */ }\n  throw e;\n}","preventionTips":["Use the Enter field mapping wizard, which produces one-to-one mappings.","After copy-pasting rows in the update fields grid, always change the table field value.","Validate hand-edited step XML for duplicate value_name attributes."],"tags":["kettle","pdi","duplicate-column","insert"],"backgroundTag":"invalid-argument-value","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}