{"record":{"id":"37c5bbe37a6c2ec3","repo":"prestodb/presto","slug":"unsupported-query-type-s-37c5bb","errorCode":null,"errorMessage":"Unsupported query type: %s","messagePattern":"Unsupported query type: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/QueryRewriter.java","lineNumber":294,"sourceCode":"        }\n        if (statement instanceof Query) {\n            Query queryBody = (Query) statement;\n            return rewriteQuery(queryBody, queryConfiguration, clusterType, shouldReuseTable, prefix, properties);\n        }\n        if (statement instanceof CreateView) {\n            CreateView createView = (CreateView) statement;\n            return rewriteCreateView(createView, queryConfiguration, clusterType, shouldReuseTable, prefix, properties);\n        }\n        if (statement instanceof CreateTable) {\n            CreateTable createTable = (CreateTable) statement;\n            return rewriteCreateTable(createTable, queryConfiguration, clusterType, shouldReuseTable, prefix, properties);\n        }\n        if (statement instanceof Delete) {\n            Delete delete = (Delete) statement;\n            return rewriteDelete(delete, queryConfiguration, clusterType, shouldReuseTable, prefix, properties);\n        }\n\n        throw new IllegalStateException(format(\"Unsupported query type: %s\", statement.getClass()));\n    }\n\n    protected QueryObjectBundle rewriteCreateTableAsSelect(CreateTableAsSelect createTableAsSelect, QueryConfiguration queryConfiguration, ClusterType clusterType, boolean shouldReuseTable, QualifiedName prefix, List<Property> properties)\n    {\n        SubstitutedStatement<Query> substitutedQuery = rewriteQueryFunctions(createTableAsSelect.getQuery());\n        Query createQuery = substitutedQuery.getStatement();\n        Optional<String> functionSubstitutions = substitutedQuery.getFunctionSubstitutions();\n\n        if (shouldReuseTable && !functionSubstitutions.isPresent()) {\n            Optional<Expression> partitionsPredicate = getPartitionsPredicate(createTableAsSelect.getName(), queryConfiguration.getPartitions());\n            if (partitionsPredicate.isPresent()) {\n                return new QueryObjectBundle(\n                        createTableAsSelect.getName(),\n                        ImmutableList.of(),\n                        createTableAsSelect,\n                        ImmutableList.of(),\n                        clusterType,\n                        Optional.empty(),","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-verifier/src/main/java/com/facebook/presto/verifier/rewrite/QueryRewriter.java#L276-L312","documentation":"QueryRewriter.rewriteQuery dispatches on the parsed Statement type (Select, Insert, Delete, CreateTableAsSelect, etc.). When the statement's concrete class matches none of the handled branches, it throws IllegalStateException signaling the verifier does not support rewriting that query type.","triggerScenarios":"Calling rewriteQuery (directly or via bundle) with a parsed statement whose class is not one of the instanceof-handled types — e.g. CREATE VIEW, MERGE, CALL, EXPLAIN, or any newer statement kind.","commonSituations":"A verifier suite is extended with new query kinds (DDL like CREATE VIEW, SHOW statements) that the rewriter never supported; a Presto upgrade adds new statement types that fall through the dispatch; tests feed arbitrary SQL to the verifier.","solutions":["Remove or replace the unsupported statement in the verifier query configuration with a supported type (SELECT/INSERT/DELETE/CTAS)","Add a rewrite branch for the statement type in QueryRewriter (e.g. implement rewriteCreateView) and dispatch on it","Log and skip unsupported statements upstream instead of passing them to rewriteQuery"],"exampleFix":"// before\nthrow new IllegalStateException(format(\"Unsupported query type: %s\", statement.getClass()));\n// after\nif (statement instanceof CreateView) {\n    return rewriteCreateView((CreateView) statement, queryConfiguration, clusterType, prefix);\n}\nthrow new IllegalStateException(format(\"Unsupported query type: %s\", statement.getClass()));","handlingStrategy":"validation","validationCode":"Statement stmt = parser.createStatement(sql);\nSet<Class<?>> supported = Set.of(Query.class, Insert.class, Delete.class, CreateTableAsSelect.class);\nif (supported.stream().noneMatch(c -> c.isAssignableFrom(stmt.getClass()))) {\n    throw new IllegalArgumentException(\"Query type not supported by verifier: \" + stmt.getClass().getSimpleName());\n}","typeGuard":"boolean isRewritableStatement(Statement s) {\n    return s instanceof Query || s instanceof Insert || s instanceof Delete || s instanceof CreateTableAsSelect;\n}","tryCatchPattern":"try {\n    return rewriter.rewriteQuery(...);\n} catch (IllegalStateException ex) {\n    if (ex.getMessage().startsWith(\"Unsupported query type\")) {\n        log.warn(\"Skipping unsupported statement: %s\", ex.getMessage());\n        return null;\n    }\n    throw ex;\n}","preventionTips":["Only feed SELECT/INSERT/DELETE/CTAS statements to the verifier","Pre-parse SQL and filter unsupported statement kinds before invoking rewriteQuery","After Presto upgrades, review whether new statement types need rewrite branches"],"tags":["verifier","query-rewrite","unsupported-query-type","illegal-state"],"backgroundTag":"unsupported-query-type","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"}