{"record":{"id":"c1d662bcaa8b6614","repo":"apache/iceberg","slug":"failed-to-get-view-s-from-catalog-s","errorCode":null,"errorMessage":"Failed to get view %s from catalog %s","messagePattern":"Failed to get view (.+?) from catalog (.+?)","errorType":"exception","errorClass":"UncheckedSQLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java","lineNumber":77,"sourceCode":"    this.catalogName = catalogName;\n    this.viewIdentifier = viewIdentifier;\n    this.fileIO = fileIO;\n    this.connections = dbConnPool;\n    this.catalogProperties = catalogProperties;\n  }\n\n  @Override\n  protected void doRefresh() {\n    Map<String, String> view;\n\n    try {\n      view = JdbcUtil.loadView(JdbcUtil.SchemaVersion.V1, connections, catalogName, viewIdentifier);\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new UncheckedInterruptedException(e, \"Interrupted during refresh\");\n    } catch (SQLException e) {\n      // SQL exception happened when getting view from catalog\n      throw new UncheckedSQLException(\n          e, \"Failed to get view %s from catalog %s\", viewIdentifier, catalogName);\n    }\n\n    if (view.isEmpty()) {\n      if (currentMetadataLocation() != null) {\n        throw new NoSuchViewException(\"View does not exist: %s\", viewIdentifier);\n      } else {\n        this.disableRefresh();\n        return;\n      }\n    }\n\n    String newMetadataLocation = view.get(JdbcTableOperations.METADATA_LOCATION_PROP);\n    Preconditions.checkState(\n        newMetadataLocation != null, \"Invalid view %s: metadata location is null\", viewIdentifier);\n    refreshFromMetadataLocation(newMetadataLocation);\n  }\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java#L59-L95","documentation":"Thrown by JdbcViewOperations.doRefresh when loading the view row from the JDBC catalog throws a SQLException. The raw SQL error is wrapped in UncheckedSQLException with the view identifier and catalog name for context. It indicates a database-level failure while reading view metadata — connectivity, SQL syntax/schema issues, or permissions.","triggerScenarios":"Calling catalog.loadView / doRefresh when the database is unreachable, the connection pool is exhausted, the iceberg_views table is missing or has an unexpected schema, or the DB user lacks SELECT privileges.","commonSituations":"Misconfigured JDBC URL/credentials, database restarted or network partition, catalog tables not initialized (missing schema), or upgrading Iceberg against an older/partially-migrated JDBC catalog.","solutions":["Verify database connectivity and credentials in the catalog's URI/user properties","Confirm the JDBC catalog schema is initialized (iceberg_views table exists with expected columns)","Check DB user permissions for SELECT on catalog tables","Inspect the wrapped SQLException cause for the precise driver error"],"exampleFix":"// before\nView view = catalog.loadView(ident); // fails with UncheckedSQLException\n// after\n// check catalog config first\nMap<String, String> props = Map.of(\n  CatalogProperties.URI, \"jdbc:postgresql://host:5432/db\",\n  JdbcCatalog.PROPERTY_PREFIX + \"user\", \"iceberg\",\n  JdbcCatalog.PROPERTY_PREFIX + \"password\", \"...\");\nView view = new JdbcCatalog(...).loadView(ident);","handlingStrategy":"retry","validationCode":"// Validate catalog config before use\nPreconditions.checkNotNull(props.get(CatalogProperties.URI), \"JDBC URI required\");\nPreconditions.checkNotNull(props.get(JdbcCatalog.PROPERTY_PREFIX + \"user\"), \"JDBC user required\");\nPreconditions.checkNotNull(props.get(JdbcCatalog.PROPERTY_PREFIX + \"password\"), \"JDBC password required\");","typeGuard":null,"tryCatchPattern":"try {\n  View view = catalog.loadView(ident);\n} catch (UncheckedSQLException e) {\n  // inspect e.getCause() (SQLException) for SQLState/retryability\n  if (isTransient(e)) retryWithBackoff(); else throw e;\n}","preventionTips":["Initialize the JDBC catalog schema before first use","Verify DB connectivity and credentials at startup","Grant SELECT privileges on iceberg_views to the catalog user","Keep the catalog database healthy and reachable from compute"],"tags":["jdbc","sql","view"],"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-23T08:17:48.524Z"}