[multistage] order-by on UNION STRING and INT columns somehow is allowed
- 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.1 AS DOUBLE) AS val, 1 AS ord
UNION ALL
SELECT CAST(3.1 AS DOUBLE) AS val, 3 AS ord
)
UNION ALL
SELECT val, ord FROM (
SELECT '2.1' AS val, 2 AS ord
UNION ALL
SELECT '4.1' AS val, 4 AS ord
)
)
ORDER BY val
```
This query should throw an exception as `2.1` and `4.1` should not be allowed to compare directly against a numeric value (explicit cast is required) but somehow Pinot produces wrong result instead of throwing an exception.
Contributor guide
Research direction
Run the supplied SQL query in Pinot and trace how the multistage UNION resolves STRING and numeric column types before ORDER BY comparison. Done means the query rejects the mixed comparison with an exception, while an explicit cast permits the comparison and produces the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 63/100