pentaho/pentaho-kettle · error · KettleDatabaseException

Unable to obtain last logdate from table " + logtable

Error message

Unable to obtain last logdate from table " + logtable

What it means

Database.getFirstLogDate() executes a query for the maximum log_date of a logging table and wraps any SQLException in a KettleDatabaseException naming the log table. It means the log-date lookup query could not be executed against the given table.

Solutions

  1. Verify the log table exists and has the expected log_date column in the connected schema
  2. Check the logging configuration (table name + schema) in your transformation/job log settings
  3. Run the SQL shown in your DB console to reproduce the driver error
  4. If the table is intentionally empty/missing, create the logging tables (SQL button in the log table settings)

Example fix

// before
db.getLastLogDate(""KETTLE"."TRANS_LOG"", "transname", "t", "transformation", null);
// after
// confirm table exists, or create it first via logging settings, then:
db.getLastLogDate(""KETTLE"."TRANSMETALOG"", "transname", "t", "transformation", null);
Defensive patterns

Strategy: validation

Validate before calling

if (!db.checkTableExistsUnquoted(null, logtable)) {
  throw new IllegalStateException("Log table missing: " + logtable + " — create logging tables first");
}

Type guard

null

Try / catch

try {
  RowMetaAndData last = db.getLastLogDate(logtable, name, id, type, status);
} catch (KettleDatabaseException e) {
  log.warn("No last log date for " + logtable + ": " + e.getMessage());
  // proceed with default (no previous run)
}

Prevention

When it happens

Trigger: Calling getFirstLogDate(schemaTable, ...) / getLastLogDate where the log table name is wrong, the table has no log_date column, or the connection fails during pstmt.executeQuery().

Common situations: Misconfigured logging table names in transformation/job settings, renamed or dropped logging tables, schema prefix mismatch, or connecting to a fresh database with no logging tables created yet.

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/b6775a4218ac067f. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:3933

    sql += " AND    " + databaseMeta.quoteField( "STATUS" ) + "    = 'end'";
    sql += " AND    " + jobtrans + " = ?";
    sql +=
      " ORDER BY "
        + databaseMeta.quoteField( "LOGDATE" ) + " DESC, " + databaseMeta.quoteField( "ENDDATE" ) + " DESC";

    try {
      pstmt = connection.prepareStatement( databaseMeta.stripCR( sql ) );

      RowMetaInterface r = new RowMeta();
      r.addValueMeta( new ValueMetaString( "TRANSNAME", 255, -1 ) );
      setValues( r, new Object[] { name } );

      try ( ResultSet res = pstmt.executeQuery() ) {
        rowMeta = getRowInfo( res.getMetaData(), false, false );
        row = getRow( res );
      }
    } catch ( SQLException ex ) {
      throw new KettleDatabaseException( "Unable to obtain last logdate from table " + logtable, ex );
    }

    return row;
  }

  public synchronized Long getNextValue( Hashtable<String, Counter> counters, String tableName, String valKey )
    throws KettleDatabaseException {
    return getNextValue( counters, null, tableName, valKey );
  }

  public synchronized Long getNextValue( Hashtable<String, Counter> counters, String schemaName, String tableName,
                                         String valKey ) throws KettleDatabaseException {
    Long nextValue = null;

    String schemaTable = databaseMeta.getQuotedSchemaTableCombination( schemaName, tableName );

    String lookup = schemaTable + "." + databaseMeta.quoteField( valKey );

View on GitHub (pinned to f3058517a1)