prestodb/presto · error · HiveViewNotSupportedException

Hive view is not supported: ${schemaTableName}

Error message

Hive view is not supported: ${schemaTableName}

What it means

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.

Source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastore.java:432

    @Override
    public Optional<Table> getTable(MetastoreContext metastoreContext, String databaseName, String tableName)
    {
        HiveTableHandle hiveTableHandle = new HiveTableHandle(databaseName, tableName);
        return getTable(metastoreContext, hiveTableHandle);
    }

    @Override
    public Optional<Table> getTable(MetastoreContext metastoreContext, HiveTableHandle hiveTableHandle)
    {
        try {
            return retry()
                    .stopOn(NoSuchObjectException.class, HiveViewNotSupportedException.class)
                    .stopOnIllegalExceptions()
                    .run("getTable", stats.getGetTable().wrap(() ->
                            getMetastoreClientThenCall(metastoreContext, client -> {
                                Table table = client.getTable(hiveTableHandle.getSchemaName(), hiveTableHandle.getTableName());
                                if (table.getTableType().equals(TableType.VIRTUAL_VIEW.name()) && !isPrestoView(table)) {
                                    throw new HiveViewNotSupportedException(hiveTableHandle.getSchemaTableName());
                                }
                                return Optional.of(table);
                            })));
        }
        catch (NoSuchObjectException e) {
            return Optional.empty();
        }
        catch (TException e) {
            throw new PrestoException(HIVE_METASTORE_ERROR, e);
        }
        catch (Exception e) {
            throw propagate(e);
        }
    }

    @Override
    public Set<ColumnStatisticType> getSupportedColumnStatistics(MetastoreContext metastoreContext, Type type)
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Recreate the view in Presto with CREATE VIEW instead of Hive
  2. Query the underlying base table directly instead of the Hive view
  3. Enable/use a connector that supports Hive views (e.g. hive.views-execution for materialized views or a view-execution module)
  4. Rename the Hive view so it is not picked up when browsing tables

Example fix

// before (Hive)
CREATE VIEW my_view AS SELECT a, b FROM my_table;
// after (Presto)
CREATE VIEW hive.default.my_view AS SELECT a, b FROM my_table;
Defensive patterns

Strategy: validation

Validate before calling

// Check the object is a Presto table, not a Hive view, before querying
Table table = metastore.getTable(schemaName, tableName).orElseThrow();
boolean isHiveView = "VIRTUAL_VIEW".equals(table.getTableType()) && !isPrestoView(table);
if (isHiveView) {
    throw new IllegalStateException("Use CREATE VIEW in Presto or query the base table for " + schemaName + "." + tableName);
}

Type guard

public static boolean isHiveView(Table table) {
    return table != null
        && TableType.VIRTUAL_VIEW.name().equals(table.getTableType())
        && !isPrestoView(table);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/04ede4832ebbce77. Report an issue: GitHub.