{"record":{"id":"d424b1b6d703ce8f","repo":"pentaho/pentaho-kettle","slug":"truncate-table-not-supported-by","errorCode":null,"errorMessage":"Truncate table not supported by ","messagePattern":"Truncate table not supported by ","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":4984,"sourceCode":"    // First, check for reserved SQL in the input row r...\n    databaseMeta.quoteReservedWords( fields );\n    String quotedTk = databaseMeta.quoteField( null );\n\n    return getCreateTableStatement( tableName, fields, quotedTk, false, null, true );\n  }\n\n  /**\n   * Return SQL TRUNCATE statement for a Table\n   *\n   * @param schema    The schema\n   * @param tablename The table to create\n   * @throws KettleDatabaseException\n   */\n  public String getDDLTruncateTable( String schema, String tablename ) throws KettleDatabaseException {\n    if ( Utils.isEmpty( connectionGroup ) ) {\n      String truncateStatement = databaseMeta.getTruncateTableStatement( schema, tablename );\n      if ( truncateStatement == null ) {\n        throw new KettleDatabaseException( \"Truncate table not supported by \"\n          + databaseMeta.getDatabaseInterface().getPluginName() );\n      }\n      return truncateStatement;\n    } else {\n      return ( \"DELETE FROM \" + databaseMeta.getQuotedSchemaTableCombination( schema, tablename ) );\n    }\n  }\n\n  /**\n   * Return SQL statement (INSERT INTO TableName ...\n   *\n   * @param schemaName tableName The schema\n   * @param tableName\n   * @param fields\n   * @param dateFormat date format of field\n   * @throws KettleDatabaseException\n   */\n","sourceCodeStart":4966,"sourceCodeEnd":5002,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L4966-L5002","documentation":"Thrown by Database.getDDLTruncateTable() (Database.java:4984) when the connected database type's dialect does not define a TRUNCATE TABLE statement (getTruncateTableStatement returns null) and no transaction/connection group forces a DELETE fallback. Indicates the dialect plugin simply has no TRUNCATE support.","triggerScenarios":"Calling Database.getDDLTruncateTable(schema, tablename) when connectionGroup is empty and the active databaseMeta plugin's getTruncateTableStatement() returns null (dialects without TRUNCATE support).","commonSituations":"Using a community/custom database plugin that never implemented getTruncateTableStatement; running Table Output truncation against dialects lacking TRUNCATE; building dynamic SQL generation for multiple DB types where one target lacks TRUNCATE.","solutions":["Ensure a connection group is active so the method falls back to 'DELETE FROM table' instead of TRUNCATE","Override getTruncateTableStatement() in a custom DatabaseInterface to return a valid statement (e.g. 'TRUNCATE TABLE x' or 'DELETE FROM x')","Use DatabaseMeta.getQuotedSchemaTableCombination plus 'DELETE FROM' manually when you know TRUNCATE is unsupported","Switch to a standard supported database dialect or update the plugin","Check databaseMeta.getPluginName() in the message to identify which dialect needs the fix"],"exampleFix":"// before\nString ddl = database.getDDLTruncateTable( schema, table );\n// after\nString ddl = databaseMeta.supportsTruncateTable()\n  ? database.getDDLTruncateTable( schema, table )\n  : \"DELETE FROM \" + databaseMeta.getQuotedSchemaTableCombination( schema, table );","handlingStrategy":"fallback","validationCode":"String stmt = databaseMeta.getTruncateTableStatement( schema, tablename );\nif ( stmt == null ) {\n  stmt = \"DELETE FROM \" + databaseMeta.getQuotedSchemaTableCombination( schema, tablename );\n}","typeGuard":null,"tryCatchPattern":"try {\n  ddl = database.getDDLTruncateTable( schema, table );\n} catch ( KettleDatabaseException e ) {\n  ddl = \"DELETE FROM \" + databaseMeta.getQuotedSchemaTableCombination( schema, table );\n}","preventionTips":["Check DatabaseMeta.supportsTruncateTable()/getTruncateTableStatement before use","Prefer DELETE fallback inside a connection group for portability","Test generated DDL against every target dialect in CI","Implement getTruncateTableStatement in custom database plugins"],"tags":["database","sql","truncate","dialect"],"backgroundTag":"unsupported-operation","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"}