{"record":{"id":"55aa8d8113f8c861","repo":"prestodb/presto","slug":"materialized-execution-is-not-supported-by-the-pre","errorCode":null,"errorMessage":"materialized execution is not supported by the presto on spark","messagePattern":"materialized execution is not supported by the presto on spark","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-spark-base/src/main/java/com/facebook/presto/spark/planner/PrestoSparkPlanFragmenter.java","lineNumber":44,"sourceCode":"\npublic class PrestoSparkPlanFragmenter\n{\n    private final PlanFragmenter planFragmenter;\n\n    @Inject\n    public PrestoSparkPlanFragmenter(PlanFragmenter planFragmenter)\n    {\n        this.planFragmenter = requireNonNull(planFragmenter, \"planFragmenter is null\");\n    }\n\n    public SubPlan fragmentQueryPlan(Session session, Plan plan, WarningCollector warningCollector)\n    {\n        PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator()\n        {\n            @Override\n            public PlanNodeId getNextId()\n            {\n                throw new UnsupportedOperationException(\"materialized execution is not supported by the presto on spark\");\n            }\n        };\n        return planFragmenter.createSubPlans(session, plan, false, planNodeIdAllocator, warningCollector);\n    }\n}\n","sourceCodeStart":26,"sourceCodeEnd":50,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-base/src/main/java/com/facebook/presto/spark/planner/PrestoSparkPlanFragmenter.java#L26-L50","documentation":"PrestoSparkPlanFragmenter supplies a PlanNodeIdAllocator whose getNextId always throws UnsupportedOperationException, because materialized (fresh plan-node id allocation for materialized views/CTE re-use) execution is not supported on Spark. Any attempt to allocate new plan node IDs during sub-plan creation aborts.","triggerScenarios":"The fragmenter's createSubPlans path tries to allocate a new plan node id (e.g. materialized execution / CTE materialization features enabled) and hits the stub allocator in getNextId.","commonSituations":"Enabling CTE materialization or materialized-execution session features on Presto on Spark; queries using features that require re-planning with fresh node IDs.","solutions":["Disable materialized execution / CTE materialization session properties when running on Presto on Spark","Inline the CTE manually instead of relying on automatic materialization","Upgrade Presto if support for materialized execution on Spark lands in a later release"],"exampleFix":"// before\nSET SESSION cte_materialization_enabled = true;\n// after\nSET SESSION cte_materialization_enabled = false; -- unsupported on Presto on Spark","handlingStrategy":"validation","validationCode":"if (session.getSystemProperty(\"cte_materialization_enabled\").equals(\"true\")) {\n    throw new PrestoException(NOT_SUPPORTED, \"cte materialization unsupported on Spark\");\n}","typeGuard":null,"tryCatchPattern":"try { planFragmenter.createSubPlans(...) } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"materialized execution\")) { log.error(\"disable materialization features\", e); } throw e; }","preventionTips":["Set cte_materialization_enabled=false in Spark cluster session defaults","Rewrite CTE-heavy queries to avoid auto-materialization paths","Check release notes before enabling new materialization features on Spark"],"tags":["presto-on-spark","materialized-execution","unsupported-operation","plan-fragmenter"],"backgroundTag":"materialized-execution-unsupported","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"}