Skip to content

Commit

Permalink
Merge #53020
Browse files Browse the repository at this point in the history
53020: logictest: move remaining kv trace assertions to execbuilder tests r=RaduBerinde a=asubiotto

KV trace assertions belong in execbuilder tests. Moving these assertions allows
the tests in question to be run with 3node-tenant.

Release note: None

Closes #49582

Co-authored-by: Alfonso Subiotto Marques <[email protected]>
  • Loading branch information
craig[bot] and asubiotto committed Aug 19, 2020
2 parents 51b0af4 + b6fb4cb commit c5fd3de
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 84 deletions.
73 changes: 0 additions & 73 deletions pkg/sql/logictest/testdata/logic_test/lookup_join
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# LogicTest: !3node-tenant(49582)
statement ok
CREATE TABLE abc (a INT, b INT, c INT, PRIMARY KEY (a, c));
INSERT INTO abc VALUES (1, 1, 2), (2, 1, 1), (2, NULL, 2)
Expand Down Expand Up @@ -579,78 +578,6 @@ SELECT a,b from small WHERE a+b<20 AND EXISTS (SELECT a FROM data WHERE small.a=
5 10
6 12

# The following tests check that if the joiners can separate a row request
# into separate families that it does, and generates spans for each family
# instead of reading the entire row when it doesn't need to.

statement ok
CREATE TABLE family_split_1 (x INT, PRIMARY KEY (x))

statement ok
INSERT INTO family_split_1 VALUES (1)

statement ok
CREATE TABLE family_split_2 (x INT, y INT, z INT, PRIMARY KEY (x), FAMILY f1 (x), FAMILY f2 (y), FAMILY f3 (z))

statement ok
INSERT INTO family_split_2 VALUES (1, 2, 3)

statement ok
SET tracing = on; SELECT family_split_2.x, family_split_2.z FROM family_split_1 INNER LOOKUP JOIN family_split_2 ON family_split_1.x = family_split_2.x; SET tracing = off

query T
SELECT message FROM [SHOW TRACE FOR SESSION] WHERE message LIKE 'Scan /Table/70/1/1/{0-1}, /Table/70/1/1/2/{1-2}'
----
Scan /Table/70/1/1/{0-1}, /Table/70/1/1/2/{1-2}

statement ok
CREATE TABLE family_index_join (x INT PRIMARY KEY, y INT, z INT, w INT, INDEX (y), FAMILY f1 (x), FAMILY f2 (y), FAMILY f3 (z), FAMILY f4(w))

statement ok
INSERT INTO family_index_join VALUES (1, 2, 3, 4)

statement ok
SET tracing = on

query II
SELECT y,w FROM family_index_join@family_index_join_y_idx WHERE y = 2
----
2 4

statement ok
SET tracing = off

query T
SELECT message FROM [SHOW TRACE FOR SESSION] WHERE message LIKE 'Scan /Table/71/1/%'
----
Scan /Table/71/1/1/{0-1/2}, /Table/71/1/1/3/{1-2}

# Test generating tighter spans on interleaved tables.
statement ok
CREATE TABLE family_interleave_1 (x INT, y INT, z INT, PRIMARY KEY (x), FAMILY f1 (x), FAMILY f2 (y), FAMILY f3 (z))

statement ok
CREATE TABLE family_interleave_2 (x INT, y INT, PRIMARY KEY (x, y)) INTERLEAVE IN PARENT family_interleave_1 (x)

statement ok
INSERT INTO family_interleave_1 VALUES (1, 2, 3)

statement ok
INSERT INTO family_interleave_2 VALUES (1, 3)

statement ok
SET TRACING = on

query II
SELECT family_interleave_1.x, family_interleave_1.z FROM family_interleave_2 INNER LOOKUP JOIN family_interleave_1 ON family_interleave_1.x = family_interleave_2.x
----
1 3

query T
SELECT message FROM [SHOW TRACE FOR SESSION] WHERE message LIKE 'Scan /Table/72/1/1/{0-1}, /Table/72/1/1/2/{1-2}'
----
Scan /Table/72/1/1/{0-1}, /Table/72/1/1/2/{1-2}

# Regression test for #50964.
statement ok
CREATE TABLE tab4 (
Expand Down
11 changes: 0 additions & 11 deletions pkg/sql/logictest/testdata/logic_test/select_index
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# LogicTest: !3node-tenant(49582)
statement ok
CREATE TABLE t (
a INT PRIMARY KEY,
Expand Down Expand Up @@ -437,16 +436,6 @@ SET tracing=on, kv; SELECT * FROM noncover WHERE b = 2; SET tracing=off
----
1 2 3 4

# Verify that the index join span created doesn't include any potential child
# interleaved tables. We look only for spans with the primary prefix to avoid
# inconsistency between the fakedist and local test configurations.

query T rowsort
SELECT message FROM [SHOW KV TRACE FOR SESSION]
WHERE message LIKE 'Scan /Table/65/1%'
----
Scan /Table/65/1/1{-/#}

# Subset of output columns, not including tested column.
query II
SELECT a, d FROM noncover WHERE b=2
Expand Down
53 changes: 53 additions & 0 deletions pkg/sql/opt/exec/execbuilder/testdata/lookup_join
Original file line number Diff line number Diff line change
Expand Up @@ -1522,3 +1522,56 @@ project · ·
· estimated row count 10 (missing stats) · ·
· table tab4@tab4_col3_col4_key · ·
· spans /NULL- · ·

# The following tests check that if the joiners can separate a row request
# into separate families that it does, and generates spans for each family
# instead of reading the entire row when it doesn't need to.

statement ok
CREATE TABLE family_split_1 (x INT, PRIMARY KEY (x))

statement ok
INSERT INTO family_split_1 VALUES (1)

statement ok
CREATE TABLE family_split_2 (x INT, y INT, z INT, PRIMARY KEY (x), FAMILY f1 (x), FAMILY f2 (y), FAMILY f3 (z))

statement ok
INSERT INTO family_split_2 VALUES (1, 2, 3)

query T kvtrace(Scan)
SELECT family_split_2.x, family_split_2.z FROM family_split_1 INNER LOOKUP JOIN family_split_2 ON family_split_1.x = family_split_2.x; SET tracing = off
----
Scan /Table/74/{1-2}
Scan /Table/75/1/1/{0-1}, /Table/75/1/1/2/{1-2}

statement ok
CREATE TABLE family_index_join (x INT PRIMARY KEY, y INT, z INT, w INT, INDEX (y), FAMILY f1 (x), FAMILY f2 (y), FAMILY f3 (z), FAMILY f4(w))

statement ok
INSERT INTO family_index_join VALUES (1, 2, 3, 4)

query T kvtrace(Scan)
SELECT y,w FROM family_index_join@family_index_join_y_idx WHERE y = 2
----
Scan /Table/76/2/{2-3}
Scan /Table/76/1/1/{0-1/2}, /Table/76/1/1/3/{1-2}

# Test generating tighter spans on interleaved tables.
statement ok
CREATE TABLE family_interleave_1 (x INT, y INT, z INT, PRIMARY KEY (x), FAMILY f1 (x), FAMILY f2 (y), FAMILY f3 (z))

statement ok
CREATE TABLE family_interleave_2 (x INT, y INT, PRIMARY KEY (x, y)) INTERLEAVE IN PARENT family_interleave_1 (x)

statement ok
INSERT INTO family_interleave_1 VALUES (1, 2, 3)

statement ok
INSERT INTO family_interleave_2 VALUES (1, 3)

query T kvtrace(Scan)
SELECT family_interleave_1.x, family_interleave_1.z FROM family_interleave_2 INNER LOOKUP JOIN family_interleave_1 ON family_interleave_1.x = family_interleave_2.x
----
Scan /Table/77/{1-2}
Scan /Table/77/1/1/{0-1}, /Table/77/1/1/2/{1-2}
8 changes: 8 additions & 0 deletions pkg/sql/opt/exec/execbuilder/testdata/select_index
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,14 @@ fetched: /noncover/primary/1/c -> 3
fetched: /noncover/primary/1/d -> 4
output row: [1 2 3 4]

# Verify that the index join span created doesn't include any potential child
# interleaved tables.
query T rowsort
SELECT message FROM [SHOW KV TRACE FOR SESSION]
WHERE message LIKE 'Scan /Table/67/1%'
----
Scan /Table/67/1/1{-/#}

query TTT
EXPLAIN SELECT * FROM noncover WHERE c = 6
----
Expand Down

0 comments on commit c5fd3de

Please sign in to comment.