Skip to content

Commit cb76195

Browse files
craig[bot]Uzair5162
andcommitted
Merge #155107
155107: sql/stats: add partial stats with WHERE clause mixed version logic test r=Uzair5162 a=Uzair5162 This commit adds a mixed version logic test to ensure that partial statistics with a `WHERE` clause can't be collected on clusters not on version 25.4. We added support for partial stats with `WHERE` clauses in #152469 behind a version gate. Part of: #153309 Release note: None Co-authored-by: Uzair Ahmad <[email protected]>
2 parents 0fed78c + ebbba18 commit cb76195

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# LogicTest: cockroach-go-testserver-configs
2+
3+
# Sanity check that partial stats with a WHERE clause can only be collected once
4+
# the cluster is upgraded to 25.4.
5+
6+
statement ok
7+
CREATE TABLE t (a INT, INDEX (a));
8+
9+
statement ok
10+
INSERT INTO t VALUES (1), (2), (3), (4), (5);
11+
12+
statement ok
13+
ANALYZE t;
14+
15+
# Clear the stat cache so that creating partial statistics has access to the
16+
# latest full statistic.
17+
statement ok
18+
SELECT crdb_internal.clear_table_stats_cache();
19+
20+
statement error pq: creating partial statistics with a WHERE clause is not yet supported
21+
CREATE STATISTICS pstat ON a FROM t WHERE a > 2;
22+
23+
upgrade 0
24+
25+
statement error pq: unimplemented: CREATE STATISTICS with a WHERE clause is not supported until v25.4
26+
CREATE STATISTICS pstat ON a FROM t WHERE a > 2;
27+
28+
upgrade 1
29+
30+
statement error pq: unimplemented: CREATE STATISTICS with a WHERE clause is not supported until v25.4
31+
CREATE STATISTICS pstat ON a FROM t WHERE a > 2;
32+
33+
upgrade 2
34+
35+
statement ok
36+
SET CLUSTER SETTING version = crdb_internal.node_executable_version()
37+
38+
statement ok
39+
CREATE STATISTICS pstat ON a FROM t WHERE a > 2;
40+
41+
query TTIIIT colnames
42+
SELECT statistics_name, column_names, row_count, distinct_count, null_count, partial_predicate
43+
FROM [SHOW STATISTICS FOR TABLE t]
44+
WHERE statistics_name = 'pstat'
45+
----
46+
statistics_name column_names row_count distinct_count null_count partial_predicate
47+
pstat {a} 3 3 0 a > 2

pkg/sql/logictest/tests/cockroach-go-testserver-25.2/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ go_test(
1111
"//pkg/sql/logictest:testdata", # keep
1212
],
1313
exec_properties = {"test.Pool": "heavy"},
14-
shard_count = 11,
14+
shard_count = 12,
1515
tags = ["cpu:3"],
1616
deps = [
1717
"//pkg/base",

pkg/sql/logictest/tests/cockroach-go-testserver-25.2/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/sql/logictest/tests/cockroach-go-testserver-25.3/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ go_test(
1111
"//pkg/sql/logictest:testdata", # keep
1212
],
1313
exec_properties = {"test.Pool": "heavy"},
14-
shard_count = 8,
14+
shard_count = 9,
1515
tags = ["cpu:3"],
1616
deps = [
1717
"//pkg/base",

pkg/sql/logictest/tests/cockroach-go-testserver-25.3/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)