pentaho/pentaho-kettle · error · KettleStepException

DynamicSQLRowMeta.Exception.ErrorObtainingFields

Error message

DynamicSQLRowMeta.Exception.ErrorObtainingFields

What it means

DynamicSQLRowMeta.getFields wraps a KettleDatabaseException raised while finalizing the step's output fields (attaching the query-derived fields to the row meta and closing the connection) into a KettleStepException with this message key. Unlike 1388, this fires after getQueryFields succeeded, during the add/close phase.

Solutions

  1. Check the wrapped cause for the close/connection error; inspect DB logs for dropped sessions
  2. Verify network stability and connection/timeout settings on the database connection
  3. Update the JDBC driver to a version compatible with the DB server
  4. Retry the metadata calculation; if transient, the error should not recur

Example fix

// before
// connection closed abruptly by firewall after 30s idle
// after
set 'Connection timeout' / TCP keepalive on the DB connection (e.g. connectTimeout=30000, socketTimeout=0) and ensure firewall idle timeout > query duration
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the connection is usable before field calculation:
Database db = new Database(loggingObject, meta.getDatabaseMeta());
db.connect();
if (!db.checkConnection()) throw new IllegalStateException("DB connection check failed");
db.disconnect();

Try / catch

try {
  meta.getFields(row, origin, info, target, space, repository, metaStore);
} catch (KettleStepException e) {
  logError("Error obtaining fields — check DB connection stability: " + e.getCause(), e);
  throw e;
}

Prevention

When it happens

Trigger: In getFields, after add = db.getQueryFields(...) returned, when subsequent operations inside the try block (e.g. db.close() or value metadata handling) throw KettleDatabaseException — typically connection close/rollback failures.

Common situations: Connection already dropped between query-field retrieval and close (network timeout, DB killed session); driver quirks on close; pool exhaustion.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/dynamicsqlrow/DynamicSQLRowMeta.java:258

    if ( add != null ) { // Cache hit, just return it this...
      for ( int i = 0; i < add.size(); i++ ) {
        ValueMetaInterface v = add.getValueMeta( i );
        v.setOrigin( name );
      }
      row.addRowMeta( add );
    } else {
      // No cache hit, connect to the database, do it the hard way...
      try {
        db.connect();
        add = db.getQueryFields( realSQL, false );
        for ( int i = 0; i < add.size(); i++ ) {
          ValueMetaInterface v = add.getValueMeta( i );
          v.setOrigin( name );
        }
        row.addRowMeta( add );
        db.close();
      } catch ( KettleDatabaseException dbe ) {
        throw new KettleStepException( BaseMessages.getString(
          PKG, "DynamicSQLRowMeta.Exception.ErrorObtainingFields" ), dbe );
      }
    }
  }

  public String getXML() {
    StringBuilder retval = new StringBuilder();

    retval
      .append( "    " + XMLHandler.addTagValue( "connection", databaseMeta == null ? "" : databaseMeta.getName() ) );
    retval.append( "    " + XMLHandler.addTagValue( "rowlimit", rowLimit ) );
    retval.append( "    " + XMLHandler.addTagValue( "sql", sql ) );
    retval.append( "    " + XMLHandler.addTagValue( "outer_join", outerJoin ) );
    retval.append( "    " + XMLHandler.addTagValue( "replace_vars", replacevars ) );
    retval.append( "    " + XMLHandler.addTagValue( "sql_fieldname", sqlfieldname ) );
    retval.append( "    " + XMLHandler.addTagValue( "query_only_on_change", queryonlyonchange ) );

    return retval.toString();

View on GitHub (pinned to f3058517a1)