{"record":{"id":"04ede4832ebbce77","repo":"prestodb/presto","slug":"hive-view-is-not-supported-schematablename","errorCode":null,"errorMessage":"Hive view is not supported: ${schemaTableName}","messagePattern":"Hive view is not supported: (.+?)","errorType":"exception","errorClass":"HiveViewNotSupportedException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastore.java","lineNumber":432,"sourceCode":"    @Override\n    public Optional<Table> getTable(MetastoreContext metastoreContext, String databaseName, String tableName)\n    {\n        HiveTableHandle hiveTableHandle = new HiveTableHandle(databaseName, tableName);\n        return getTable(metastoreContext, hiveTableHandle);\n    }\n\n    @Override\n    public Optional<Table> getTable(MetastoreContext metastoreContext, HiveTableHandle hiveTableHandle)\n    {\n        try {\n            return retry()\n                    .stopOn(NoSuchObjectException.class, HiveViewNotSupportedException.class)\n                    .stopOnIllegalExceptions()\n                    .run(\"getTable\", stats.getGetTable().wrap(() ->\n                            getMetastoreClientThenCall(metastoreContext, client -> {\n                                Table table = client.getTable(hiveTableHandle.getSchemaName(), hiveTableHandle.getTableName());\n                                if (table.getTableType().equals(TableType.VIRTUAL_VIEW.name()) && !isPrestoView(table)) {\n                                    throw new HiveViewNotSupportedException(hiveTableHandle.getSchemaTableName());\n                                }\n                                return Optional.of(table);\n                            })));\n        }\n        catch (NoSuchObjectException e) {\n            return Optional.empty();\n        }\n        catch (TException e) {\n            throw new PrestoException(HIVE_METASTORE_ERROR, e);\n        }\n        catch (Exception e) {\n            throw propagate(e);\n        }\n    }\n\n    @Override\n    public Set<ColumnStatisticType> getSupportedColumnStatistics(MetastoreContext metastoreContext, Type type)\n    {","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastore.java#L414-L450","documentation":"HiveViewNotSupportedException is thrown by ThriftHiveMetastore.getTable when the requested table exists in the Hive Metastore but is a VIRTUAL_VIEW that was not created by Presto. Presto's Hive connector can only read Presto-defined views; views created by Hive (or other engines) have no Presto representation and cannot be queried as a table.","triggerScenarios":"Calling getTable (e.g. via SELECT * FROM hive.schema.view_name) where metastore client.getTable returns a table with TableType.VIRTUAL_VIEW and isPrestoView(table) is false.","commonSituations":"Querying a view created with CREATE VIEW in Hive CLI/Beeline; pointing Presto at a shared metastore containing Hive-authored views; using SHOW TABLES (which lists the view) then SELECTing from it.","solutions":["Recreate the view in Presto with CREATE VIEW instead of Hive","Query the underlying base table directly instead of the Hive view","Enable/use a connector that supports Hive views (e.g. hive.views-execution for materialized views or a view-execution module)","Rename the Hive view so it is not picked up when browsing tables"],"exampleFix":"// before (Hive)\nCREATE VIEW my_view AS SELECT a, b FROM my_table;\n// after (Presto)\nCREATE VIEW hive.default.my_view AS SELECT a, b FROM my_table;","handlingStrategy":"validation","validationCode":"// Check the object is a Presto table, not a Hive view, before querying\nTable table = metastore.getTable(schemaName, tableName).orElseThrow();\nboolean isHiveView = \"VIRTUAL_VIEW\".equals(table.getTableType()) && !isPrestoView(table);\nif (isHiveView) {\n    throw new IllegalStateException(\"Use CREATE VIEW in Presto or query the base table for \" + schemaName + \".\" + tableName);\n}","typeGuard":"public static boolean isHiveView(Table table) {\n    return table != null\n        && TableType.VIRTUAL_VIEW.name().equals(table.getTableType())\n        && !isPrestoView(table);\n}","tryCatchPattern":null,"preventionTips":["Create views with Presto's CREATE VIEW so they carry Presto-view properties","Audit shared metastores for Hive-authored views before onboarding schemas to Presto","Prefer querying base tables directly when a Hive view is only a thin rename/selection","Document engine-specific views to prevent cross-engine selection mistakes"],"tags":["hive","view","metastore","unsupported-feature"],"backgroundTag":"hive-view-not-supported","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}