pentaho/pentaho-kettle · error · KettleException

Error while truncating table

Error message

Error while truncating table 

What it means

After obtaining a valid truncate statement, MonetDBBulkLoader.truncate executes it via executeSql(); if execution throws, the error is wrapped in a KettleException naming the table. This means the SQL TRUNCATE itself failed against the MonetDB server, distinct from the dialect not supporting truncate at all.

Solutions

  1. Check the wrapped cause for the server-side SQL error and the exact table name in the message
  2. Grant the connecting user TRUNCATE/ALTER privileges on the target table
  3. Verify the schema-qualified table name matches the target database (schemaTable resolution)
  4. If constraints block truncation, use DELETE instead or handle constraints; check for a server restart mid-run

Example fix

-- before: privilege denied for etl_user
-- after (as admin)
GRANT ALTER ON SCHEMA staging TO etl_user;
Defensive patterns

Strategy: retry

Validate before calling

// Check privileges and table existence before running
// As admin on MonetDB:
// GRANT ALTER ON SCHEMA staging TO etl_user;
// SELECT * FROM sys.tables WHERE name = 'target_table';

Type guard

null

Try / catch

try {
  step.run();
} catch (KettleException e) {
  if (e.getMessage().startsWith("Error while truncating table")) {
    logError("TRUNCATE failed on " + e.getMessage() + ": " + e.getCause().getMessage());
    // check privileges/table locks, then retry
  }
}

Prevention

When it happens

Trigger: truncate() runs the TRUNCATE statement and the server rejects it — insufficient privileges, table locked or referenced by constraints, wrong schema/table name, or connection lost mid-statement.

Common situations: User lacks TRUNCATE/ALTER privileges; table name/schema mismatch after moving environments; foreign-key-referenced table; transient connection drop during a long transformation.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/b1307c7b8c30f7f0. Report an issue: GitHub.

Appendix: source

Thrown at plugins/monet-db-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/monetdbbulkloader/MonetDBBulkLoader.java:394

    } catch ( Exception e ) {
      throw new KettleException( "Error serializing rows of data to the MonetDB API (MAPI).", e );
    }

  }

  public void truncate() throws KettleException {
    String cmd;
    String table = data.schemaTable;
    String truncateStatement = meta.getDatabaseMeta().getTruncateTableStatement( null, table );
    if ( truncateStatement == null ) {
      throw new KettleException( "Truncate table is not supported!" );
    }
    cmd = truncateStatement + ";";

    try {
      executeSql( cmd );
    } catch ( Exception e ) {
      throw new KettleException( "Error while truncating table " + table, e );
    }

    // try to update the metadata registry
    util.updateMetadata( meta, -1 );
    if ( log.isDetailed() ) {
      logDetailed( "Successfull: " + cmd );
    }

  }

  public void drop() throws KettleException {
    try {
      executeSql( "drop table " + data.schemaTable );
    } catch ( Exception e ) {
      throw new KettleException( "Error while dropping table " + data.schemaTable, e );
    }

  }

View on GitHub (pinned to f3058517a1)