{"record":{"id":"8ac48c3d18f49d9d","repo":"pentaho/pentaho-kettle","slug":"spoon-ripdb-exception-errorgettingsqlfromtransformation","errorCode":"Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation","errorMessage":"Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation","messagePattern":"Spoon\\.RipDB\\.Exception\\.ErrorGettingSQLFromTransformation","errorType":"exception","errorClass":"InvocationTargetException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/spoon/delegates/SpoonJobDelegate.java","lineNumber":722,"sourceCode":"      ok = spoon.saveToFile( transMeta );\n    }\n    if ( !ok ) {\n      throw new InvocationTargetException( new Exception(\n        BaseMessages.getString( PKG, \"Spoon.RipDB.Exception.UnableToSaveTransformationToRepository\" ) ),\n        BaseMessages.getString( PKG, \"Spoon.RipDB.Exception.UnableToSaveTransformationToRepository\" ) );\n    }\n  }\n\n  private String getSQLString( DatabaseMeta sourceDbInfo, TableInputMeta tii, TransMeta transMeta )\n    throws InvocationTargetException {\n    // First set the limit to 1 to speed things up!\n    String tmpSql = tii.getSQL();\n    tii.setSQL( tii.getSQL() + sourceDbInfo.getLimitClause( 1 ) );\n    String sql;\n    try {\n      sql = transMeta.getSQLStatementsString();\n    } catch ( KettleStepException kse ) {\n      throw new InvocationTargetException( kse, BaseMessages.getString(\n        PKG, \"Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation\" )\n        + transMeta + \"] : \" + kse.getMessage() );\n    }\n    // remove the limit\n    tii.setSQL( tmpSql );\n    return sql;\n  }\n\n  private StepMeta getToStep( DatabaseMeta targetDbInfo, String table ) {\n    String tostepname = BaseMessages.getString( PKG, \"Spoon.RipDB.Monitor.ToStep.Name\" ) + table + \"]\";\n    TableOutputMeta toi = new TableOutputMeta();\n    toi.setDatabaseMeta( targetDbInfo );\n    toi.setTableName( table );\n    toi.setCommitSize( 100 );\n    toi.setTruncateTable( true );\n\n    String tostepid = PluginRegistry.getInstance().getPluginId( StepPluginType.class, toi );\n    StepMeta tostep = new StepMeta( tostepid, tostepname, toi );","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/spoon/delegates/SpoonJobDelegate.java#L704-L740","documentation":"While ripping a database, SpoonJobDelegate.getSQLString builds preview SQL by appending a LIMIT clause to a TableInput step and calls transMeta.getSQLStatementsString(). A KettleStepException from that call is wrapped in an InvocationTargetException with message Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation.","triggerScenarios":"getSQLString called on a transformation whose steps cannot generate SQL: a TableInput step without a valid DatabaseMeta, missing step metadata, or a step throwing KettleStepException during SQL generation.","commonSituations":"Source database connection not defined or unreachable; transformation copied from another environment with dangling connection references; corrupted TableInput SQL field.","solutions":["Open the transformation and verify every step's database connection is defined and testable.","Fix the TableInput step's SQL and connection reference before rerunning the rip.","Run transformation verification (checkSteps) to surface the offending step.","Recreate the offending step if its metadata is corrupted."],"exampleFix":"// before\nTableInputMeta tii = ...; // databaseMeta never assigned\ntii.setSQL( \"SELECT * FROM ...\" );\n// after\ntii.setDatabaseMeta( sourceDbInfo ); // assign a valid DatabaseMeta before getSQLStatementsString()\ntii.setSQL( \"SELECT * FROM ...\" );","handlingStrategy":"validation","validationCode":"for (StepMeta step : transMeta.getSteps()) {\n  if (step.getStepMetaInterface() instanceof TableInputMeta\n      && ((TableInputMeta) step.getStepMetaInterface()).getDatabase() == null) {\n    throw new IllegalStateException(\"TableInput step '\" + step.getName() + \"' has no database connection\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  String sql = getSQLString(sourceDbInfo, tii, transMeta);\n} catch (InvocationTargetException e) {\n  log.error(\"SQL generation failed: \" + e.getTargetException().getMessage(), e.getTargetException());\n}","preventionTips":["Fix all step validation errors before running the rip wizard.","Keep connection references intact when copying transformations between environments.","Run checkSteps() before SQL generation."],"tags":["pdi","sql-generation","kettle-step-exception","spoon"],"backgroundTag":"sql-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"}