SUM over a union column should skip an undefined slot, not throw ArrayIndexOutOfBoundsException
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start with DenseUnionVector.sumInto and compare it with the guarded per-leg logic in forEachLeaf; also review writeUndefined and the union copiers to understand how type id -1 is preserved. Add a focused unit test alongside the AggregateTest coverage for forEachLeaf, asserting that an undefined slot is treated as NULL by SUM. Done also includes checking whether other per-leg splits in DenseUnionVector have the same gap.
Written by the indexing model from the issue text.
Description
SUM over a union column holding an undefined slot throws ArrayIndexOutOfBoundsException, where it should skip the slot as NULL.
- An undefined slot carries type id -1.
DenseUnionVector.writeUndefined()writes it, and the union's copiers carry it across;isNullreads such a row as NULL (leg(idx)?.isNull(…) ?: true). DenseUnionVector.sumIntosplits the batch's mask per leg withlegMasks[getTypeId(idx).toInt()].add(i), and doesn't check for -1.
So an in-mask undefined slot indexeslegMasks[-1].- #6565's
forEachLeaf(landing with that PR), the same per-leg split formin/maxandbool_and/bool_or, skips a negative type id, with a unit test inAggregateTest.
sumIntois the remaining copy without the guard.
Symptoms
assumption:the exception isArrayIndexOutOfBoundsException: Index -1 out of bounds for length N, thrown fromDenseUnionVector.sumInto— read from the code, not reproduced.assumption:reachable from SQL asSUM(x)over a union column with undefined slots among the rows that reach the aggregate; which query writes such a column is unknown, so done is a unit test onsumInto, as #6565's is onforEachLeaf.COUNTis unaffected:DenseUnionVectordoesn't overridecountInto, and the default goes throughisNull, which handles -1.check:whetherDenseUnionVector's other per-leg splits share the gap.
Expected behaviour
- An undefined slot contributes nothing to
SUM, as a NULL row doesn't.
- Dominant language
- Clojure
- Stars
- 3.1k
- Forks
- 193
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 84
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xtdb/xtdb
-
unshaved-yak
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
sql unshaved-yak
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
flaky
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
metrics
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
.Needs Triage .Team/UXWest Priority:P3 Type:Bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
metabase/metabase#88625 · 1 comment ·
Maintainers usually reply within 1 day
-
clojure easy first-contributor first-contributors good first issue help wanted up-for-grabs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
fork-commit-merge/fork-commit-merge#8749 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
unclebob/uml-viewer#18 ·
-
category:tooling
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day