Why do certain queries take a long time and others finish quickly using the Trino Pinot connector?

This questions was asked on the Trino Slack.

I noticed a weird thing while using trino-pinot. Whenever I execute query 1 it takes a lot of time to execute and whenever I execute query 2 I get the results instantaneously, although both the queries are similar.
Can you please suggest as to why this is happening.

-- query 1
select sum(c1), 'Total' as total
from table_name
where dt >= '20210401' 
and dt <= '20210630' 
group by 'Total';

Query 20210927_114139_00025_hxt48, FINISHED, 3 nodes
Splits: 200 total, 200 done (100.00%)
41.78 [827M rows, 6.16GB] [19.8M rows/s, 151MB/s]


-- query 2 
select sum(c1), 'Total' as total
from table_name
where dt >= '20210401' 
and dt <= '20210630' 
;
Query 20210927_114543_00026_hxt48, FINISHED, 1 node
Splits: 9 total, 9 done (100.00%)
0.70 [1 rows, 9B] [1 rows/s, 13B/s]

Hey there, it looks like this is likely due to aggregation pushdown which is improved in the new version of the connector (pr #8098). The second query doesn’t group by anything so it just sums the entire dataset which it likely uses an pre-aggregated index for. What version of Trino and Pinot do you use?