gortiz commented on PR #19554:
URL: https://github.com/apache/pinot/pull/19554#issuecomment-5678135879
They should return `Madrid` — that's the multi-stage column in the table,
and the multi-stage engine is right.
DISTINCT + WHERE was my first implementation, and it is correct for a
single-valued grouping column. It is silently wrong for a multi-valued one.
With two rows, `tags = {1, 9}` and `tags = {2}`:
| query | result |
|---|---|
| `SELECT tags FROM t GROUP BY tags` | `9, 1, 2` — one group per value |
| `SELECT tags, COUNT(*) FROM t GROUP BY tags HAVING tags > 5` | `9, 2` —
correct |
| `SELECT DISTINCT tags FROM t WHERE tags > 5` | `9, 1` — leaks `1` |
WHERE keeps the whole row because one of its values matches, and DISTINCT
then emits every value of that row, so `1` comes back even though the predicate
excludes it. GROUP BY builds one group per value, so it never does.
`NonAggregationGroupByToDistinctQueryRewriter` runs before any schema is
available, so it cannot tell the two cases apart — hence rejecting rather than
guessing. These queries were returning wrong rows before this PR, not right
ones, so the error is not taking away anything that worked.
If you would rather have the rewrite, the clean way is to do it somewhere
with schema access and gate it on `isSingleValue()`. Happy to do that here or
as a follow-up — your call.
--
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]