{"record":{"id":"fcd1082b02b1e31f","repo":"pentaho/pentaho-kettle","slug":"the-tablename-is-not-defined-empty","errorCode":null,"errorMessage":"The tablename is not defined (empty)","messagePattern":"The tablename is not defined \\(empty\\)","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"critical","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/sqlfileoutput/SQLFileOutput.java","lineNumber":336,"sourceCode":"              } catch ( Exception ex ) { /* Ignore */\n              }\n            }\n          }\n        }\n\n        if ( !meta.isDoNotOpenNewFileInit() ) {\n          if ( !openNewFile() ) {\n            logError( \"Couldn't open file [\" + buildFilename() + \"]\" );\n            setErrors( 1L );\n            stopAll();\n          }\n        }\n\n        tableName = environmentSubstitute( meta.getTablename() );\n        schemaName = environmentSubstitute( meta.getSchemaName() );\n\n        if ( Utils.isEmpty( tableName ) ) {\n          throw new KettleStepException( \"The tablename is not defined (empty)\" );\n        }\n\n        schemaTable = data.db.getDatabaseMeta().getQuotedSchemaTableCombination( schemaName, tableName );\n\n      } catch ( Exception e ) {\n        logError( \"An error occurred intialising this step: \" + e.getMessage() );\n        stopAll();\n        setErrors( 1 );\n      }\n\n      return true;\n    }\n    return false;\n  }\n\n  public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {\n    meta = (SQLFileOutputMeta) smi;\n    data = (SQLFileOutputData) sdi;","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/sqlfileoutput/SQLFileOutput.java#L318-L354","documentation":"SQLFileOutput.init() substitutes variables for the configured table name and throws KettleStepException when the result is null or empty. The step writes SQL directly to a file targeting a specific table, so a table name is mandatory; without it no valid SQL could be generated. The throw happens during step initialization, before any rows are processed.","triggerScenarios":"The step's 'Target table' field is left blank in the step dialog, or the field contains only variable placeholders (e.g. ${TABLE_NAME}) that resolve to empty/null at runtime because the variable is not defined in the transformation, run configuration, or environment.","commonSituations":"Copy-pasting a step without filling in the target table; relying on a ${TABLE} variable that was set in one environment but not another (dev vs prod); running the transformation headless/pan without the variable defined on the command line; repository metadata where the tablename attribute was never saved.","solutions":["Open the SQL File Output step dialog and set the 'Target table' field to a non-empty value","If using a variable like ${TABLE_NAME}, define it in the transformation run configuration, kettle.properties, or pass -param:TABLE_NAME=value to pan","Verify with Get SQL / Preview that the table name resolves before running in production","Re-save the step metadata if the field appears filled but the value was never persisted to the repository"],"exampleFix":"// before (step XML, empty table)\n<tablename/>\n// after\n<tablename>DIM_CUSTOMER</tablename>","handlingStrategy":"validation","validationCode":"// In the step dialog / before running:\nString tableName = transMeta.environmentSubstitute( meta.getTablename() );\nif ( tableName == null || tableName.trim().isEmpty() ) {\n  throw new IllegalArgumentException( \"SQL File Output: target table is empty; set 'Target table' or define the variable\" );\n}","typeGuard":null,"tryCatchPattern":"// When running transformations programmatically:\ntry {\n  trans.execute( null );\n} catch ( KettleStepException e ) {\n  if ( e.getMessage().contains( \"tablename is not defined\" ) ) {\n    // correct step metadata or define variables, then retry\n  } else { throw e; }\n}","preventionTips":["Always set the Target table before saving the step","Prefer explicit table names over variables unless the variable is defined in kettle.properties","Use the step's Check/check() results in Spoon to catch empty tables before execution","Pass variables with -param: to pan in headless runs"],"tags":["kettle","pentaho","configuration","sql","step-init"],"backgroundTag":"empty-required-field","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"}