fix: ensure new_list respects data_type argument - #24029
Conversation
|
@Ruchirtripathi Thanks for the contribution! Can you take a look at the test failures, please? |
6bfdcf2 to
55e5063
Compare
…chema in array_agg accumulators
55e5063 to
1239b46
Compare
|
Hi! I've pushed a new commit that resolves the CI errors while maintaining the strict contract for #24022. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24029 +/- ##
==========================================
- Coverage 80.86% 80.85% -0.01%
==========================================
Files 1101 1101
Lines 375446 375466 +20
Branches 375446 375466 +20
==========================================
- Hits 303598 303597 -1
- Misses 53758 53775 +17
- Partials 18090 18094 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kosiew
left a comment
There was a problem hiding this comment.
Thanks for working on this. The constructor normalization looks like the right direction, but the DISTINCT and ordered ARRAY_AGG paths are still deriving their output types from runtime values. That can cause nested field nullability to differ from the aggregate's declared return and state schema.
I have left two blocking comments where the declared element types should continue to be used, along with a non-blocking suggestion to broaden the constructor regression coverage.
|
Thanks for the detailed feedback! I've gone ahead and addressed all the requested changes:
Let me know if there's anything else you'd like me to tweak @kosiew |
kosiew
left a comment
There was a problem hiding this comment.
@Ruchirtripathi, thanks for the follow-up. The declared element types are now restored in both the DISTINCT and ordered ARRAY_AGG evaluation paths, and the new ordered aggregate regression looks good.
There is still one blocking gap: the DISTINCT accumulator path does not have equivalent nested-nullability regression coverage. Since this was the path where decoding could preserve different nested nullability, please add a test using a declared nullable struct field and a runtime non-nullable struct field. The test should assert the exact resulting list type and values.
I also left a non-blocking suggestion to expand the list constructor regression across all three constructors changed by this PR.
The targeted tests listed in the review passed, and I did not find any other correctness issues in the follow-up changes.
| Arc::new(Int32Array::from(vec![1])) as ArrayRef, | ||
| )]))); | ||
|
|
||
| let list = ScalarValue::new_list(&[value], &requested_element_type, true); |
There was a problem hiding this comment.
Could we extend this regression to cover all three constructors changed by this PR?
Right now it only calls new_list and checks list.data_type(). A shared assertion for new_list, new_list_from_iter, and new_large_list would also let us verify both the declared nested child type and the normalized child values.
This is a suggestion only.
| } | ||
|
|
||
| #[test] | ||
| fn ordered_aggregate_nested_nullability_mismatch_issue_24022() -> Result<()> { |
There was a problem hiding this comment.
Thanks for adding the ordered aggregate regression. Could you also add equivalent coverage for DistinctArrayAggAccumulator::evaluate?
Please use a declared struct type with a nullable field and runtime values whose struct field is non-nullable, then assert both the exact resulting list type and the values. This is the remaining blocking item because the DISTINCT decoding path can preserve different nested nullability.
There was a problem hiding this comment.
Thanks for the detailed review! That makes sense. I'll add an equivalent regression for DistinctArrayAggAccumulator::evaluate using a declared struct type with a nullable field and runtime values whose struct field is non-nullable. I'll assert both the exact resulting list type and the values to cover the nested nullability preservation in the DISTINCT decoding path, then update the PR.
|
Hey! @kosiew Just pushed the latest changes. I've added the missing nested-nullability regression test for the DISTINCT accumulator just like you asked. I set up a declared nullable struct field, As for the list constructor regressions for Could you take a quick look and let me know if everything looks good to go now? Thanks again for the help! |
Which issue does this PR close?
Rationale for this change
Fixes a bug where
ScalarValue::new_list,new_list_nullable, andnew_large_listsilently ignored thedata_typeargument when thevaluesarray was non-empty. This caused issues where accumulators likecollect_listcould produce outputs with a slightly different type than declared (e.g., in the nullability ofnested fields), leading to invalid argument errors in
GroupedHashAggregateStream::emit.What changes are included in this PR?
cast_with_optionscall for non-empty lists inScalarValue::new_list,new_list_from_iter, andnew_large_list.DEFAULT_CAST_OPTIONSto ensure the concatenated array is properly reconciled with the requesteddata_type.Are these changes tested?
Yes, this is covered by existing tests. It resolves the
GroupedHashAggregateStreamoutput batch validationfailures for accumulators.
Are there any user-facing changes?
No, this is an internal bug fix.