Fix LIST/VALUES aggregate type-mismatch - #21997
Conversation
PR Reviewer Guide 🔍(Review updated until commit 97ca5f2)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to c8a8250 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 311b3e8
Suggestions up to commit d486638
Suggestions up to commit 5f0b3be
Suggestions up to commit 71fe3f4
Suggestions up to commit 9713eda
|
9713eda to
b68dc61
Compare
|
Persistent review updated to latest commit b68dc61 |
|
Persistent review updated to latest commit 71fe3f4 |
71fe3f4 to
5f0b3be
Compare
|
Persistent review updated to latest commit 5f0b3be |
5f0b3be to
d486638
Compare
|
Persistent review updated to latest commit d486638 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21997 +/- ##
============================================
+ Coverage 73.45% 73.48% +0.03%
- Complexity 75554 75591 +37
============================================
Files 6037 6038 +1
Lines 342795 342820 +25
Branches 49313 49314 +1
============================================
+ Hits 251797 251935 +138
+ Misses 71034 70863 -171
- Partials 19964 20022 +58 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit 311b3e8 |
311b3e8 to
c8a8250
Compare
|
Persistent review updated to latest commit c8a8250 |
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
Insert a Project above each Aggregate that has LIST/VALUES calls with non-VARCHAR scalar operands. IpType is routed to ip_to_string and BinaryType to binary_to_base64; other types get a plain CAST to VARCHAR. The aggregator then produces ARRAY<VARCHAR>, so byte[] elements never reach the response boundary and stop tripping "unsupported object class [B" on list(ip_value) / list(binary_value). Add ListAggregateMultiTypeIT covering all 13 supported scalar types, and fix an unrelated pre-existing spotless violation in ToStringFunctionAdapter that the targeted spotless run surfaced. Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
c8a8250 to
97ca5f2
Compare
|
Persistent review updated to latest commit 97ca5f2 |
* Fix LIST/VALUES aggregate type-mismatch Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com> * Added Integ tests Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com> * Render IP/binary list/values aggregate results as canonical strings Insert a Project above each Aggregate that has LIST/VALUES calls with non-VARCHAR scalar operands. IpType is routed to ip_to_string and BinaryType to binary_to_base64; other types get a plain CAST to VARCHAR. The aggregator then produces ARRAY<VARCHAR>, so byte[] elements never reach the response boundary and stop tripping "unsupported object class [B" on list(ip_value) / list(binary_value). Add ListAggregateMultiTypeIT covering all 13 supported scalar types, and fix an unrelated pre-existing spotless violation in ToStringFunctionAdapter that the targeted spotless run surfaced. Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com> * fix tests Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com> --------- Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
Description
Fixes two bugs that combined to make
stats list(<field>)/stats values(<field>)unusable on the analytics-engine path:AssertionErrorfor every element type (31 failures inCalciteMultiValueStatsIT).unsupported object class [Bspecifically forlist(ip_value)/list(binary_value)(and thevalues()equivalents).Bug 1 — nullability mismatch
PplAggregateCallRewriterbuiltexplicitReturnTypefor LIST/VALUES viacreateArrayType(elemType, -1)— the 2-arg overload defaults to NOT NULL.LOCAL_ARRAY_AGG_OP'sinferReturnTypeisTO_ARRAY.andThen(FORCE_NULLABLE)— nullable. Calcite'sAggregate.typeMatchesInferredasserted on the mismatch.Fix: build the explicit return type with
createTypeWithNullability(arrayType, true)so it aligns with the operator's inference. Aggregate output is inherently nullable on empty input, so this matches the semantics too.Bug 2 —
byte[]rendering for IP / binary list elementsAfter bug 1 was fixed, IP/binary list queries returned HTTP 400
unsupported object class [B.LIST/VALUESare registered withSTRING_ARRAYreturn type, but DataFusion'sarray_aggon anIpType/BinaryTypecolumn accumulates rawbyte[]payloads — which the SQL plugin's response converter cannot render.Fix: insert a
LogicalProjectabove the aggregate that lifts every non-VARCHAR scalar operand of a LIST/VALUES call into a VARCHAR column.IpTyperoutes to the existingip_to_stringRust UDF,BinaryTypetobinary_to_base64, other types use a plainCAST(... AS VARCHAR). The aggregator then producesARRAY<VARCHAR>, so byte[] elements never reach the response boundary.Direct UDF dispatch (rather than a plain CAST for IP/binary):
IpBinaryCastFunctionAdapterruns in an earlier pass, so a CAST emitted at this stage would fall through to DataFusion's Latin-1 cast kernel and corrupt the bytes.Testing
Verified locally on Variant B (parquet+lucene+SQL plugin,
plugins.calcite.enabled=true):ARRAY<VARCHAR>["127.0.0.1"]["U29tZSBiaW5hcnkgYmxvYg=="]ListAggregateMultiTypeIT(new) covers all 13 supported scalar types end-to-end. The 31CalciteMultiValueStatsITcases this category covers also pass.