{"record":{"id":"053ed3673902bb6a","repo":"pentaho/pentaho-kettle","slug":"sqlfileoutputmeta-exception-tablenotfound","errorCode":"SQLFileOutputMeta.Exception.TableNotFound","errorMessage":"SQLFileOutputMeta.Exception.TableNotFound","messagePattern":"SQLFileOutputMeta\\.Exception\\.TableNotFound","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/sqlfileoutput/SQLFileOutputMeta.java","lineNumber":805,"sourceCode":"\n    return retval;\n  }\n\n  public RowMetaInterface getRequiredFields( VariableSpace space ) throws KettleException {\n    String realTableName = space.environmentSubstitute( tablename );\n    String realSchemaName = space.environmentSubstitute( schemaName );\n\n    if ( databaseMeta != null ) {\n      Database db = new Database( loggingObject, databaseMeta );\n      try {\n        db.connect();\n\n        if ( !Utils.isEmpty( realTableName ) ) {\n          // Check if this table exists...\n          if ( db.checkTableExists( realSchemaName, realTableName ) ) {\n            return db.getTableFieldsMeta( realSchemaName, realTableName );\n          } else {\n            throw new KettleException( BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.TableNotFound\" ) );\n          }\n        } else {\n          throw new KettleException( BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.TableNotSpecified\" ) );\n        }\n      } catch ( Exception e ) {\n        throw new KettleException(\n          BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.ErrorGettingFields\" ), e );\n      } finally {\n        db.close();\n      }\n    } else {\n      throw new KettleException( BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.ConnectionNotDefined\" ) );\n    }\n  }\n\n  public DatabaseMeta[] getUsedDatabaseConnections() {\n    if ( databaseMeta != null ) {\n      return new DatabaseMeta[] { databaseMeta };","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/sqlfileoutput/SQLFileOutputMeta.java#L787-L823","documentation":"In SQLFileOutputMeta's table-fields lookup, after connecting to the configured database the code checks db.checkTableExists(schema, table); if the table does not exist it throws KettleException with the localized message 'SQLFileOutputMeta.Exception.TableNotFound'. This happens while resolving field metadata for the target table (used to generate SQL / preview fields).","triggerScenarios":"Clicking 'Get Fields' / generating SQL in the step dialog (getTableFieldsMeta path) when the real (variable-substituted) schema+table does not exist in the configured database connection: typo in table name, wrong schema, table not yet created, or pointed at the wrong database/environment.","commonSituations":"Case-sensitivity mismatches on Oracle/Postgres (lowercase vs uppercase identifiers); table exists in DEV but not in the PROD connection; schema-qualified name given without setting the schema field; DB user lacking visibility of the other schema's tables.","solutions":["Verify the table exists: run SELECT count(*) FROM <schema>.<table> against the exact configured connection","Fix the table name/schema spelling and case in the step dialog (use the browser to pick the real name)","Set the 'Schema' field explicitly instead of embedding schema in the table name","Create the target table first, or point the step at the correct database connection/environment"],"exampleFix":"// before (table given with schema embedded, wrong case)\ntableName = \"dim.customer\";\n// after\nschemaName = \"dim\";\ntableName = \"CUSTOMER\"; // matches Oracle's stored uppercase name","handlingStrategy":"validation","validationCode":"Database db = new Database( parent, meta.getDatabaseMeta() );\ndb.connect();\nString realTable = transMeta.environmentSubstitute( meta.getTablename() );\nString realSchema = transMeta.environmentSubstitute( meta.getSchemaName() );\nif ( !db.checkTableExists( realSchema, realTable ) ) {\n  throw new IllegalStateException( \"Table \" + realSchema + \".\" + realTable + \" does not exist on this connection\" );\n}\ndb.disconnect();","typeGuard":null,"tryCatchPattern":"try {\n  RowMetaInterface fields = meta.getTableFields();\n} catch ( KettleException e ) {\n  if ( e.getMessage().contains( \"TableNotFound\" ) ) {\n    // create the table or fix schema/table name before proceeding\n  }\n}","preventionTips":["Match identifier case to the database's stored convention (upper for Oracle, lower for Postgres)","Set the Schema field separately rather than embedding it in the table name","Create/verify target tables in each environment before deploying","Use the same connection object for validation and execution"],"tags":["kettle","pentaho","sql","metadata","table-not-found"],"backgroundTag":"resource-not-found","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"}