prestodb/presto · error · UnsupportedOperationException

materialized execution is not supported by the presto on spa

Error message

materialized execution is not supported by the presto on spark

What it means

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.

Source

Thrown at presto-spark-base/src/main/java/com/facebook/presto/spark/planner/PrestoSparkPlanFragmenter.java:44

public class PrestoSparkPlanFragmenter
{
    private final PlanFragmenter planFragmenter;

    @Inject
    public PrestoSparkPlanFragmenter(PlanFragmenter planFragmenter)
    {
        this.planFragmenter = requireNonNull(planFragmenter, "planFragmenter is null");
    }

    public SubPlan fragmentQueryPlan(Session session, Plan plan, WarningCollector warningCollector)
    {
        PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator()
        {
            @Override
            public PlanNodeId getNextId()
            {
                throw new UnsupportedOperationException("materialized execution is not supported by the presto on spark");
            }
        };
        return planFragmenter.createSubPlans(session, plan, false, planNodeIdAllocator, warningCollector);
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Disable materialized execution / CTE materialization session properties when running on Presto on Spark
  2. Inline the CTE manually instead of relying on automatic materialization
  3. Upgrade Presto if support for materialized execution on Spark lands in a later release

Example fix

// before
SET SESSION cte_materialization_enabled = true;
// after
SET SESSION cte_materialization_enabled = false; -- unsupported on Presto on Spark
Defensive patterns

Strategy: validation

Validate before calling

if (session.getSystemProperty("cte_materialization_enabled").equals("true")) {
    throw new PrestoException(NOT_SUPPORTED, "cte materialization unsupported on Spark");
}

Try / catch

try { planFragmenter.createSubPlans(...) } catch (UnsupportedOperationException e) { if (e.getMessage().contains("materialized execution")) { log.error("disable materialization features", e); } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: Enabling CTE materialization or materialized-execution session features on Presto on Spark; queries using features that require re-planning with fresh node IDs.

Related errors


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