Skip to content

Commit

Permalink
opt: add partition info to the opt catalog
Browse files Browse the repository at this point in the history
Prior to this commit, the opt catalog did not include zone information
or prefixes specific to each partition of an index. This commit adds this
information since it will be necessary to support locality optimized
search in a future commit.

Informs #55185

Release note: None
  • Loading branch information
rytaft committed Feb 19, 2021
1 parent 06486c9 commit 9678713
Show file tree
Hide file tree
Showing 14 changed files with 808 additions and 193 deletions.
83 changes: 61 additions & 22 deletions pkg/ccl/logictestccl/testdata/logic_test/partitioning
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,13 @@ TABLE ok1
└── PRIMARY INDEX primary
├── a int not null
├── b int not null
└── partition by list prefixes
├── (1)
└── (2)
└── partitions
├── p1
│ └── partition by list prefixes
│ └── (1)
└── p2
└── partition by list prefixes
└── (2)
scan ok1

statement ok
Expand Down Expand Up @@ -472,9 +476,13 @@ TABLE ok2
└── PRIMARY INDEX primary
├── a int not null
├── b int not null
└── partition by list prefixes
├── (1)
└── (2)
└── partitions
├── p1
│ └── partition by list prefixes
│ └── (1)
└── p2
└── partition by list prefixes
└── (2)
scan ok2

statement ok
Expand Down Expand Up @@ -516,8 +524,13 @@ TABLE ok3
└── PRIMARY INDEX primary
├── a int not null
├── b int not null
└── partition by list prefixes
└── (1)
└── partitions
├── p1
│ └── partition by list prefixes
│ └── (1)
└── p2
└── partition by list prefixes
└── ()
scan ok3

statement ok
Expand Down Expand Up @@ -563,10 +576,19 @@ TABLE ok4
└── PRIMARY INDEX primary
├── a int not null
├── b int not null
└── partition by list prefixes
├── (1, 1)
├── (1)
└── (2, 3)
└── partitions
├── p1
│ └── partition by list prefixes
│ └── (1, 1)
├── p2
│ └── partition by list prefixes
│ └── (1)
├── p3
│ └── partition by list prefixes
│ └── (2, 3)
└── p4
└── partition by list prefixes
└── ()
scan ok4

statement ok
Expand Down Expand Up @@ -603,9 +625,16 @@ TABLE ok5
└── PRIMARY INDEX primary
├── a int not null
├── b int not null
└── partition by list prefixes
├── (1)
└── (2)
└── partitions
├── p1
│ └── partition by list prefixes
│ └── (1)
├── p2
│ └── partition by list prefixes
│ └── (2)
└── p3
└── partition by list prefixes
└── ()
scan ok5

query TT
Expand Down Expand Up @@ -897,9 +926,13 @@ TABLE ok11
├── a int not null
├── b int not null
├── c int not null
└── partition by list prefixes
├── (1)
└── (6)
└── partitions
├── p1
│ └── partition by list prefixes
│ └── (1)
└── p2
└── partition by list prefixes
└── (6)
scan ok11

statement ok
Expand Down Expand Up @@ -943,10 +976,16 @@ TABLE ok12
└── PRIMARY INDEX primary
├── a int not null
├── b int not null
└── partition by list prefixes
├── (NULL)
├── (1)
└── (2)
└── partitions
├── pu
│ └── partition by list prefixes
│ └── (NULL)
├── p1
│ └── partition by list prefixes
│ └── (1)
└── p2
└── partition by list prefixes
└── (2)
scan ok12

# Verify that creating a partition that includes NULL does not change the
Expand Down
67 changes: 67 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/partitioning_implicit
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,73 @@ CREATE TABLE public.t (
)
-- Warning: Partitioned table with no zone configurations.

query T
EXPLAIN (OPT, CATALOG) SELECT * FROM t
----
TABLE t
├── pk int not null
├── a int not null
├── b int
├── c int
├── d int
├── j jsonb
├── crdb_internal_mvcc_timestamp decimal [hidden] [system]
├── tableoid oid [hidden] [system]
├── j_inverted_key bytes not null [virtual-inverted]
├── FAMILY fam_0_pk_a_b_c_d_j (pk, a, b, c, d, j)
├── PRIMARY INDEX primary
│ ├── a int not null (implicit)
│ ├── pk int not null
│ └── partitions
│ └── pk_implicit
│ └── partition by list prefixes
│ └── (1)
├── INDEX t_b_idx
│ ├── a int not null (implicit)
│ ├── b int
│ ├── pk int not null
│ └── partitions
│ └── b_implicit
│ └── partition by list prefixes
│ └── (2)
├── UNIQUE INDEX t_c_key
│ ├── a int not null (implicit)
│ ├── c int
│ ├── pk int not null (storing)
│ └── partitions
│ └── c_implicit
│ └── partition by list prefixes
│ └── (3)
├── INDEX t_a_b_c_idx
│ ├── d int (implicit)
│ ├── a int not null
│ ├── b int
│ ├── c int
│ ├── pk int not null
│ └── partitions
│ └── a_b_c_implicit
│ └── partition by list prefixes
│ └── (4)
├── INVERTED INDEX t_j_idx
│ ├── a int not null (implicit)
│ ├── j_inverted_key bytes not null [virtual-inverted]
│ ├── pk int not null
│ └── partitions
│ └── j_implicit
│ └── partition by list prefixes
│ └── (5)
├── INDEX new_idx
│ ├── a int not null (implicit)
│ ├── d int
│ ├── pk int not null
│ └── partitions
│ └── d_implicit
│ └── partition by list prefixes
│ └── (1)
├── UNIQUE WITHOUT INDEX (pk)
└── UNIQUE WITHOUT INDEX (c)
scan t

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

Expand Down
Loading

0 comments on commit 9678713

Please sign in to comment.