{"record":{"id":"197621f0a2fdc238","repo":"prestodb/presto","slug":"learn-must-run-on-a-single-machine","errorCode":null,"errorMessage":"LEARN must run on a single machine","messagePattern":"LEARN must run on a single machine","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-ml/src/main/java/com/facebook/presto/ml/LearnClassifierAggregation.java","lineNumber":55,"sourceCode":"            @SqlType(BIGINT) long label,\n            @SqlType(\"map(bigint,double)\") Block features)\n    {\n        input(state, (double) label, features);\n    }\n\n    @InputFunction\n    public static void input(\n            @AggregationState LearnState state,\n            @SqlType(DOUBLE) double label,\n            @SqlType(\"map(bigint,double)\") Block features)\n    {\n        LearnLibSvmClassifierAggregation.input(state, label, features, Slices.utf8Slice(\"\"));\n    }\n\n    @CombineFunction\n    public static void combine(@AggregationState LearnState state, @AggregationState LearnState otherState)\n    {\n        throw new UnsupportedOperationException(\"LEARN must run on a single machine\");\n    }\n\n    @OutputFunction(\"Classifier<bigint>\")\n    public static void output(@AggregationState LearnState state, BlockBuilder out)\n    {\n        LearnLibSvmClassifierAggregation.output(state, out);\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":64,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-ml/src/main/java/com/facebook/presto/ml/LearnClassifierAggregation.java#L37-L64","documentation":"LearnClassifierAggregation.combine (the @CombineFunction for LEARN) unconditionally throws UnsupportedOperationException because training a LibSVM classifier cannot be partitioned — partial aggregation states cannot be merged across machines. The LEARN aggregation must therefore execute entirely on one node.","triggerScenarios":"Running SELECT LEARN(label, features) ... on a distributed plan where the aggregation is split into partial/final stages across workers, so combine() gets invoked.","commonSituations":"Large training datasets where the planner parallelizes the aggregation; clusters where session singleNode/single-thread constraints are absent; users upgrading Presto and hitting the restriction on multi-worker setups.","solutions":["Force single-node execution for the query, e.g. session properties/plan hints that keep the aggregation on one worker (or run against a single-node cluster).","Set the aggregation to run partially... no — instead ensure the aggregation isn't split: use session property query.max-run-time-safe... concretely, restrict execution with 'single_node' style session configuration available in your Presto version.","Reduce input size (sample the training data) so single-node execution is feasible.","Use a training path that supports distributed execution if available in your Presto version."],"exampleFix":"-- before (distributed)\nSELECT LEARN(label, features) FROM training_data;\n-- after (pin to one node where supported)\nSET SESSION query_execution_policy = SINGLE_NODE; -- or run on a single-worker cluster\nSELECT LEARN(label, features) FROM training_data;","handlingStrategy":"validation","validationCode":"// pre-check plan/cluster before running LEARN\nif (workerCount > 1 && !singleNodeSessionConfigured) throw new IllegalStateException(\"LEARN requires single-node execution\");","typeGuard":null,"tryCatchPattern":"try { runLearnQuery() } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"LEARN must run on a single machine\")) { rerunSingleNode(); } else throw e; }","preventionTips":["Configure single-node execution for all ML (LEARN/LEARNER) queries","Sample training data so it fits one worker's memory"],"tags":["presto","presto-ml","aggregation","unsupported-operation"],"backgroundTag":"single-node-aggregation-required","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"}