Repository navigation
[analytics-engine] Fix dc() on short/tinyint fields and DF54 keyword field over-counting - #22299
Conversation
PR Reviewer Guide 🔍(Review updated until commit 3812166)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 3812166 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit c5cae93
Suggestions up to commit 34d0afc
Suggestions up to commit 5bcb413
Suggestions up to commit 2be7e20
Suggestions up to commit 2a55b03
|
|
❌ Gradle check result for 5f2557a: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit bb22ba7 |
|
❌ Gradle check result for bb22ba7: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit 8644aa8 |
|
Persistent review updated to latest commit 9f69501 |
|
Persistent review updated to latest commit 2a55b03 |
|
Persistent review updated to latest commit 2be7e20 |
expani
left a comment
There was a problem hiding this comment.
Thanks for the fix @sandeshkr419 I analyzed DF Physical plan rewrites as well and it seems more hairy because of lack of sufficient extension points.
|
Persistent review updated to latest commit 5bcb413 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22299 +/- ##
============================================
- Coverage 73.38% 73.38% -0.01%
+ Complexity 76071 76063 -8
============================================
Files 6076 6076
Lines 345461 345463 +2
Branches 49723 49724 +1
============================================
- Hits 253527 253517 -10
+ Misses 71731 71723 -8
- Partials 20203 20223 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit 34d0afc |
|
Persistent review updated to latest commit c5cae93 |
Cast TINYINT/SMALLINT to INTEGER before APPROX_COUNT_DISTINCT so DataFusion uses HLL (Binary state) instead of bitmap (List state). Widen derive_schema_from_partial_plan to detect List state types. Signed-off-by: Sandesh Kumar <[email protected]>
…ntIT Register custom approx_distinct UDAF for Utf8View that uses consistent &str hashing, fixing apache/datafusion#21064. Add DistinctCountIT covering all field types on 2-shard clickbench. Signed-off-by: Sandesh Kumar <[email protected]>
Add unit test asserting CAST(SMALLINT→INTEGER) is present in the plan when COUNT(DISTINCT) targets a sub-32-bit column. Add TODOs on approx_distinct_safe.rs for upstream removal timeline. Signed-off-by: Sandesh Kumar <[email protected]>
dc(UserID) grouped by RegionID with sort+head produces non-deterministic results on 2-node clusters due to HLL estimate variance across shards for tied groups. Mute until golden comparison handles tied-row tolerance. Signed-off-by: Sandesh Kumar <[email protected]>
|
Persistent review updated to latest commit 3812166 |
…field over-counting (opensearch-project#22299) * [analytics-engine] Fix dc() on short/tinyint fields Cast TINYINT/SMALLINT to INTEGER before APPROX_COUNT_DISTINCT so DataFusion uses HLL (Binary state) instead of bitmap (List state). Widen derive_schema_from_partial_plan to detect List state types. Signed-off-by: Sandesh Kumar <[email protected]> * [analytics-engine] Fix dc() overcount on keyword fields + DistinctCountIT Register custom approx_distinct UDAF for Utf8View that uses consistent &str hashing, fixing apache/datafusion#21064. Add DistinctCountIT covering all field types on 2-shard clickbench. Signed-off-by: Sandesh Kumar <[email protected]> * [analytics-engine] Add UT for SMALLINT widening + TODOs for upstream fix Add unit test asserting CAST(SMALLINT→INTEGER) is present in the plan when COUNT(DISTINCT) targets a sub-32-bit column. Add TODOs on approx_distinct_safe.rs for upstream removal timeline. Signed-off-by: Sandesh Kumar <[email protected]> * [analytics-engine] Mute flaky PplClickBenchIT Q9/Q10 dc(UserID) grouped by RegionID with sort+head produces non-deterministic results on 2-node clusters due to HLL estimate variance across shards for tied groups. Mute until golden comparison handles tied-row tolerance. Signed-off-by: Sandesh Kumar <[email protected]> --------- Signed-off-by: Sandesh Kumar <[email protected]>
Summary
dc()on TINYINT/SMALLINT: cast to INTEGER beforeAPPROX_COUNT_DISTINCTso DataFusion uses HLL (Binary state) instead of bitmap (List state)dc()overcount on keyword fields: customapprox_distinctUDAF routes Utf8View through consistent&strhashing, avoiding different hashing paths introduced in perf: Optimizeapprox_distinctfor inline Utf8View apache/datafusion#21064DistinctCountIT— 13 tests covering keyword, short, integer, long, filtered, and groupeddc()on a 2-shard clickbench datasetTest Plan
DistinctCountIT— 13/13 passCheck List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Signed-off-by: Sandesh Kumar [email protected]