{"record":{"id":"e97144e50f64099b","repo":"prestodb/presto","slug":"invalid-function-argument-e97144","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"e.getMessage()","messagePattern":"e\\.getMessage\\(\\)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/noisyaggregation/SfmSketchMergeAggregation.java","lineNumber":53,"sourceCode":"\n    @InputFunction\n    public static void input(@AggregationState SfmSketchState state, @SqlType(SfmSketchType.NAME) Slice value)\n    {\n        SfmSketch sketch = SfmSketch.deserialize(value);\n        SfmSketch previous = state.getSketch();\n        if (previous == null) {\n            // if state sketch is empty, add this sketch to the state\n            state.setSketch(sketch);\n            state.setEpsilon(0); // not used\n        }\n        else {\n            // if state already has a sketch, merge in the current sketch\n            try {\n                // throws if the sketches are incompatible (e.g., different bucket count/size)\n                state.mergeSketch(sketch);\n            }\n            catch (IllegalArgumentException e) {\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);\n            }\n        }\n    }\n\n    @CombineFunction\n    public static void combine(@AggregationState SfmSketchState state, @AggregationState SfmSketchState otherState)\n    {\n        SfmSketchAggregationUtils.mergeStates(state, otherState);\n    }\n\n    @OutputFunction(SfmSketchType.NAME)\n    public static void output(@AggregationState SfmSketchState state, BlockBuilder out)\n    {\n        VARBINARY.writeSlice(out, state.getSketch().serialize());\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":70,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/noisyaggregation/SfmSketchMergeAggregation.java#L35-L70","documentation":"The SfmSketchMergeAggregation @InputFunction merges an incoming sketch into the state's sketch. If the sketches are incompatible (different bucket count/size), mergeSketch throws IllegalArgumentException, which is caught and rethrown as INVALID_FUNCTION_ARGUMENT with the original message.","triggerScenarios":"Calling the sfm sketch aggregation (@InputFunction input) over rows whose sketch values were built with different bucket counts or sizes.","commonSituations":"Sketches from jobs with different configurations, or sketch columns populated across schema/config changes, aggregated in one query.","solutions":["Regenerate all sketches with the same bucket count/size configuration","Verify sketch construction parameters across data producers","Catch this error in the client and surface which job produced the mismatched sketch"],"exampleFix":"// before\nINSERT INTO t VALUES (sfm_sketch(x, buckets=1024)); -- later aggregated with buckets=2048 inputs\n// after\nINSERT INTO t VALUES (sfm_sketch(x, buckets=2048));","handlingStrategy":"validation","validationCode":"// verify sketch inputs share parameters before aggregating\nif (!sketchA.sameParameters(sketchB)) throw new IllegalStateException(\"sketch params differ\");","typeGuard":null,"tryCatchPattern":"try { rows.stream().collect(sfSketchCollector); } catch (PrestoException e) { if (e.getMessage().contains(\"bucket\")) { rebuildSketchsWithUniformConfig(); } else throw e; }","preventionTips":["Use one shared sketch configuration across all producers","Store bucket count/size alongside sketch data","Recompute sketches when configuration changes"],"tags":["presto","aggregation","sketch","argument-validation"],"backgroundTag":"incompatible-sketch-merge","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"}