{"record":{"id":"67b6691237dba733","repo":"apache/iceberg","slug":"table-does-not-exist-s-67b669","errorCode":null,"errorMessage":"Table does not exist: %s","messagePattern":"Table does not exist: (.+?)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":404,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveOperationsBase.java","lineNumber":138,"sourceCode":"  static void validateTableIsIcebergView(Table table, String fullName) {\n    String tableTypeProp = table.getParameters().get(BaseMetastoreTableOperations.TABLE_TYPE_PROP);\n    NoSuchIcebergViewException.check(\n        isValidIcebergView(table),\n        \"Not an iceberg view: %s (type=%s) (tableType=%s)\",\n        fullName,\n        tableTypeProp,\n        table.getTableType());\n  }\n\n  static void validateIcebergTableNotLoadedAsIcebergView(Table table, String fullName) {\n    if (!isValidIcebergView(table) && isValidIcebergTable(table)) {\n      throw new NoSuchViewException(\"View does not exist: %s\", fullName);\n    }\n  }\n\n  static void validateIcebergViewNotLoadedAsIcebergTable(Table table, String fullName) {\n    if (!isValidIcebergTable(table) && isValidIcebergView(table)) {\n      throw new NoSuchTableException(\"Table does not exist: %s\", fullName);\n    }\n  }\n\n  default void persistTable(Table hmsTable, boolean updateHiveTable, String metadataLocation)\n      throws TException, InterruptedException {\n    if (updateHiveTable) {\n      metaClients()\n          .run(\n              client -> {\n                MetastoreUtil.alterTable(\n                    client, database(), table(), hmsTable, hmsEnvContext(metadataLocation));\n                return null;\n              });\n    } else {\n      metaClients()\n          .run(\n              client -> {\n                client.createTable(hmsTable);","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveOperationsBase.java#L120-L156","documentation":"HiveOperationsBase throws NoSuchTableException when the HMS entry is a valid Iceberg VIEW but the caller requested it as a table. The identifier resolves in the metastore, but not to an Iceberg table, so the table-load path fails. It is the mirror of validateIcebergTableNotLoadedAsIcebergView.","triggerScenarios":"Calling catalog.loadTable(identifier) on a name that is registered as an Iceberg view in HMS; validateIcebergViewNotLoadedAsIcebergTable detects !isValidIcebergTable(table) && isValidIcebergView(table).","commonSituations":"A view was created at the same name after the code expected a table; renaming an entity from view to table in code while the HMS object stayed a view; loading all entities of a database assuming tables.","solutions":["Load it as a view instead: catalog.loadView(identifier).","If a table is intended, choose a different name and create the table, since the name is occupied by a view.","Drop or rename the existing view in HMS if the identifier should hold a table."],"exampleFix":"// before\nTable table = catalog.loadTable(TableIdentifier.of(\"db\", \"summary\")); // it's a view\n// after\nView view = catalog.loadView(TableIdentifier.of(\"db\", \"summary\"));","handlingStrategy":"try-catch","validationCode":"if (catalog.viewExists(ident) && !catalog.tableExists(ident)) { /* load as view */ }","typeGuard":null,"tryCatchPattern":"try { table = catalog.loadTable(ident); } catch (NoSuchTableException e) { view = catalog.loadView(ident); }","preventionTips":["Confirm entity type via HMS before loading.","Avoid reusing the same identifier for tables and views across migrations.","Enumerate databases/tables with the correct catalog API."],"tags":["hive-metastore","table-not-found","catalog"],"backgroundTag":"entity-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}