Skip to content

Commit

Permalink
opt: move execbuilder partial index EXPLAIN tests to metamorphic file
Browse files Browse the repository at this point in the history
These tests do not show traces so they do not need to live in a
non-metamorphic test file.

Release note: None
  • Loading branch information
mgartner committed Dec 23, 2020
1 parent 9115165 commit 86949e1
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 58 deletions.
76 changes: 76 additions & 0 deletions pkg/sql/opt/exec/execbuilder/testdata/partial_index
Original file line number Diff line number Diff line change
@@ -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
# ---------------------------------------------------------
Expand Down
58 changes: 0 additions & 58 deletions pkg/sql/opt/exec/execbuilder/testdata/partial_index_nonmetamorphic
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 86949e1

Please sign in to comment.