{"record":{"id":"9f7c90548f72badb","repo":"apache/iceberg","slug":"failed-to-get-table-metadata-for-s","errorCode":null,"errorMessage":"Failed to get table metadata for '%s'","messagePattern":"Failed to get table metadata for '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java","lineNumber":348,"sourceCode":"  @Override\n  public SnowflakeTableMetadata loadTableMetadata(SnowflakeIdentifier tableIdentifier) {\n    Preconditions.checkArgument(\n        tableIdentifier.type() == SnowflakeIdentifier.Type.TABLE,\n        \"loadTableMetadata requires a TABLE identifier, got '%s'\",\n        tableIdentifier);\n    SnowflakeTableMetadata tableMeta;\n    try {\n      final String finalQuery = \"SELECT SYSTEM$GET_ICEBERG_TABLE_INFORMATION(?) AS METADATA\";\n      tableMeta =\n          connectionPool.run(\n              conn ->\n                  queryHarness.query(\n                      conn,\n                      finalQuery,\n                      TABLE_METADATA_RESULT_SET_HANDLER,\n                      tableIdentifier.toIdentifierString()));\n    } catch (SQLException e) {\n      throw snowflakeExceptionToIcebergException(\n          tableIdentifier,\n          e,\n          String.format(\"Failed to get table metadata for '%s'\", tableIdentifier));\n    } catch (InterruptedException e) {\n      throw new UncheckedInterruptedException(\n          e, \"Interrupted while getting table metadata for '%s'\", tableIdentifier);\n    }\n    return tableMeta;\n  }\n\n  @Override\n  public void close() {\n    connectionPool.close();\n  }\n\n  private RuntimeException snowflakeExceptionToIcebergException(\n      SnowflakeIdentifier identifier, SQLException ex, String defaultExceptionMessage) {\n    // NoSuchNamespace exception for Database and Schema cases","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java#L330-L366","documentation":"JdbcSnowflakeClient.loadTableMetadata executes SELECT SYSTEM$GET_ICEBERG_TABLE_INFORMATION(?) and wraps SQLException into 'Failed to get table metadata for %s'. It means the metadata lookup for the Iceberg table failed - the table doesn't exist, the caller lacks privileges, or the query/connection failed. Non-table identifiers are rejected earlier with an IllegalArgumentException, so this message always reflects a query/privilege/existence problem.","triggerScenarios":"Calling loadTableMetadata(tableIdentifier) (used by SnowflakeCatalog.loadTable/refresh to obtain metadata location and registered-time) when the fully qualified table doesn't exist or is not an Iceberg table, the role lacks SELECT/OWNERSHIP privileges, or the JDBC query raises SQLException.","commonSituations":"Table dropped or renamed before metadata fetch; passing a dynamic/virtual view or non-Iceberg table; wrong case or qualifier in the identifier; expired credentials; transient Snowflake service errors.","solutions":["Verify the table exists and is a Snowflake-managed Iceberg table (SHOW ICEBERG TABLES / DESCRIBE TABLE)","Check the role has sufficient privileges (SELECT or OWNERSHIP) on the table and its database/schema","Catch the IcebergException and inspect the underlying SQLException error code; handle missing tables by re-listing or throwing NoSuchTableException upstream","Retry transient failures and validate JDBC auth/connectivity configuration"],"exampleFix":"// before\ncatalog.loadTable(TableIdentifier.of(\"DB\", \"SCHEMA\", \"TBL\")); // SQLException -> 'Failed to get table metadata'\n// after\ntry {\n  catalog.loadTable(TableIdentifier.of(\"DB\", \"SCHEMA\", \"TBL\"));\n} catch (IcebergException e) {\n  // inspect e.getCause() SQLException: existence, privileges, or connectivity\n  // optionally fall back to listIcebergTables to confirm the table exists\n}","handlingStrategy":"try-catch","validationCode":"// confirm the table is a listed Iceberg table before loading metadata\nboolean isIceberg = catalog.listTables(Namespace.of(db, schema)).stream()\n    .anyMatch(t -> t.name().equalsIgnoreCase(tableName));\nif (!isIceberg) {\n  // fail fast with NoSuchTableException instead of a metadata query error\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.loadTable(TableIdentifier.of(db, schema, table));\n} catch (IcebergException e) {\n  SQLException cause = findCause(e, SQLException.class);\n  if (cause != null && tableMissing(cause.getErrorCode())) {\n    // handle missing/non-Iceberg table\n  } else if (isTransient(cause)) {\n    // retry with backoff\n  } else {\n    throw e;\n  }\n}","preventionTips":["Verify the table exists and is a Snowflake-managed Iceberg table before loading","Ensure the role has SELECT/OWNERSHIP on the table and USAGE on its parents","Re-list tables when load fails after a drop/rename to refresh identifiers","Validate JDBC auth and add retries for transient errors"],"tags":["snowflake","jdbc","table-metadata"],"backgroundTag":"database-query-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}