prestodb/presto · error · PrestoException

GENERIC_INTERNAL_ERROR

GENERIC_INTERNAL_ERROR

Error message

Cannot assign canonical plan id to Group Reference node: %s

What it means

GroupReference nodes represent placeholders for groups in the iterative optimizer's memo structure; they never carry a canonical stats-equivalent plan node. Assigning one is a signal that the optimizer internals tried to attach canonical plan identity to a memo group reference, which is unsupported, so Presto throws GENERIC_INTERNAL_ERROR.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/GroupReference.java:79

        return visitor.visitGroupReference(this, context);
    }

    @Override
    public List<VariableReferenceExpression> getOutputVariables()
    {
        return outputs;
    }

    @Override
    public PlanNode replaceChildren(List<PlanNode> newChildren)
    {
        throw new UnsupportedOperationException();
    }

    @Override
    public PlanNode assignStatsEquivalentPlanNode(Optional<PlanNode> statsEquivalentPlanNode)
    {
        throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Cannot assign canonical plan id to Group Reference node: %s", this));
    }

    public Optional<LogicalProperties> getLogicalProperties()
    {
        return logicalProperties;
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check which optimizer rule or stats pass invoked assignStatsEquivalentPlanNode on a GroupReference and fix it to skip GroupReference nodes
  2. Verify you are not running experimental/cost-based optimizer features that mishandle memo groups; disable the cost-based optimizer as a workaround
  3. If reproducible, file a bug with the query and stack trace to the Presto maintainers

Example fix

// before
node.assignStatsEquivalentPlanNode(statsEquivalentPlanNode);
// after
if (!(node instanceof GroupReference)) {
    node.assignStatsEquivalentPlanNode(statsEquivalentPlanNode);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (node instanceof GroupReference) {
    throw new IllegalStateException("skip stats assignment for memo group reference");
}

Type guard

function isGroupReference(node) { return node instanceof GroupReference; }

Try / catch

try {
    node.assignStatsEquivalentPlanNode(statsNode);
} catch (PrestoException e) {
    if (e.getErrorCode() == GENERIC_INTERNAL_ERROR.toErrorCode()) {
        // log optimizer bug details and skip/abort gracefully
    } else throw e;
}

Prevention

When it happens

Trigger: Calling assignStatsEquivalentPlanNode on a GroupReference node, which happens when a stats-writing optimizer pass traverses the plan without skipping memo group references.

Common situations: Custom optimizer rules or stats-collection passes running during iterative optimization that do not filter out GroupReference nodes; usually indicates an engine bug rather than a user error.

Related errors


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