Skip to content

Commit 3544232

Browse files
mjonssclaude
andcommitted
statistics: update testIssues24349 global b bucket expectation
The combined merge plus the "pick closer cut point" equi-depth builder produces three global b buckets ([1,1] count=2 repeat=2, [1,3] cumulative=7 repeat=4, [4,4] cumulative=8 repeat=1) instead of the old single wide bucket ([1,4] count=8 repeat=1). Both shapes preserve the same total row count (8); the new shape has finer cut points near the equi-depth thresholds (totCount=8 / 3 buckets). Refresh the expected rows and the inline comment to describe the new bucket breakdown and why. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e787dc8 commit 3544232

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

pkg/statistics/handle/globalstats/global_stats_internal_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,23 @@ func testIssues24349(t *testing.T, testKit *testkit.TestKit, store kv.Storage) {
379379
// p1: TopN b=2 count=3. Histogram: [1, 3] count=2, repeat=1. [4, 4] count=repeat=1
380380
// p2: TopN b=1 count=2. No histogram (fully covered by TopN)
381381
//
382-
// Global TopN merge (both separate and combined produce same result):
383-
// b=2 wins with count=4 (p1 TopN=3 + p0 hist upper-bound b=2 repeat=1)
384-
// leftTopN b=3 count=4 (p0 TopN=3 + p1 hist upper-bound b=3 repeat=1),
385-
// b=1 count=2 (p2 TopN=2), b=4 count=1 (p1 hist repeat=1)
386-
// These leftTopN + remaining hist buckets merge into global b: [1, 4] count=8, repeat=1
382+
// Combined global TopN merge: b=2 wins (p1 TopN=3 + p0 hist upper-bound
383+
// repeat=1 = 4). Leftover TopN entries (b=3 count=4 pulling p1 hist
384+
// upper-bound repeat=1, b=1 count=2, b=4 count=1) merge with the
385+
// remaining hist buckets into the global histogram. With 3 expected
386+
// buckets and totCount=8, the equi-depth builder picks cut points near
387+
// cumCount 2, 7, 8, giving three buckets:
388+
// [1,1] count=2 repeat=2 ← leftTopN b=1
389+
// [1,3] count=7 repeat=4 ← b=3 leftTopN + p1 [1,3] hist
390+
// [4,4] count=8 repeat=1 ← p1 [4,4] hist
387391
//
388392
// show stats_buckets format: db table partition col is_index bucket_id count repeats lower upper ndv
389393
testKit.MustQuery("show stats_buckets where table_name='t'").Sort().Check(testkit.Rows(
390394
"test t global a 0 0 4 4 0 0 0", // global a bucket 0: [0, 0] count=4, repeat=4
391395
"test t global a 0 1 6 2 2 2 0", // global a bucket 1: [2, 2] cumulative=6, repeat=2
392-
"test t global b 0 0 8 1 1 4 0", // global b bucket 0: [1, 4] count=8, repeat=1 (merged from leftTopN + hist)
396+
"test t global b 0 0 2 2 1 1 0", // global b bucket 0: [1, 1] count=2, repeat=2
397+
"test t global b 0 1 7 4 1 3 0", // global b bucket 1: [1, 3] cumulative=7, repeat=4
398+
"test t global b 0 2 8 1 4 4 0", // global b bucket 2: [4, 4] cumulative=8, repeat=1
393399
"test t p0 b 0 0 1 1 2 2 0", // p0 hist: [2, 2] count=1, repeat=1
394400
"test t p1 b 0 0 2 1 1 3 0", // p1 hist bucket 0: [1, 3] count=2, repeat=1
395401
"test t p1 b 0 1 3 1 4 4 0", // p1 hist bucket 1: [4, 4] cumulative=3, repeat=1

0 commit comments

Comments
 (0)