pentaho/pentaho-kettle · error · InvocationTargetException
Problem encountered determining query fields:
Error message
Problem encountered determining query fields:
What it means
In GetQueryFieldsProgressDialog.run, any exception thrown while connecting or while db.getQueryFields(sql, false) determines the result-row fields is rethrown as an InvocationTargetException with the message 'Problem encountered determining query fields: ' plus the underlying exception's toString().
Solutions
- Read the cause (e.getMessage() of the InvocationTargetException) for the real SQL/database error and fix the statement.
- Validate the SQL by executing it directly in the database's client before using 'Get fields'.
- Test/refresh the database connection; reconnect if the session was dropped.
- Check that the user has permissions to run the statement and read the referenced tables.
Example fix
// before
result = db.getQueryFields( sql, false );
// after
if ( dbMeta.testConnection( loggingObject ).length == 0 ) {
result = db.getQueryFields( sql, false );
} else {
throw new KettleException( "Database connection invalid; cannot determine query fields" );
} Defensive patterns
Strategy: try-catch
Validate before calling
// basic SQL sanity before asking for fields if ( sql == null || sql.trim().isEmpty() ) throw new IllegalArgumentException( "SQL statement is empty" );
Try / catch
try {
fields = new GetQueryFieldsProgressDialog( shell, loggingObject, dbMeta, sql ).open();
} catch ( InvocationTargetException e ) {
logError( "Problem determining query fields: " + e.getCause(), e.getCause() );
} Prevention
- Validate SQL syntax in the database's own client before 'Get fields'.
- Ensure the connection is alive (testConnection) first.
- Check user permissions on all referenced tables.
When it happens
Trigger: Invoking the dialog with SQL that the database rejects — syntax errors, unknown tables/columns, connect failure, insufficient privileges — so getQueryFields throws inside the runnable.
Common situations: Typing an invalid SQL statement in Spoon's SQL editor and clicking 'Get fields'; running SQL against a database whose connection has timed out; SQL using vendor-specific syntax the driver cannot prepare.
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
- 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 :
- Couldn't get field info from [" + sql + "]" + Const.CR
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/6210437cb30205e8.
Report an issue: GitHub.
Appendix: source
Thrown at ui/src/main/java/org/pentaho/di/ui/core/database/dialog/GetQueryFieldsProgressDialog.java:68
*/
public GetQueryFieldsProgressDialog( Shell shell, DatabaseMeta dbInfo, String sql ) {
this.shell = shell;
this.dbMeta = dbInfo;
this.sql = sql;
}
public RowMetaInterface open() {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
db = new Database( Spoon.loggingObject, dbMeta );
try {
db.connect();
result = db.getQueryFields( sql, false );
if ( monitor.isCanceled() ) {
throw new InvocationTargetException( new Exception( "This operation was cancelled!" ) );
}
} catch ( Exception e ) {
throw new InvocationTargetException( e, "Problem encountered determining query fields: " + e.toString() );
} finally {
db.close();
}
}
};
try {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog( shell );
// Run something in the background to cancel active database queries, forecably if needed!
Runnable run = new Runnable() {
public void run() {
IProgressMonitor monitor = pmd.getProgressMonitor();
while ( pmd.getShell() == null || ( !pmd.getShell().isDisposed() && !monitor.isCanceled() ) ) {
try {
Thread.sleep( 250 );
} catch ( InterruptedException e ) {
// IgnoreView on GitHub (pinned to f3058517a1)