trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
9.83k stars 2.85k forks source link

MethodTooLargeException When Aggregation Funcation Use More Than 6 Parameters #22373

Open liumumumumumu opened 2 weeks ago

liumumumumumu commented 2 weeks ago

I have some User-Defined Aggregate Functions that use more than 6 parameters. They worked well in version 429.

However, half a year ago, after I upgraded Trino to version 433, these functions threw an exception: org.objectweb.asm.MethodTooLargeException: Method too large

Recently, I wanted to upgrade Trino to version 449 to experience some new features, but I found that this problem still exists.

I conducted tests with the aggregate function example from the official documentation under different numbers of parameters and found that exceeding 6 parameters would trigger the exception.

The problem may occur in the: https://github.com/trinodb/trino/blob/3c40b19eaccb5dd1da69c6d2ca04e844d7329539/core/trino-main/src/main/java/io/trino/operator/aggregation/AggregationLoopBuilder.java#L87 As this method fills the ClassDefinition and CallSiteBinder objects with too many methods.

image

I have counted the number of methods filled in the ClassDefinition object by aggregate functions with different numbers of parameters:

parameters 1 2 3 4 5 6 7
methods generated 5 11 29 83 245 731 2189

$$ a_{n+1}=3a_n-4 $$

Apologize for my inability to further investigate this issue at my level of expertise. Is this a bug, or is it intended by design? @dain

wendigo commented 2 weeks ago

cc @dain