yashmayya commented on PR #20293: URL: https://github.com/apache/pinot/pull/20293#issuecomment-6997453705
I took over this PR from gortiz (we agreed offline). Two changes are pushed. **1. The blocker from my review (`b52286e64f`)** A plain `GROUP BY mvCol` that plans on master plans again. For a plan with no MV aggregate, the check of array-typed group keys is the check of master, with no change. Plan tests pin the shapes from the review for the default planner, the physical optimizer and lite mode. The branch also has a merge of master. **2. One plan instead of two (`8138fe3082`)** The first version planned each query as master does, and planned it again with the MV aggregate only when the first plan failed. That kept every query of master unchanged, but the cost was high: - a copy of the parsed query (`SqlNodeCopier`) and a second operator table - a second pass over the plan fragments in `compile`, which also counted the join and window meters two times - different null semantics of `ARRAY_TO_MV` in the two plans Now the planner makes one plan: - An aggregate that reads a table scan keeps the plain plan of master, so old servers can run it. - Every other `GROUP BY ARRAY_TO_MV` is an MV aggregate. - `ARRAY_TO_MV` is nullable when the array is nullable. It stays above a join, and a filter on an MV key stays above the aggregate. This removes about 320 lines of main code. `QueryEnvironment`, `PlannerContext`, `PinotRuleUtils`, `PinotConvertletTable` and `CalciteRexExpressionParser` have no diff from master now. The price is that some queries that work on master change. The description has the full table. In short: - `HAVING` on the MV key returns only the matching group (#20295). - A null check on a nullable MV column is not folded (#20294). A `COALESCE` around it fails when the query runs. - `GROUP BY ARRAY_TO_MV` with an `IN (subquery)` semi-join gets the MV aggregate. It returns the same rows, but it fails on old servers during a rolling upgrade. The first two are known bugs of master, and I do not expect the other patterns in production queries. Tell me if you know a user of one of them. **What I checked** I compared master with this branch on about 1,640 planner queries (default planner, physical optimizer, lite mode, null handling on and off). No query without `ARRAY_TO_MV` changes its plan. The queries that change are only in the groups above. The planner tests, the runtime tests and `MultiStageEngineIntegrationTest` pass locally. **Still open from my review** - The type error in `PinotLogicalMvAggregate` for some outer-join shapes. - The `SqlNodeCopier` comment is obsolete: the class is gone. -- 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]
