{"record":{"id":"198b7cea2c869e0b","repo":"pentaho/pentaho-kettle","slug":"error-converting-data-while-looking-up-value","errorCode":null,"errorMessage":"Error converting data while looking up value","messagePattern":"Error converting data while looking up value","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/streamlookup/StreamLookup.java","lineNumber":259,"sourceCode":"      if ( data.convertKeysToNative[i] ) {\n        lu[i] = data.lookupMeta.getValueMeta( i ).convertBinaryStringToNativeType( (byte[]) row[data.keynrs[i]] );\n      } else {\n        lu[i] = row[data.keynrs[i]];\n      }\n    }\n\n    // Handle conflicting types (Number-Integer-String conversion to lookup type in hashtable)\n    if ( data.keyTypes != null ) {\n      for ( int i = 0; i < data.lookupMeta.size(); i++ ) {\n        ValueMetaInterface inputValue = data.lookupMeta.getValueMeta( i );\n        ValueMetaInterface lookupValue = data.keyTypes.getValueMeta( i );\n        if ( inputValue.getType() != lookupValue.getType() ) {\n          try {\n            // Change the input value to match the lookup value\n            //\n            lu[i] = lookupValue.convertDataCompatible( inputValue, lu[i] );\n          } catch ( KettleValueException e ) {\n            throw new KettleStepException( \"Error converting data while looking up value\", e );\n          }\n        }\n      }\n    }\n\n    Object[] add = null;\n\n    if ( data.hasLookupRows ) {\n      try {\n        if ( meta.getKeystream().length > 0 ) {\n          add = getFromCache( data.cacheKeyMeta, lu );\n        } else {\n   // Just take the first element in the hashtable...\n          throw new KettleStepException( BaseMessages.getString( PKG, \"StreamLookup.Log.GotRowWithoutKeys\" ) );\n        }\n      } catch ( Exception e ) {\n        throw new KettleStepException( e );\n      }","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/streamlookup/StreamLookup.java#L241-L277","documentation":"When the main-stream lookup key's data type differs from the lookup-stream key type, the step attempts convertDataCompatible(); if that conversion fails (KettleValueException) it is wrapped as 'Error converting data while looking up value'. This means incompatible data, not just differing declared types (e.g. converting non-numeric String to Integer).","triggerScenarios":"lookupValues detects inputValue.getType() != lookupValue.getType(), calls lookupValue.convertDataCompatible(inputValue, lu[i]), which throws because the data cannot be converted (e.g. 'abc' to Integer, malformed Date string).","commonSituations":"Key field is String in one stream and Integer in the other with unparseable values; date keys with differing date formats; nulls or locale-specific number formats in the key column.","solutions":["Align the key field data types upstream (e.g. add 'Field exists in stream?' / Select Values metadata-type conversion) before the lookup","Use a 'String Operations' or 'Calculator' step to normalize/trim/standardize key values so conversion succeeds","Verify date formats and number formats match between the two streams","Pre-clean the data (remove empty/non-numeric keys) with a Filter or JavaScript step"],"exampleFix":"// before: keys String vs Integer mismatch\n// after: add Select Values step converting 'id' String->Integer before StreamLookup\n<meta type=\"Integer\" name=\"id\"/>","handlingStrategy":"try-catch","validationCode":"ValueMetaInterface in = mainRowMeta.getValueMeta(mainIdx);\nValueMetaInterface lk = lookupRowMeta.getValueMeta(lookupIdx);\nif (in.getType() != lk.getType() && !in.isCompatibleNumeric(lk)) {\n  throw new IllegalArgumentException(\"Key types differ: \" + in + \" vs \" + lk);\n}","typeGuard":"boolean sameType(ValueMetaInterface a, ValueMetaInterface b) {\n  return a != null && b != null && a.getType() == b.getType();\n}","tryCatchPattern":"try { lookupValues(...); } catch (KettleStepException e) {\n  if (e.getMessage().contains(\"Error converting data\")) {\n    log.error(\"Key value unconvertible; check raw key data\", e); setErrors(1L);\n  }\n  throw e;\n}","preventionTips":["Match key field data types exactly across both streams (Integer vs Integer, String vs String)","Standardize date/number formats on keys with explicit format masks","Trim and clean key strings before the lookup","Sample data with a preview to catch unconvertible values early"],"tags":["kettle","pdi","type-conversion","stream-lookup"],"backgroundTag":"type-mismatch","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"}