{"record":{"id":"5a18b7802ae76bdf","repo":"prestodb/presto","slug":"not-supported-5a18b7","errorCode":"NOT_SUPPORTED","errorMessage":"CREATE TABLE IF NOT EXISTS is not supported in this context ","messagePattern":"CREATE TABLE IF NOT EXISTS is not supported in this context ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/LogicalPlanner.java","lineNumber":210,"sourceCode":"        if (statement instanceof CreateTableAsSelect && analysis.isCreateTableAsSelectNoOp()) {\n            checkState(analysis.getCreateTableDestination().isPresent(), \"Table destination is missing\");\n            VariableReferenceExpression variable = variableAllocator.newVariable(getSourceLocation(statement), \"rows\", BIGINT);\n            PlanNode source = new ValuesNode(\n                    getSourceLocation(statement),\n                    idAllocator.getNextId(),\n                    ImmutableList.of(variable),\n                    ImmutableList.of(ImmutableList.of(constant(0L, BIGINT))),\n                    Optional.empty());\n            return new OutputNode(source.getSourceLocation(), idAllocator.getNextId(), source, ImmutableList.of(\"rows\"), ImmutableList.of(variable));\n        }\n        return createOutputPlan(planStatementWithoutOutput(analysis, statement), analysis);\n    }\n\n    private RelationPlan planStatementWithoutOutput(Analysis analysis, Statement statement)\n    {\n        if (statement instanceof CreateTableAsSelect) {\n            if (analysis.isCreateTableAsSelectNoOp()) {\n                throw new PrestoException(NOT_SUPPORTED, \"CREATE TABLE IF NOT EXISTS is not supported in this context \" + statement.getClass().getSimpleName());\n            }\n            return createTableCreationPlan(analysis, ((CreateTableAsSelect) statement).getQuery());\n        }\n        else if (statement instanceof Analyze) {\n            return createAnalyzePlan(analysis, (Analyze) statement);\n        }\n        else if (statement instanceof Call) {\n            Optional<DistributedProcedure.DistributedProcedureType> procedureType = analysis.getCallDistributedProcedureAnalysis()\n                    .map(Analysis.CallDistributedProcedureAnalysis::getDistributedProcedureType);\n            checkState(procedureType.isPresent(),\n                    \"Call distributed procedure analysis is missing\");\n            switch (procedureType.get()) {\n                case TABLE_DATA_REWRITE:\n                    return createCallDistributedProcedurePlanForTableDataRewrite(analysis, (Call) statement);\n                default:\n                    throw new PrestoException(NOT_SUPPORTED, \"Unsupported distributed procedure type: \" + procedureType.get());\n            }\n        }","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/LogicalPlanner.java#L192-L228","documentation":"Planning error: a CREATE TABLE IF NOT EXISTS (or INSERT-style CTAS no-op path) statement reached a planning context that does not support the IF NOT EXISTS no-op semantics (e.g. inside a distributed procedure or non-standard execution path), so the planner refuses to produce a plan for it.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/planner/LogicalPlanner.java:210 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop the IF NOT EXISTS clause and handle existence checks manually","Check table existence first, then run a plain CREATE TABLE AS SELECT","Use a supported execution context for the CTAS statement"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}