{"record":{"id":"f210752546e48fb9","repo":"prestodb/presto","slug":"function-implementation-error-f21075","errorCode":"FUNCTION_IMPLEMENTATION_ERROR","errorMessage":"expected group enum type %s","messagePattern":"expected group enum type (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/histogram/HistogramStateFactory.java","lineNumber":65,"sourceCode":"\n    @Override\n    public Class<? extends HistogramState> getSingleStateClass()\n    {\n        return SingleHistogramState.class;\n    }\n\n    @Override\n    public HistogramState createGroupedState()\n    {\n        if (mode == NEW) {\n            return new GroupedHistogramState(keyType, expectedEntriesCount);\n        }\n\n        if (mode == LEGACY) {\n            return new LegacyHistogramGroupState(keyType, expectedEntriesCount);\n        }\n\n        throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, format(\"expected group enum type %s\", mode));\n    }\n\n    @Override\n    public Class<? extends HistogramState> getGroupedStateClass()\n    {\n        if (mode == NEW) {\n            return GroupedHistogramState.class;\n        }\n\n        if (mode == LEGACY) {\n            return LegacyHistogramGroupState.class;\n        }\n\n        throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, format(\"expected group enum type %s\", mode));\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":82,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/histogram/HistogramStateFactory.java#L47-L82","documentation":"HistogramStateFactory.createGroupedState selects the group-state implementation based on a HistogramGroupMode enum. If the mode is neither NEW nor LEGACY (an unexpected/unhandled enum value, e.g. from a stale serialized state factory or an internal bug), the factory cannot instantiate state and throws FUNCTION_IMPLEMENTATION_ERROR — a signal of an internal implementation inconsistency rather than user input error.","triggerScenarios":"createGroupedState invoked with a HistogramGroupMode other than NEW or LEGACY, typically from an incompatibly serialized plan/state or an internal regression adding a new enum constant without updating this switch.","commonSituations":"Rolling upgrades where a coordinator/worker version mismatch introduces a new mode; stale cached plans referencing an old/new histogram implementation.","solutions":["Restart the cluster so all nodes run the same Presto version.","Invalidate cached plans / retry the query; report a bug if it reproduces on a uniform version.","Ensure coordinator and workers are not mixed across versions during upgrade."],"exampleFix":"// before\n// enum has new value but factory only handles NEW/LEGACY\n// after\nif (mode == NEW) { ... } else if (mode == LEGACY) { ... } else if (mode == NEW_VALUE) { ... } else { throw ... }","handlingStrategy":"try-catch","validationCode":"-- ensure uniform Presto versions\n-- run `SELECT node_version FROM system.runtime.nodes;` and confirm a single version","typeGuard":null,"tryCatchPattern":"try { result = query(...); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"FUNCTION_IMPLEMENTATION_ERROR\")) { /* retry after version alignment / plan cache clear */ } else { throw e; } }","preventionTips":["Keep coordinator and workers on identical builds","Clear stale plans after upgrades","Add every new enum mode to all factory dispatch sites when extending histogram"],"tags":["presto","histogram","internal-error","state-factory"],"backgroundTag":"internal-implementation-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"}