[analytics-engine] Fix CHECKED_LONG_SUM conversion - #22611
Conversation
PR Reviewer Guide 🔍(Review updated until commit 7ebc621)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 7ebc621 Explore these optional code suggestions:
Suggestions up to commit af8fb51
Suggestions up to commit e7f94f6
Suggestions up to commit 0416b8d
Suggestions up to commit d0cc903
|
Signed-off-by: Kai Huang <ahkcs@amazon.com>
dba238c to
2d8457e
Compare
|
Persistent review updated to latest commit 2d8457e |
|
Persistent review updated to latest commit b798c51 |
|
❌ Gradle check result for b798c51: 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 6d8cc59 |
Signed-off-by: Kai Huang <ahkcs@amazon.com>
6d8cc59 to
a01e3bd
Compare
|
Persistent review updated to latest commit a01e3bd |
|
❌ Gradle check result for a01e3bd: 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? |
Signed-off-by: Kai Huang <ahkcs@amazon.com>
|
Persistent review updated to latest commit d0cc903 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22611 +/- ##
============================================
- Coverage 71.55% 71.49% -0.07%
+ Complexity 77036 76984 -52
============================================
Files 6156 6156
Lines 358413 358413
Branches 52243 52243
============================================
- Hits 256476 256247 -229
- Misses 81581 81776 +195
- Partials 20356 20390 +34 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Thanks @ahkcs for working on this. I have an alternative proposal which I suspect should simplify the changes.
The operator rewrite should belong in the RBO planner layer (a new OpenSearchCheckedLongSumRule modeled on OpenSearchDistinctCountRule), not inside DataFusionFragmentConvertor. Moving it earlier, i.e., before OpenSearchAggregateRule runs means the entire stack sees SqlStdOperatorTable.SUM by operator identity: AggregateSplitRule, TopK, the Lucene backend, and Isthmus all resolve it correctly without any special-casing.
The custom LOCAL_CHECKED_LONG_SUM_OP, YAML bindings, and checked_long_sum.rs Rust UDAF are only needed in this PR because the current rewrite happens too late (inside the fragment convertor, after Isthmus dispatch). With an early planner rewrite, DataFusion receives sum in the Substrait proto and resolves to its own native sum_udaf — the delegation wrapper in checked_long_sum.rs is pure boilerplate with zero custom logic and could be deleted entirely.
Signed-off-by: Kai Huang <ahkcs@amazon.com>
|
Persistent review updated to latest commit 0416b8d |
|
Persistent review updated to latest commit f98b766 |
|
The I reproduced the failure with seed |
|
|
Persistent review updated to latest commit e7f94f6 |
|
|
Persistent review updated to latest commit af8fb51 |
|
Persistent review updated to latest commit 47401b0 |
|
This is more reason for us to remove this hacky circular dependency on sql plugin. Ideally these rules would be registered with us or applied entirely in sql side before we receive the relNode, that is validated against what AE can support. I suggest we take this to unblock our sandbox check and other changes, and then aggressively refactor this dependency. |
sandeshkr419
left a comment
There was a problem hiding this comment.
Thanks @ahkcs for working on this. This looks super neat now with the logic moved to planing side.
|
Persistent review updated to latest commit 7ebc621 |
Description
SQL PR opensearch-project/sql#5612 introduced the reflective
CHECKED_LONG_SUMaggregate. Isthmus resolves Substrait functions by exact Calcite operator identity, so the analytics path could not bind that marker directly.This change canonicalizes aggregate and window forms of
CHECKED_LONG_SUMtoSqlStdOperatorTable.SUMin the RBO planner, beforeOpenSearchAggregateRuleruns. Aggregate splitting, TopK, Lucene, Isthmus, and DataFusion therefore all see nativeSUM. When Calcite's logical return type differs, a result projection restores the originalBIGINTschema after aggregation.The earlier local operator, Substrait YAML bindings, and delegating Rust UDAF are removed. DataFusion resolves the standard Substrait function to its native
sum_udaf.Testing
AggregatePlanShapeTestsandWindowPlanShapeTestsDataFusionFragmentConvertorTestsStatsCommandIT.testStatsIntegralSumprecommitcargo fmt --all --check