[CALCITE-7574] RelDecorrelator.isFieldNotNullRecursive throws IndexOutOfBoundsException when decorrelating correlated scalar subquery with Aggregate#4981
Conversation
|
The commit message should not contain "Fix", we also should keep the message same as PR title and JIRA title. |
|
@xiedeyantu Updated as requested. Commit message, PR title, and JIRA summary are now aligned. Also renamed the Fix section to Solution in the description for consistency. Thanks! |
|
The commit message and PR title should using "[CALCITE-7574] xxx" at the beginning. |
|
@xiedeyantu Updated. JIRA summary, PR title, and commit message now all use the [CALCITE-7574] prefix as requested. Thanks for clarifying! |
|
Since there are 2 approvals already I think you can squash the commits for merging |
…tOfBoundsException when decorrelating correlated scalar subquery with Aggregate Root Cause: In isFieldNotNullRecursive, the Aggregate branch used ImmutableBitSet.size() for bounds checking. size() returns the bitset capacity, not the number of group keys. Changed to agg.getGroupCount() which correctly returns the actual number of group keys.
|
@mihaibudiu Squashed the commits into a single clean commit as requested. Ready for merge. Thanks for the review! |
|



Jira Link
CALCITE-7574
Changes Proposed
In
RelDecorrelator.isFieldNotNullRecursive, the Aggregate branch usedImmutableBitSet.size()for bounds checking, which returns the bitset capacity (words.length * 64,typically ≥ 64) rather than the actual number of group keys. When a field index corresponds to an aggregate result field (not a group field), the check was too lenient, causing
groupSet.asList().get(index)to callnth(index)which throwsIndexOutOfBoundsException.Changed
groupSet.size()toagg.getGroupCount()(equivalent togroupSet.cardinality()), which correctly returns the number of group keys. Aggregate result fields nowcorrectly return
falseinstead of throwing an exception.Bug introduced by [CALCITE-6962].
Reproduction