Repository navigation
Open
Description
What is the bug?
After #1300 enabled array values in query evaluation and result sets, the engine decomposes arrays into individual scalar elements for operations that should treat the array as a single unit. This causes incorrect results or exceptions across multiple SQL/PPL operations.
Affected operations
| Operation | Symptom | Issue |
|---|---|---|
WHERE comparisons (=, !=, >, >=, <, <=) |
If any element passes, the whole array passes the filter | #3136 |
| ORDER BY | Only the first element is used for comparison | #3133 |
| GROUP BY | Each array element is treated as a separate group key | #3132 |
| MAX/MIN aggregation | Operates on individual elements across all arrays instead of comparing whole arrays | #3138 |
regex command |
Only matches patterns against the first element of an array field | #4461 |
| Calcite eval/arithmetic expressions | ClassCastException: ArrayList cannot be cast to Long — no array handling at all |
#5232 |
How to reproduce
Create an index with array-valued fields:
{"x": 1, "y": [1, 2]}
{"x": 2, "y": [3, 4]}
{"x": 3, "y": [1, 5]}
{"x": 4, "y": [1, 2]}
{"x": 5, "y": [2, 3]}Then run any of the following:
-- WHERE: returns rows where ANY element > 3, not treating array as atomic
SELECT x, y FROM test WHERE y > 3;
-- ORDER BY: sorts by first element only
SELECT x, y FROM test ORDER BY y;
-- GROUP BY: explodes array into individual group keys
SELECT COUNT(x), y FROM test GROUP BY y;
-- MAX/MIN: returns max/min of all individual elements, not max/min array
SELECT MAX(y) FROM test;Expected behavior
Arrays should be treated as indivisible values. Operations on array vs scalar should either:
- Throw an exception (type mismatch), or
- Have well-defined semantics (e.g., element-wise comparison for array vs array)
Root cause
The engine does not distinguish between array values and scalar values at the operator level. When an array is encountered, it is implicitly flattened or only the first element is used, depending on the code path.
Duplicates
This issue consolidates the following duplicates:
- [BUG] GROUP BY does not work properly with array values #3132 — GROUP BY with array values
- [BUG] ORDER BY on array values produces incorrect results #3133 — ORDER BY with array values
- [BUG] Comparison operators only compare the first element for arrays against a scalar value #3136 — Comparison operators with array values
- [BUG] MAX/MIN functions does not work properly with array values #3138 — MAX/MIN with array values
- [BUG]
regexcommand fails to match patterns in array fields beyond first element #4461 — regex matching on array fields - ClassCastException: ArrayList cannot be cast to Long on multi-valued long fields #5232 — ClassCastException on multi-valued long fields
- [BUG] Query workbench PPL 'parse' syntax doesn't work on nested/non-single line field values #3206 — Parse on multi-valued fields
- [BUG] Certain fields are unexpectedly not compatible with patterns command #4365 — Pattern on multi-valued fields
Reacted by Simeon Widdis
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsNot Started
Activity
[-][BUG] Array values are not treated as atomic values in SQL/PPL operations[/-][+][BUG][Umbrella] Array values are not treated as atomic values in SQL/PPL operations[/+]regexcommand fails to match patterns in array fields beyond first element #4461 as a duplicate of this issueSwiddis commentedon Apr 27, 2026
Also found this via dynamic testing (#3220) -- array explosion causes a violation of the invariant that for all Q, F:
Q | stats count() as c=Q | stats count() as cnt by F | stats sum(cnt) as c.