gortiz opened a new issue, #20294:
URL: https://github.com/apache/pinot/issues/20294

   In the multi-stage engine, `ARRAY_TO_MV(col)` has the type of the array 
component, and that type is NOT NULL also when the multi-value column is 
nullable. Calcite then simplifies null checks around it, so some filters and 
group keys on a nullable MV column give wrong results when the query runs in 
the leaf stage. Null handling must be on to see it.
   
   With a table where `strMv` is a nullable MV column and one row has a null 
`strMv`:
   
   | Query | Result | Correct result |
   |---|---|---|
   | `SELECT COUNT(*) FROM t WHERE ARRAY_TO_MV(strMv) IS NOT NULL` | Every row: 
the predicate is folded to `TRUE` | The rows with a non-null `strMv` |
   | `SELECT COUNT(*) FROM t WHERE COALESCE(ARRAY_TO_MV(strMv), 'x') = 'x'` | 
0: `COALESCE` is removed | The null row |
   | `SELECT COALESCE(ARRAY_TO_MV(strMv), 'none'), COUNT(*) FROM t GROUP BY 1` 
| The group `null`: `COALESCE` is removed | The group `none` |
   
   [apache/pinot#20293](https://github.com/apache/pinot/pull/20293) keeps this 
behavior on purpose for queries that plan today, so that it does not change 
their results. That PR gives `ARRAY_TO_MV` a nullable type only in the plan 
with the MV aggregate, which a query gets only when it fails without it. So 
today the same expression can give a different result when a join is added to a 
query. A fix here needs to make the type nullable for every plan, and to decide 
how the leaf stage runs `COALESCE` and `IS NULL` on a multi-value column.
   


-- 
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]

Reply via email to