github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/exec/execbuilder/testdata/enums (about) 1 # LogicTest: local 2 3 statement ok 4 SET experimental_enable_enums=true; 5 6 # Note that we use EXPLAIN (opt) in these tests because the standard explain 7 # prints spans after they have been converted into keys. Once converted into 8 # keys, enum datums are not human readable. EXPLAIN (OPT) prints these enums 9 # as datums, so we can more clearly see what spans are being generated. 10 11 statement ok 12 CREATE TYPE greeting AS ENUM ('hello', 'howdy', 'hi'); 13 CREATE TABLE t (x greeting PRIMARY KEY, y greeting, INDEX i (y), FAMILY (x, y)); 14 INSERT INTO t VALUES ('hello', 'howdy'), ('howdy', 'hi') 15 16 query T 17 EXPLAIN (OPT) SELECT * FROM t WHERE x = 'hello' 18 ---- 19 scan t 20 └── constraint: /1: [/'hello' - /'hello'] 21 22 query T 23 EXPLAIN (OPT) SELECT * FROM t WHERE x = 'hello' OR x = 'hi' 24 ---- 25 scan t 26 └── constraint: /1 27 ├── [/'hello' - /'hello'] 28 └── [/'hi' - /'hi'] 29 30 query T 31 EXPLAIN (OPT) SELECT * FROM t WHERE x > 'hello' 32 ---- 33 scan t 34 └── constraint: /1: [/'howdy' - ] 35 36 # Test that we can perform constrained scans using secondary indexes too. 37 query T 38 EXPLAIN (OPT) SELECT * FROM t WHERE y = 'hello' 39 ---- 40 scan t@i 41 └── constraint: /2/1: [/'hello' - /'hello'] 42 43 query T 44 EXPLAIN (OPT) SELECT * FROM t WHERE y > 'hello' AND y < 'hi' 45 ---- 46 scan t@i 47 └── constraint: /2/1: [/'howdy' - /'howdy'] 48 49 query T 50 EXPLAIN (opt) SELECT * FROM t WHERE x IN ('hello', 'hi') 51 ---- 52 scan t 53 └── constraint: /1 54 ├── [/'hello' - /'hello'] 55 └── [/'hi' - /'hi']