Fix flaky PARTIAL/FINAL plan assertion in rateFunctionsNormalTest - #18556
Merged
Conversation
assertRateQueryUsesIntermediateAggregation unconditionally required a PARTIAL/FINAL aggregation split in the EXPLAIN output. Under randomized data partition allocation (the SHUFFLE strategy used by IoTDBTableAggregation2IT), all 8 devices of rate_merge_test may occasionally land in a single DataRegion, where a SINGLE-step aggregation is the correct plan, so the assertion failed sporadically. Skip the PARTIAL/FINAL check when the plan scans fewer than two distinct RegionIds; keep it whenever the data actually spans regions.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18556 +/- ##
============================================
- Coverage 42.34% 42.33% -0.01%
Complexity 413 413
============================================
Files 5411 5411
Lines 390231 390231
Branches 51071 51071
============================================
- Hits 165233 165221 -12
- Misses 224998 225010 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
IoTDBTableAggregation2IT.rateFunctionsNormalTest(inherited fromIoTDBTableAggregationIT) fails sporadically:Root cause
assertRateQueryUsesIntermediateAggregationunconditionally requires theEXPLAIN (FORMAT JSON)output of an ungroupedrate()/increase()/irate()/delta()query overrate_merge_testto contain aPARTIAL/FINALtwo-step aggregation. That split only exists when the scanned data spans more than one DataRegion.IoTDBTableAggregation2ITruns withdata_partition_allocation_strategy = SHUFFLE.PartitionBalancer.shuffleAllocationStrategyassigns each (seriesSlot, timeSlot) to a random DataRegionGroup, and all 8 rows ofrate_merge_testfall into one time partition. So occasionally all 8 devices land in the same DataRegion; the planner then correctly produces aSINGLE-step aggregation with oneDeviceTableScanNode, and the assertion fails even though both the plan and the query result are correct (the result comparison right before the assertion had already passed).Fix
Count the distinct
RegionIdvalues in the JSON plan first. Skip thePARTIAL/FINALcheck when the plan scans fewer than two distinct regions (aSINGLEaggregation is the correct plan there), and keep asserting it whenever the data actually spans multiple regions — which preserves the original intent of the check in the deterministic base-class environment (CUSTOMextension policy with 2 DataRegions per DataNode).Verification
IoTDBTableAggregationIT#rateFunctionsNormalTestandIoTDBTableAggregation2IT#rateFunctionsNormalTestpass locally (TableSimpleIT)."RegionId": "Not Assigned"(count 0 → skip).🤖 Generated with Claude Code