{"record":{"id":"28b2735118cd179f","repo":"prestodb/presto","slug":"show-create-only-supported-for-tables-and-views","errorCode":null,"errorMessage":"SHOW CREATE only supported for tables and views","messagePattern":"SHOW CREATE only supported for tables and views","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java","lineNumber":642,"sourceCode":"                                        constraint.isEnforced()));\n                            }\n                            return Optional.empty();\n                        })\n                        .filter(Optional::isPresent)\n                        .map(Optional::get)\n                        .map(ConstraintSpecification.class::cast)\n                        .collect(toImmutableList()));\n\n                CreateTable createTable = new CreateTable(\n                        QualifiedName.of(objectName.getCatalogName(), objectName.getSchemaName(), objectName.getObjectName()),\n                        columns,\n                        false,\n                        propertyNodes,\n                        connectorTableMetadata.getComment());\n                return singleValueQuery(\"Create Table\", formatSql(createTable, Optional.of(parameters)).trim());\n            }\n\n            throw new UnsupportedOperationException(\"SHOW CREATE only supported for tables and views\");\n        }\n\n        @Override\n        protected Node visitShowCreateFunction(ShowCreateFunction node, Void context)\n        {\n            QualifiedObjectName functionName = metadata.getFunctionAndTypeManager().getFunctionAndTypeResolver().qualifyObjectName(node.getName());\n            Collection<? extends SqlFunction> functions = metadata.getFunctionAndTypeManager().getFunctions(session, functionName);\n            if (node.getParameterTypes().isPresent()) {\n                List<TypeSignature> parameterTypes = node.getParameterTypes().get().stream()\n                        .map(TypeSignature::parseTypeSignature)\n                        .collect(toImmutableList());\n                functions = functions.stream()\n                        .filter(function -> function.getSignature().getArgumentTypes().equals(parameterTypes))\n                        .collect(toImmutableList());\n            }\n            if (functions.isEmpty()) {\n                String types = node.getParameterTypes().map(parameterTypes -> format(\"(%s)\", Joiner.on(\", \").join(parameterTypes))).orElse(\"\");\n                throw new PrestoException(FUNCTION_NOT_FOUND, format(\"Function not found: %s%s\", functionName, types));","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java#L624-L660","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only use SHOW CREATE for tables, views, and materialized views","Check the installed Presto version's supported SHOW CREATE variants in the release notes","If hit from tooling, patch the tool to skip unsupported relation kinds"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const supportedKinds = new Set(['TABLE','VIEW','MATERIALIZED VIEW']);\nif (!supportedKinds.has(kind)) throw new Error(`SHOW CREATE unsupported for ${kind}`);","typeGuard":null,"tryCatchPattern":"try { session.execute(showCreateSql); } catch (UnsupportedOperationException e) { /* skip kind or use engine-specific DDL tool */ }","preventionTips":["Restrict SHOW CREATE usage to TABLE/VIEW/MATERIALIZED VIEW","Review release notes for newly added SHOW CREATE variants","Keep client tooling in sync with the server Presto version"],"tags":["presto","sql","unsupported-feature","internal"],"backgroundTag":"unsupported-statement","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"}