{"record":{"id":"9775eadedd4a35b0","repo":"prestodb/presto","slug":"invalid-function-argument-9775ea","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"cannot add a double to a q-digest","messagePattern":"cannot add a double to a q-digest","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/StatisticalDigest.java","lineNumber":25,"sourceCode":" *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.facebook.presto.operator.aggregation;\n\nimport com.facebook.presto.spi.PrestoException;\nimport io.airlift.slice.Slice;\n\nimport static com.facebook.presto.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT;\n\npublic interface StatisticalDigest<T>\n{\n    default void add(double value, long weight)\n    {\n        throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"cannot add a double to a q-digest\");\n    }\n\n    default void add(long value, long weight)\n    {\n        throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"cannot add a long to a t-digest\");\n    }\n\n    void merge(StatisticalDigest other);\n\n    long estimatedInMemorySizeInBytes();\n\n    Slice serialize();\n\n    StatisticalDigest<T> getDigest();\n\n    double getSize();\n}\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/StatisticalDigest.java#L7-L43","documentation":"Type guard in StatisticalDigest.add (INVALID_FUNCTION_ARGUMENT): a DOUBLE value was added to a q-digest, which only accepts BIGINT (integer) values. The value-type mismatch is detected when the add operation runs on the q-digest implementation.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/StatisticalDigest.java:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use qdigest_agg with BIGINT input for q-digests","Cast the doubles to BIGINT if integer semantics are acceptable","Use tdigest (tdigest_agg) instead, which natively supports DOUBLE values"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}