pentaho/pentaho-kettle · error · KettleDatabaseException
Truncate table not supported by " +…
Error message
Truncate table not supported by " + databaseMeta.getDatabaseInterface().getPluginName()
What it means
Database.truncateTable(String) issues a TRUNCATE TABLE statement via databaseMeta.getTruncateTableStatement(null, tablename). When the active database plugin does not define a truncate statement, the method returns null and Kettle throws this KettleDatabaseException instead of silently falling back. It signals that the connected database dialect has no TRUNCATE implementation in the repository's database plugins.
Solutions
- Implement getTruncateTableStatement() in the database plugin's DatabaseMeta class (return "TRUNCATE TABLE " + quoted table name) so the plugin supports truncation
- Use the connection-group path instead: group connections so the code falls back to execStatement("DELETE FROM table"), or execute the DELETE explicitly
- Run the operation against a database plugin known to support truncation, or check support first with databaseMeta.getTruncateTableStatement(null, tablename) != null
- Upgrade Pentaho/Kettle — newer versions added truncate statements for more dialects
Example fix
// before
database.truncateTable( "staging_log" ); // throws for plugins without truncate support
// after
String stmt = database.getDatabaseMeta().getTruncateTableStatement( null, "staging_log" );
if ( stmt != null ) {
database.execStatement( stmt );
} else {
database.execStatement( "DELETE FROM " + database.getDatabaseMeta().quoteField( "staging_log" ) );
} Defensive patterns
Strategy: validation
Validate before calling
String stmt = databaseMeta.getTruncateTableStatement( null, tablename );
if ( stmt == null ) {
// dialect lacks truncate — fall back or fail fast before calling truncateTable
database.execStatement( "DELETE FROM " + databaseMeta.quoteField( tablename ) );
} else {
database.truncateTable( tablename );
} Type guard
boolean supportsTruncate( DatabaseMeta meta, String table ) {
return meta != null && meta.getTruncateTableStatement( null, table ) != null;
} Try / catch
try {
database.truncateTable( tablename );
} catch ( KettleDatabaseException e ) {
if ( e.getMessage() != null && e.getMessage().startsWith( "Truncate table not supported" ) ) {
database.execStatement( "DELETE FROM " + databaseMeta.quoteField( tablename ) );
} else {
throw e;
}
} Prevention
- Check getTruncateTableStatement(...) for null before truncating on non-mainstream dialects
- Keep database plugins/driver versions current — newer releases add truncate support for more dialects
- Use a DELETE fallback for dialects known to lack TRUNCATE
- Test table-maintenance steps against every target database type in your environments
When it happens
Trigger: Calling db.truncateTable( tablename ) (single-arg overload) while (a) no connectionGroup is set, and (b) databaseMeta.getTruncateTableStatement(null, tablename) returns null — i.e. the current database plugin does not implement getTruncateTableStatement. Note that inside a connection group (batch mode) this exception is never thrown; a DELETE FROM is used instead.
Common situations: Using a custom or less-common database plugin (SAP HANA, Ingres, generic JDBC, MonetDB, etc.) that lacks a truncate statement in its DatabaseMeta; truncating tables during transformation steps against non-standard dialects; running the same job that works on PostgreSQL/Oracle against an exotic target database.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- An error occurred executing SQL:
- An error occurred executing SQL:
- Couldn't execute SQL:
- Couldn't find any rows because of an error :
- Couldn't get a result because of an error :
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/5d3d56ba7b85038a.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:3575
}
}
}
if ( modify.size() > 0 ) {
for ( int i = 0; i < modify.size(); i++ ) {
ValueMetaInterface v = modify.getValueMeta( i );
retval.append( databaseMeta.getModifyColumnStatement( tableName, v, tk, useAutoinc, pk, true ) );
}
}
return retval.toString();
}
public void truncateTable( String tablename ) throws KettleDatabaseException {
if ( Utils.isEmpty( connectionGroup ) ) {
String truncateStatement = databaseMeta.getTruncateTableStatement( null, tablename );
if ( truncateStatement == null ) {
throw new KettleDatabaseException( "Truncate table not supported by "
+ databaseMeta.getDatabaseInterface().getPluginName() );
}
execStatement( truncateStatement );
} else {
execStatement( "DELETE FROM " + databaseMeta.quoteField( tablename ) );
}
}
public void truncateTable( String schema, String tablename ) throws KettleDatabaseException {
if ( Utils.isEmpty( connectionGroup ) && !databaseMeta.getPluginId().equalsIgnoreCase(
"MySQL" ) ) { // this is a hack to fix a know issue on MySQL issue name on Pentaho side BISERVER-14546
String truncateStatement = databaseMeta.getTruncateTableStatement( schema, tablename );
if ( truncateStatement == null ) {
throw new KettleDatabaseException( "Truncate table not supported by "
+ databaseMeta.getDatabaseInterface().getPluginName() );
}
execStatement( truncateStatement );
} else {View on GitHub (pinned to f3058517a1)