{"record":{"id":"42ca57cae0a2236f","repo":"apache/iceberg","slug":"failed-to-check-view-existence-of-viewidentifier","errorCode":null,"errorMessage":"Failed to check view existence of ${viewIdentifier}","messagePattern":"Failed to check view existence of (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java","lineNumber":520,"sourceCode":"    }\n  }\n\n  @Override\n  public boolean viewExists(TableIdentifier viewIdentifier) {\n    if (!isValidIdentifier(viewIdentifier)) {\n      return false;\n    }\n\n    String database = viewIdentifier.namespace().level(0);\n    String viewName = viewIdentifier.name();\n    try {\n      Table table = clients.run(client -> client.getTable(database, viewName));\n      HiveOperationsBase.validateTableIsIcebergView(table, fullTableName(name, viewIdentifier));\n      return true;\n    } catch (NoSuchIcebergViewException | NoSuchObjectException e) {\n      return false;\n    } catch (TException e) {\n      throw new RuntimeException(\"Failed to check view existence of \" + viewIdentifier, e);\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\n          \"Interrupted in call to check view existence of \" + viewIdentifier, e);\n    }\n  }\n\n  @Override\n  public void createNamespace(Namespace namespace, Map<String, String> meta) {\n    Preconditions.checkArgument(\n        !namespace.isEmpty(), \"Cannot create namespace with invalid name: %s\", namespace);\n    Preconditions.checkArgument(\n        isValidateNamespace(namespace),\n        \"Cannot support multi part namespace in Hive Metastore: %s\",\n        namespace);\n    Preconditions.checkArgument(\n        meta.get(HMS_DB_OWNER_TYPE) == null || meta.get(HMS_DB_OWNER) != null,\n        \"Create namespace setting %s without setting %s is not allowed\",","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L502-L538","documentation":"A RuntimeException wrapping a Thrift TException raised while HiveCatalog.viewExists probes the metastore for a view. Not-found outcomes (NoSuchIcebergViewException/NoSuchObjectException) return false normally; any other Thrift failure is unexpected and wrapped with this message and the original cause.","triggerScenarios":"Calling viewExists(identifier) (or code paths that rely on it) when clients.run(client -> client.getTable(database, viewName)) fails with a TException other than not-found — metastore connectivity failure, server error, or protocol issue.","commonSituations":"Metastore outage during query planning; wrong metastore configuration; Kerberos/token expiry causing transport failures; metastore overload.","solutions":["Check the cause chain for the underlying Thrift error to distinguish connectivity from server-side failure.","Verify metastore health, URIs, and authentication credentials, then retry.","Batch or cache view-existence checks in engines that probe many views at planning time."],"exampleFix":"// before\nboolean exists = catalog.viewExists(viewId);\n// after\ntry {\n  boolean exists = catalog.viewExists(viewId);\n} catch (RuntimeException e) {\n  LOG.error(\"Metastore failure checking view {}\", viewId, e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check metastore reachability before view resolution","typeGuard":null,"tryCatchPattern":"try { boolean ok = catalog.viewExists(viewId); } catch (RuntimeException e) { /* unknown state; inspect e.getCause() */ }","preventionTips":["Remember viewExists only returns false for definite not-found","Refresh auth tokens before long planning phases","Retry transient Thrift failures with backoff","Monitor metastore availability during query planning"],"tags":["hive-metastore","view-exists","thrift","connectivity"],"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-14T16:17:12.679Z"}