123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- # Copyright Materialize, Inc. and contributors. All rights reserved.
- #
- # Use of this software is governed by the Business Source License
- # included in the LICENSE file at the root of this repository.
- #
- # As of the Change Date specified in that file, in accordance with
- # the Business Source License, use of this software will be governed
- # by the Apache License, Version 2.0.
- mode cockroach
- # We have some tests also in cockroach/like.slt, but those go through const folding. The below tests avoid const folding.
- # Run all tests on a multi-process cluster, because there were some serialization issues in the past that happened
- # only on multi-process clusters.
- statement ok
- CREATE CLUSTER multiprocess REPLICAS (a (SIZE '2-2'));
- statement ok
- SET cluster = 'multiprocess';
- statement ok
- CREATE TABLE t(s string, like_pat string, regex_pat string);
- statement ok
- INSERT INTO t VALUES ('abc', 'a%', 'a.*'), ('ABC', 'a%', 'a.*'), ('ccc', 'a%', 'a.*');
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT s FROM t WHERE s LIKE 'a%';
- ----
- Explained Query:
- Project (#0{s})
- Filter like["a%"](#0{s})
- ReadStorage materialize.public.t
- Source materialize.public.t
- filter=(like["a%"](#0{s}))
- Target cluster: multiprocess
- EOF
- query T
- SELECT s FROM t WHERE s LIKE 'a%';
- ----
- abc
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT s FROM t WHERE s ILIKE 'a%';
- ----
- Explained Query:
- Project (#0{s})
- Filter ilike["a%"](#0{s})
- ReadStorage materialize.public.t
- Source materialize.public.t
- filter=(ilike["a%"](#0{s}))
- Target cluster: multiprocess
- EOF
- query T
- SELECT s FROM t WHERE s ILIKE 'a%';
- ----
- ABC
- abc
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT s FROM t WHERE s NOT ILIKE 'a%';
- ----
- Explained Query:
- Project (#0{s})
- Filter NOT(ilike["a%"](#0{s}))
- ReadStorage materialize.public.t
- Source materialize.public.t
- filter=(NOT(ilike["a%"](#0{s})))
- Target cluster: multiprocess
- EOF
- query T
- SELECT s FROM t WHERE s NOT ILIKE 'a%';
- ----
- ccc
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT s FROM t WHERE NOT (s ILIKE 'a%');
- ----
- Explained Query:
- Project (#0{s})
- Filter NOT(ilike["a%"](#0{s}))
- ReadStorage materialize.public.t
- Source materialize.public.t
- filter=(NOT(ilike["a%"](#0{s})))
- Target cluster: multiprocess
- EOF
- # Binary versions (MirScalarExpr::reduce changes them into unary when the pattern is a constant, which we prevent here.)
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT s FROM t WHERE s LIKE like_pat;
- ----
- Explained Query:
- Project (#0{s})
- Filter (#0{s} like #1{like_pat})
- ReadStorage materialize.public.t
- Source materialize.public.t
- filter=((#0{s} like #1{like_pat}))
- Target cluster: multiprocess
- EOF
- query T
- SELECT s FROM t WHERE s LIKE like_pat;
- ----
- abc
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT s FROM t WHERE s ILIKE like_pat;
- ----
- Explained Query:
- Project (#0{s})
- Filter (#0{s} ilike #1{like_pat})
- ReadStorage materialize.public.t
- Source materialize.public.t
- filter=((#0{s} ilike #1{like_pat}))
- Target cluster: multiprocess
- EOF
- query T
- SELECT s FROM t WHERE s ILIKE like_pat;
- ----
- ABC
- abc
- # Regression test for https://github.com/MaterializeInc/database-issues/issues/7790
- statement ok
- CREATE TABLE t2 (text_val TEXT);
- statement ok
- INSERT INTO t2 VALUES ('abc');
- statement ok
- CREATE CLUSTER test SIZE '2-1';
- statement ok
- SET cluster = test;
- query B
- SELECT text_val NOT ILIKE '%A%' FROM t2;
- ----
- false
- query B
- SELECT text_val NOT ILIKE '%A%' FROM t2;
- ----
- false
- query B
- SELECT text_val NOT ILIKE '%A%' FROM t2;
- ----
- false
- query B
- SELECT text_val NOT ILIKE '%A%' FROM t2;
- ----
- false
- query B
- SELECT text_val NOT ILIKE '%A%' FROM t2;
- ----
- false
- query B
- SELECT text_val NOT ILIKE '%A%' FROM t2;
- ----
- false
- query B
- SELECT text_val NOT ILIKE '%A%' FROM t2;
- ----
- false
- # Test that % matches \n
- query B
- SELECT E'test line 1\ntest line 2' LIKE '%1%2%';
- ----
- true
- statement ok
- INSERT INTO t2 VALUES ('test line 1\ntest line 2');
- query B
- SELECT text_val LIKE '%1%2%' FROM t2;
- ----
- false
- true
- statement ok
- DROP CLUSTER multiprocess;
|