prestodb/presto · error · UnsupportedOperationException

SHOW CREATE only supported for tables and views

Error message

SHOW CREATE only supported for tables and views

What it means

The SHOW CREATE statement targeted a relation kind this rewrite does not implement. visitShowCreate only handles VIEW, MATERIALIZED VIEW, and TABLE; any other ShowCreate.Type reaches the final UnsupportedOperationException. Unlike SemanticExceptions this is not a user-facing SQL error and surfaces as a generic internal failure.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:642

                                        constraint.isEnforced()));
                            }
                            return Optional.empty();
                        })
                        .filter(Optional::isPresent)
                        .map(Optional::get)
                        .map(ConstraintSpecification.class::cast)
                        .collect(toImmutableList()));

                CreateTable createTable = new CreateTable(
                        QualifiedName.of(objectName.getCatalogName(), objectName.getSchemaName(), objectName.getObjectName()),
                        columns,
                        false,
                        propertyNodes,
                        connectorTableMetadata.getComment());
                return singleValueQuery("Create Table", formatSql(createTable, Optional.of(parameters)).trim());
            }

            throw new UnsupportedOperationException("SHOW CREATE only supported for tables and views");
        }

        @Override
        protected Node visitShowCreateFunction(ShowCreateFunction node, Void context)
        {
            QualifiedObjectName functionName = metadata.getFunctionAndTypeManager().getFunctionAndTypeResolver().qualifyObjectName(node.getName());
            Collection<? extends SqlFunction> functions = metadata.getFunctionAndTypeManager().getFunctions(session, functionName);
            if (node.getParameterTypes().isPresent()) {
                List<TypeSignature> parameterTypes = node.getParameterTypes().get().stream()
                        .map(TypeSignature::parseTypeSignature)
                        .collect(toImmutableList());
                functions = functions.stream()
                        .filter(function -> function.getSignature().getArgumentTypes().equals(parameterTypes))
                        .collect(toImmutableList());
            }
            if (functions.isEmpty()) {
                String types = node.getParameterTypes().map(parameterTypes -> format("(%s)", Joiner.on(", ").join(parameterTypes))).orElse("");
                throw new PrestoException(FUNCTION_NOT_FOUND, format("Function not found: %s%s", functionName, types));

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Only use SHOW CREATE for tables, views, and materialized views
  2. Check the installed Presto version's supported SHOW CREATE variants in the release notes
  3. If hit from tooling, patch the tool to skip unsupported relation kinds
Defensive patterns

Strategy: validation

Validate before calling

const supportedKinds = new Set(['TABLE','VIEW','MATERIALIZED VIEW']);
if (!supportedKinds.has(kind)) throw new Error(`SHOW CREATE unsupported for ${kind}`);

Try / catch

try { session.execute(showCreateSql); } catch (UnsupportedOperationException e) { /* skip kind or use engine-specific DDL tool */ }

Prevention

When it happens

Trigger: Issuing SHOW CREATE with a type outside {TABLE, VIEW, MATERIALIZED VIEW}, e.g. new statement kinds added to the grammar without a matching branch in visitShowCreate.

Common situations: Forward-compatibility gaps after a Presto upgrade introduced a new SHOW CREATE target; client drivers or BI tools emitting SHOW CREATE for unsupported object kinds.

Related errors


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