{"record":{"id":"2213dab64e04d35d","repo":"apache/iceberg","slug":"view-does-not-exist-s-2213da","errorCode":null,"errorMessage":"View does not exist: %s","messagePattern":"View does not exist: (.+?)","errorType":"exception","errorClass":"NoSuchViewException","httpStatus":404,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveOperationsBase.java","lineNumber":132,"sourceCode":"  static void validateTableIsIceberg(Table table, String fullName) {\n    String tableType = table.getParameters().get(BaseMetastoreTableOperations.TABLE_TYPE_PROP);\n    NoSuchIcebergTableException.check(\n        isValidIcebergTable(table), \"Not an iceberg table: %s (type=%s)\", fullName, tableType);\n  }\n\n  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;","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveOperationsBase.java#L114-L150","documentation":"HiveOperationsBase throws NoSuchViewException when a name resolves in the Hive Metastore to a valid Iceberg TABLE, but the caller requested it as a view. The HMS object exists, yet there is no Iceberg view at that identifier, so the view-load path fails. This enforces the table/view namespace separation in the Hive catalog.","triggerScenarios":"Calling loadView/loadTable-as-view (e.g. HiveCatalog.loadView or view-related validation) on an identifier that actually refers to an Iceberg table registered in HMS; validateIcebergTableNotLoadedAsIcebergView detects isValidIcebergTable(table) && !isValidIcebergView(table).","commonSituations":"Typo or copy-paste reusing a table name for a view; code migrated from table APIs to view APIs without renaming; an existing Iceberg table at the same catalog.database.name target where a view was expected.","solutions":["Load the identifier as a table instead: catalog.loadTable(identifier) — the object exists and is an Iceberg table.","Verify the intended view name; create the view if it does not exist via catalog.buildView(...).create().","Check the HMS entity (describe formatted / HiveCatalog) to confirm whether it is a table or view and correct the call site."],"exampleFix":"// before\nView view = catalog.loadView(TableIdentifier.of(\"db\", \"events\")); // events is a table\n// after\nTable table = catalog.loadTable(TableIdentifier.of(\"db\", \"events\"));","handlingStrategy":"try-catch","validationCode":"if (catalog.tableExists(ident) && !catalog.viewExists(ident)) { /* load as table */ }","typeGuard":null,"tryCatchPattern":"try { view = catalog.loadView(ident); } catch (NoSuchViewException e) { table = catalog.loadTable(ident); }","preventionTips":["Use distinct naming conventions for tables and views.","Check catalog.viewExists before loading as a view.","Track entity kinds in your pipeline metadata."],"tags":["hive-metastore","view-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"}