{"record":{"id":"e1b7dcc379ad768e","repo":"pentaho/pentaho-kettle","slug":"unable-to-determine-if-indexes-exists-on-table-tablename","errorCode":null,"errorMessage":"Unable to determine if indexes exists on table [<tablename>]","messagePattern":"Unable to determine if indexes exists on table \\[<tablename>\\]","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/BaseDatabaseMeta.java","lineNumber":1657,"sourceCode":"          }\n        }\n      } finally {\n        if ( indexList != null ) {\n          indexList.close();\n        }\n      }\n\n      // See if all the fields are indexed...\n      boolean all = true;\n      for ( int i = 0; i < exists.length && all; i++ ) {\n        if ( !exists[i] ) {\n          all = false;\n        }\n      }\n\n      return all;\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( \"Unable to determine if indexes exists on table [\" + tablename + \"]\", e );\n    }\n\n  }\n\n  /**\n   * @return true if the database supports the NOMAXVALUE sequence option. The default is false, AS/400 and DB2 support\n   *         this.\n   */\n  @Override\n  public boolean supportsSequenceNoMaxValueOption() {\n    return false;\n  }\n\n  /**\n   * @return true if we need to append the PRIMARY KEY block in the create table block after the fields, required for\n   *         Cache.\n   */\n  @Override","sourceCodeStart":1639,"sourceCodeEnd":1675,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/BaseDatabaseMeta.java#L1639-L1675","documentation":"BaseDatabaseMeta's index-existence check (used by e.g. checkIndexesSupported/index handling) queries database metadata to determine whether indexes exist on a table, aggregating a boolean 'all'. Any Exception during that metadata lookup is wrapped in a KettleDatabaseException stating the check could not be performed for the named table.","triggerScenarios":"Calling the index-existence check (via BaseDatabaseMeta) for a table when the underlying DatabaseMeta lookup throws — table name wrong/quoted incorrectly, insufficient permissions on metadata catalogs, or driver failure in DatabaseMetaData calls.","commonSituations":"Running 'verify/cleanup indexes' transformations against tables the user cannot see in the system catalog; schema-qualified or case-sensitive table names on Oracle/DB2; drivers that don't implement the needed metadata methods.","solutions":["Verify the table exists and the connection user has metadata read privileges (e.g. SELECT on system catalogs).","Check the table name's case and schema qualification against the target database's rules.","Test the same lookup directly via java.sql.DatabaseMetaData.getIndexInfo() to isolate the driver behavior.","Catch KettleDatabaseException and skip index verification for tables where metadata access is unavailable."],"exampleFix":"// before\nboolean ok = dbMeta.hasIndexOnColumns(... \"MyTable\" ...); // wrong case on Oracle\n\n// after\nboolean ok = dbMeta.hasIndexOnColumns(... \"MYSCHEMA.MYTABLE\" ...);","handlingStrategy":"try-catch","validationCode":"boolean readable;\ntry (java.sql.ResultSet rs = connection.getMetaData().getTables(null, schema, table, new String[]{\"TABLE\"})) {\n  readable = rs.next();\n}\nif (!readable) { /* skip index check: table or metadata not accessible */ }","typeGuard":null,"tryCatchPattern":"try {\n  db.checkIndexes(table, ...);\n} catch (KettleDatabaseException e) {\n  LOG.warn(\"Cannot verify indexes on [\" + table + \"] — check grants/driver\", e);\n}","preventionTips":["Grant the connection user metadata catalog read privileges.","Match table name case and schema qualification to the target database's rules.","Verify DatabaseMetaData.getIndexInfo() works with the driver in a smoke test."],"tags":["database","metadata","index-check"],"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"}