apache / apache/pinot

[multistage] UNION queries produces wrong sorting results

Open
#11,878 3 comments 0 reactions 0 assignees View on GitHub
bug multi-stage stale
Dominant language
Java
Stars
6.1k
Forks
1.5k
Avg merge
1d 21h
Merged PRs (30d)
189

Description

```
SELECT val FROM (
SELECT val, ord FROM (
SELECT CAST(1 AS INT) AS val, 1 AS ord
UNION ALL
SELECT CAST(3 AS INT) AS val, 3 AS ord
)
UNION ALL
SELECT val, ord FROM (
SELECT CAST(2.1 AS DOUBLE) AS val, 2 AS ord
UNION ALL
SELECT CAST(4.1 AS DOUBLE) AS val, 4 AS ord
)
)
ORDER BY ord
```
throws exception in final order-by comparison b/c of different data type (using either both DOUBLE or both INT are fine.

Contributor guide

Open the contributing guide

Research direction

Start by running the SQL reproducer and tracing the multistage UNION handling through the final ORDER BY comparison. Investigate why mixed INT and DOUBLE values cause the comparison to fail, then verify that the query sorts by ord without an exception while the existing same-type cases continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.