{"record":{"id":"08caf797bb21daae","repo":"pentaho/pentaho-kettle","slug":"metadata-check-failed-fallback-to-statement-check","errorCode":null,"errorMessage":"Metadata check failed. Fallback to statement check.","messagePattern":"Metadata check failed\\. Fallback to statement check\\.","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":2331,"sourceCode":"\n  public boolean checkColumnExistsByDbMeta( String schemaname, String tablename, String columnname )\n    throws KettleDatabaseException {\n    if ( log.isDebug() ) {\n      log.logDebug( \"Checking if column [\" + columnname + \"] exists in table [\" + tablename + \"] !\" );\n    }\n\n    // First try the metadata\n    try {\n      ResultSet columns = getColumnsMetaData( schemaname, tablename );\n      while ( columns.next() ) {\n        if ( columnname.equals( columns.getString( \"COLUMN_NAME\" ) ) ) {\n          return true;\n        }\n      }\n      return false;\n    } catch ( KettleDatabaseException | SQLException e ) {\n      // That's ok. We will use a prepared statement.\n      throw new KettleDatabaseException( \"Metadata check failed. Fallback to statement check.\" );\n    }\n\n  }\n\n  /**\n   * See if the column specified exists by reading\n   *\n   * @param columnname The name of the column to check.\n   * @param tablename  The name of the table to check.<br> This is supposed to be the properly quoted name of the table\n   *                   or the complete schema-table name combination.\n   * @return true if the table exists, false if it doesn't.\n   * @deprecated Deprecated in favor of the smarter {@link #checkColumnExists(String, String, String)}\n   */\n  @Deprecated\n  public boolean checkColumnExists( String columnname, String tablename ) throws KettleDatabaseException {\n    try {\n      if ( log.isDebug() ) {\n        log.logDebug( \"Checking if column [\" + columnname + \"] exists in table [\" + tablename + \"] !\" );","sourceCodeStart":2313,"sourceCodeEnd":2349,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L2313-L2349","documentation":"When checking whether a column exists via JDBC metadata fails (KettleDatabaseException or SQLException), Kettle throws this marker exception whose text signals the caller will fall back to a prepared-statement based check. It is a control-flow-style exception rather than a fatal condition.","triggerScenarios":"columnExists() path where getColumnsMetaData/getTableMetaData raised KettleDatabaseException or the metadata query raised SQLException.","commonSituations":"Metadata-restricted drivers, privileges lacking catalog access, schema-pattern mismatches — all forcing the statement-based fallback path.","solutions":["Treat as non-fatal; the fallback statement check usually completes the operation","Grant catalog metadata privileges to avoid the slower fallback","Correct the schema/column casing so metadata queries succeed","Wrap in try-catch and implement your own fallback (e.g. SELECT ... WHERE 1=0)"],"exampleFix":"// before\nboolean exists = db.columnExists(schema, table, column); // may throw fallback marker\n// after\nboolean exists;\ntry {\n  exists = db.columnExists(schema, table, column);\n} catch (KettleDatabaseException e) {\n  exists = db.checkColumnExistsViaSelect(schema, table, column); // custom fallback\n}","handlingStrategy":"try-catch","validationCode":"// pre-check with a cheap SELECT probe\nboolean probe = db.getOneRow(\"SELECT \" + column + \" FROM \" + table + \" WHERE 1=0\") != null || true;","typeGuard":null,"tryCatchPattern":"try {\n  exists = db.columnExists(schema, table, column);\n} catch (KettleDatabaseException e) {\n  // message says fallback to statement check\n  exists = columnExistsViaSelect(db, schema, table, column);\n}","preventionTips":["Expect this exception as a signal, not a failure","Grant dictionary/catalog read privileges to skip the fallback","Use exact identifier casing to keep metadata checks succeeding"],"tags":["fallback","jdbc-metadata","column-exists"],"backgroundTag":"database-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}