{"record":{"id":"700eed035d91191a","repo":"pentaho/pentaho-kettle","slug":"dimensionlookupmeta-exception-700eed","errorCode":null,"errorMessage":"DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2","messagePattern":"DimensionLookupMeta\\.Exception\\.UnableToRetrieveDataTypeOfReturnField2","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/dimensionlookup/DimensionLookupMeta.java","lineNumber":810,"sourceCode":"\n            // If the field needs to be renamed, rename\n            if ( fieldStream[i] != null && fieldStream[i].length() > 0 ) {\n              v.setName( fieldStream[i] );\n            }\n            v.setOrigin( name );\n            row.addValueMeta( v );\n          }\n        } else {\n          String message =\n              BaseMessages.getString( PKG, \"DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField\" );\n          logError( message );\n          throw new KettleStepException( message );\n        }\n      } catch ( Exception e ) {\n        String message =\n            BaseMessages.getString( PKG, \"DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2\" );\n        logError( message );\n        throw new KettleStepException( message, e );\n      } finally {\n        if ( db != null ) {\n          db.close();\n        }\n      }\n    }\n  }\n\n  @Override\n  public String getXML() {\n    actualizeWithInjectedValues();\n    StringBuilder retval = new StringBuilder( 512 );\n\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"schema\", schemaName ) );\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"table\", tableName ) );\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"connection\", databaseMeta == null ? \"\" : databaseMeta\n        .getName() ) );\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"commit\", commitSize ) );","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/dimensionlookup/DimensionLookupMeta.java#L792-L828","documentation":"This is the exception-path companion of the previous error: inside getFields()' try block, any Exception while reading the table's fields/data types from the database (connecting, reading table metadata, deriving types) results in the localized 'Unable to retrieve data type of return field (2)' message wrapped with the cause in a KettleStepException. It means the step could not complete metadata retrieval from the database to determine return-field types.","triggerScenarios":"getFields() opens a temporary database connection (db = new Database(...); db.connect()) and reads the table's row metadata; any exception (connection failure, bad table name, driver error) inside the try is caught and rethrown with this message; the connection is closed in finally.","commonSituations":"Database unreachable or credentials wrong at design time; table/schema name misspelled so metadata reads fail; driver class missing on the classpath; permissions prevent reading table metadata.","solutions":["Check the wrapped cause (getCause()) — it usually reveals a connection, authentication, or 'table not found' error","Verify the database connection defined in the transformation works (test the connection in Spoon)","Confirm the schema/table name configured in the step exists and the user can read its metadata","Ensure the correct JDBC driver is on the classpath for the connection type"],"exampleFix":"// before: connection points at dev DB where the dim table doesn't exist\n// after: fix the connection's host/database so table metadata can be read\nDatabaseMeta dbMeta = new DatabaseMeta(\"dimdb\", \"POSTGRESQL\", \"Native\", \"user\", \"pass\", \"prod-host:5432\", \"warehouse\", null);","handlingStrategy":"try-catch","validationCode":"// Java: verify the design-time DB connection can read table metadata before calling getFields\nDatabase db = new Database(transMeta, databaseMeta);\ntry { db.connect(); db.getTableFields(schemaTable); }\nfinally { db.disconnect(); }","typeGuard":null,"tryCatchPattern":"try {\n  meta.getFields(row, origin, null, null, sp, metaStore);\n} catch (KettleStepException e) {\n  if (e.getMessage().contains(\"UnableToRetrieveDataTypeOfReturnField2\") && e.getCause() != null) {\n    logError(\"Metadata read failed: \" + e.getCause().getMessage()); // connection/table/driver issue\n    // test/repair the connection, then retry\n  } else throw e;\n}","preventionTips":["Test the database connection in Spoon before opening/editing dimension steps","Confirm table and schema names exist and are readable by the user","Keep the JDBC driver jar on the classpath for the connection type","Read the cause chain — this error always wraps the real failure"],"tags":["database","metadata","connection","dimension-lookup"],"backgroundTag":"database-query-failed","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"}