gortiz opened a new issue, #20295: URL: https://github.com/apache/pinot/issues/20295
In the multi-stage engine, a condition on an `ARRAY_TO_MV` group key, in `HAVING` or in an outer query, can return the groups of other elements of the matching rows. ```sql SELECT ARRAY_TO_MV(tags), COUNT(*) FROM t GROUP BY ARRAY_TO_MV(tags) HAVING ARRAY_TO_MV(tags) = 'vip' ``` If a row has `tags = ['vip', 'urgent']`, the result also has the group `urgent`. The correct result has only `vip`. `FilterAggregateTransposeRule` moves the condition below the aggregate, into the leaf stage. There it becomes a multi-value predicate, which keeps the whole row when any element matches. The aggregate then groups the row by each of its elements. The same occurs for an outer filter on the key (`SELECT * FROM (... GROUP BY ARRAY_TO_MV(tags)) WHERE k = 'vip'`), and for `IN`, ranges and `<>`. [apache/pinot#20293](https://github.com/apache/pinot/pull/20293) keeps such a condition above the aggregate only in the plan with the MV aggregate, which a query gets only when it fails without it. For a query that runs in the leaf stage today, it keeps the current result, so that it does not change the results or the speed of queries that work today. A fix here changes both: above the aggregate, the leaf stage aggregates every row. Copying a positive condition below the aggregate as a pre-filter keeps the leaf work close to today. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
