{"record":{"id":"c4ffd3b635f593cc","repo":"prestodb/presto","slug":"generic-internal-error-c4ffd3","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Cannot assign canonical plan id to Group Reference node: %s","messagePattern":"Cannot assign canonical plan id to Group Reference node: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/GroupReference.java","lineNumber":79,"sourceCode":"        return visitor.visitGroupReference(this, context);\n    }\n\n    @Override\n    public List<VariableReferenceExpression> getOutputVariables()\n    {\n        return outputs;\n    }\n\n    @Override\n    public PlanNode replaceChildren(List<PlanNode> newChildren)\n    {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public PlanNode assignStatsEquivalentPlanNode(Optional<PlanNode> statsEquivalentPlanNode)\n    {\n        throw new PrestoException(GENERIC_INTERNAL_ERROR, format(\"Cannot assign canonical plan id to Group Reference node: %s\", this));\n    }\n\n    public Optional<LogicalProperties> getLogicalProperties()\n    {\n        return logicalProperties;\n    }\n}\n","sourceCodeStart":61,"sourceCodeEnd":87,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/GroupReference.java#L61-L87","documentation":"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.","triggerScenarios":"Calling assignStatsEquivalentPlanNode on a GroupReference node, which happens when a stats-writing optimizer pass traverses the plan without skipping memo group references.","commonSituations":"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.","solutions":["Check which optimizer rule or stats pass invoked assignStatsEquivalentPlanNode on a GroupReference and fix it to skip GroupReference nodes","Verify you are not running experimental/cost-based optimizer features that mishandle memo groups; disable the cost-based optimizer as a workaround","If reproducible, file a bug with the query and stack trace to the Presto maintainers"],"exampleFix":"// before\nnode.assignStatsEquivalentPlanNode(statsEquivalentPlanNode);\n// after\nif (!(node instanceof GroupReference)) {\n    node.assignStatsEquivalentPlanNode(statsEquivalentPlanNode);\n}","handlingStrategy":"try-catch","validationCode":"if (node instanceof GroupReference) {\n    throw new IllegalStateException(\"skip stats assignment for memo group reference\");\n}","typeGuard":"function isGroupReference(node) { return node instanceof GroupReference; }","tryCatchPattern":"try {\n    node.assignStatsEquivalentPlanNode(statsNode);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == GENERIC_INTERNAL_ERROR.toErrorCode()) {\n        // log optimizer bug details and skip/abort gracefully\n    } else throw e;\n}","preventionTips":["Filter out GroupReference nodes in any custom stats-assignment pass","Test custom optimizer rules against queries that go through the memo/iterative optimizer","Report engine bugs with stack traces rather than retrying"],"tags":["optimizer","internal-error","memo"],"backgroundTag":"optimizer-internal-error","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"}