{"record":{"id":"638a7a1f153b8ed3","repo":"prestodb/presto","slug":"invalid-function-argument-638a7a","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"Unsupported number of arguments: %s","messagePattern":"Unsupported number of arguments: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/StatisticalDigestAggregationFunction.java","lineNumber":180,"sourceCode":"                classLoader);\n        return new BuiltInAggregationFunctionImplementation(name, inputTypes, ImmutableList.of(intermediateType), outputType,\n                true, true, metadata, accumulatorClass, groupedAccumulatorClass);\n    }\n\n    private static List<Type> getInputTypes(Type valueType, int arity)\n    {\n        switch (arity) {\n            case 1:\n                // weight and accuracy unspecified\n                return ImmutableList.of(valueType);\n            case 2:\n                // weight specified, accuracy unspecified\n                return ImmutableList.of(valueType, BIGINT);\n            case 3:\n                // weight and accuracy specified\n                return ImmutableList.of(valueType, BIGINT, DOUBLE);\n            default:\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"Unsupported number of arguments: %s\", arity));\n        }\n    }\n\n    private MethodHandle getInputMethodHandle(Type valueType, int arity)\n    {\n        switch (type) {\n            case TDIGEST:\n                return getTDigestInputMethodHandle(valueType, arity);\n            case QDIGEST:\n                return getQuantileDigestInputMethodHandle(valueType, arity);\n            default:\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"%s must be a statistical digest\", type));\n        }\n    }\n\n    private MethodHandle getTDigestInputMethodHandle(Type valueType, int arity)\n    {\n        final MethodHandle inputFunction;","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/StatisticalDigestAggregationFunction.java#L162-L198","documentation":"getInputTypes maps the aggregation's argument count (arity) to input types: 1 arg (value), 2 args (value, weight), or 3 args (value, weight, accuracy). Any other arity is rejected with INVALID_FUNCTION_ARGUMENT because the function signature is undefined for it.","triggerScenarios":"Registering or invoking the statistical digest aggregation with 0, or more than 3 arguments, so the switch in getInputTypes falls to default.","commonSituations":"Typos in SQL aggregation calls passing extra arguments, or custom function registrations built with wrong parameter counts.","solutions":["Call the aggregation with 1, 2, or 3 arguments only (value, value+weight, or value+weight+accuracy).","Check the function signature in the catalog/registry to confirm accepted arities.","If this is a custom binding, fix the arity passed to the aggregation metadata builder."],"exampleFix":"// before\nqdigest_agg(value, weight, accuracy, extra)\n// after\nqdigest_agg(value, weight, accuracy)","handlingStrategy":"validation","validationCode":"if (args.size() < 1 || args.size() > 3) throw new IllegalArgumentException(\"digest aggregation accepts 1-3 arguments\");","typeGuard":null,"tryCatchPattern":"try { runQuery(sql); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"INVALID_FUNCTION_ARGUMENT\") && e.getMessage().startsWith(\"Unsupported number of arguments\")) { fixArity(sql); } else throw e; }","preventionTips":["Call digest aggregations with only value, value+weight, or value+weight+accuracy","Consult SHOW FUNCTION signature before use","Keep arity switches consistent when extending the aggregation"],"tags":["aggregation","arity","function-signature"],"backgroundTag":"unsupported-number-of-arguments","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"}