diff --git a/pkg/sql/opt/exec/execbuilder/testdata/partial_index b/pkg/sql/opt/exec/execbuilder/testdata/partial_index index 0e2bb9219aa7..d0fcceb19af2 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/partial_index +++ b/pkg/sql/opt/exec/execbuilder/testdata/partial_index @@ -1,5 +1,81 @@ # LogicTest: local +statement ok +CREATE TABLE t ( + a INT PRIMARY KEY, + b INT, + c STRING, + FAMILY (a, b, c), + INDEX b_partial (b) WHERE b > 10 +) + +statement ok +CREATE TABLE inv ( + a INT PRIMARY KEY, + b JSON, + c STRING, + INVERTED INDEX i (b) WHERE c IN ('foo', 'bar'), + FAMILY (a, b, c) +) + +# --------------------------------------------------------- +# EXPLAIN +# --------------------------------------------------------- + +# EXPLAIN output shows the partial index label on scans over partial indexes. +query T +EXPLAIN SELECT b FROM t WHERE b > 10 +---- +distribution: local +vectorized: true +· +• scan + missing stats + table: t@b_partial (partial index) + spans: FULL SCAN + +query T +EXPLAIN SELECT a FROM inv@i WHERE b @> '{"x": "y"}' AND c IN ('foo', 'bar') +---- +distribution: local +vectorized: true +· +• scan + missing stats + table: inv@i (partial index) + spans: 1 span + +query T +EXPLAIN SELECT a FROM inv@i WHERE b @> '{"x": "y"}' AND c = 'foo' +---- +distribution: local +vectorized: true +· +• filter +│ filter: c = 'foo' +│ +└── • index join + │ table: inv@primary + │ + └── • scan + missing stats + table: inv@i (partial index) + spans: 1 span + +query T +EXPLAIN SELECT * FROM inv@i WHERE b @> '{"x": "y"}' AND c IN ('foo', 'bar') +---- +distribution: local +vectorized: true +· +• index join +│ table: inv@primary +│ +└── • scan + missing stats + table: inv@i (partial index) + spans: 1 span + # --------------------------------------------------------- # JOIN # --------------------------------------------------------- diff --git a/pkg/sql/opt/exec/execbuilder/testdata/partial_index_nonmetamorphic b/pkg/sql/opt/exec/execbuilder/testdata/partial_index_nonmetamorphic index 83bb297e4512..e45575fce18a 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/partial_index_nonmetamorphic +++ b/pkg/sql/opt/exec/execbuilder/testdata/partial_index_nonmetamorphic @@ -882,64 +882,6 @@ UPSERT INTO inv VALUES (6, '{"x": "y", "num": 8}', 'baz') Scan /Table/55/1/6{-/#} CPut /Table/55/1/6/0 -> /TUPLE/ -# --------------------------------------------------------- -# EXPLAIN -# --------------------------------------------------------- - -# EXPLAIN output shows the partial index label on scans over partial indexes. -query T -EXPLAIN SELECT b FROM t WHERE b > 10 ----- -distribution: local -vectorized: true -· -• scan - missing stats - table: t@b_partial (partial index) - spans: FULL SCAN - -query T -EXPLAIN SELECT a FROM inv@i WHERE b @> '{"x": "y"}' AND c IN ('foo', 'bar') ----- -distribution: local -vectorized: true -· -• scan - missing stats - table: inv@i (partial index) - spans: 1 span - -query T -EXPLAIN SELECT a FROM inv@i WHERE b @> '{"x": "y"}' AND c = 'foo' ----- -distribution: local -vectorized: true -· -• filter -│ filter: c = 'foo' -│ -└── • index join - │ table: inv@primary - │ - └── • scan - missing stats - table: inv@i (partial index) - spans: 1 span - -query T -EXPLAIN SELECT * FROM inv@i WHERE b @> '{"x": "y"}' AND c IN ('foo', 'bar') ----- -distribution: local -vectorized: true -· -• index join -│ table: inv@primary -│ -└── • scan - missing stats - table: inv@i (partial index) - spans: 1 span - # Regression test for #57085. Cascading DELETEs should not issue DEL operations # for partial indexes of a child table when the deleted row was not in the # partial index.