123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- # 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.
- # Test the ability to catch plan changes using the `enable eager delta joins`
- # config flag in EXPLAIN. This test can be deleted when the feature flag is
- # removed.
- mode cockroach
- # Role-based restrictions
- # -----------------------------------------------------------
- # Regular users cannot create clusters with FEATURES yet.
- statement error db error: ERROR: FEATURES not supported for non\-system users
- CREATE CLUSTER FOO SIZE = '1' FEATURES (ENABLE EAGER DELTA JOINS = TRUE);
- # Cluster and system config for the test DDL statements below
- # -----------------------------------------------------------
- simple conn=mz_system,user=mz_system
- CREATE CLUSTER c1 SIZE = '1' FEATURES (ENABLE EAGER DELTA JOINS = TRUE);
- ----
- COMPLETE 0
- simple conn=mz_system,user=mz_system
- CREATE CLUSTER c2 SIZE = '1' FEATURES (ENABLE EAGER DELTA JOINS = FALSE);
- ----
- COMPLETE 0
- simple conn=mz_system,user=mz_system
- GRANT ALL ON CLUSTER c1 TO materialize;
- ----
- COMPLETE 0
- simple conn=mz_system,user=mz_system
- GRANT ALL ON CLUSTER c2 TO materialize;
- ----
- COMPLETE 0
- # Schema for the test DDL statements below
- # ----------------------------------------
- statement ok
- CREATE TABLE t1 (
- x int,
- y int
- );
- statement ok
- CREATE TABLE t2 (
- x int,
- y int
- );
- statement ok
- CREATE TABLE t3 (
- x int,
- y int
- );
- # Test materialized views
- # -----------------------
- # Should be created with the feature flag turned on.
- statement ok
- CREATE MATERIALIZED VIEW mv1 IN CLUSTER c1 AS
- SELECT
- t1.y as f1,
- t2.y as f2,
- t3.y as f3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- # Should be created with the feature flag turned off.
- statement ok
- CREATE MATERIALIZED VIEW mv2 IN CLUSTER c2 AS
- SELECT
- t1.y as f1,
- t2.y as f2,
- t3.y as f3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- # EXPLAIN mv1 in c1 (should be running with the feature flag turned on).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS) AS VERBOSE TEXT FOR
- MATERIALIZED VIEW mv1;
- ----
- materialize.public.mv1:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta
- implementation
- %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K
- %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}], [#1{y}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # EXPLAIN mv2 in c2 (should be running with the feature flag turned off).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS) AS VERBOSE TEXT FOR
- MATERIALIZED VIEW mv2;
- ----
- materialize.public.mv2:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential
- implementation
- %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c2
- EOF
- # EXPLAIN REPLAN mv1 in c1 (should be running with the feature flag turned on).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS) AS VERBOSE TEXT FOR
- REPLAN MATERIALIZED VIEW mv1;
- ----
- materialize.public.mv1:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta
- implementation
- %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K
- %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}], [#1{y}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # EXPLAIN REPLAN mv1 in c1 with an explain-level feature override (should be
- # running with the feature flag turned off).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS, ENABLE EAGER DELTA JOINS = FALSE) AS VERBOSE TEXT FOR
- REPLAN MATERIALIZED VIEW mv1;
- ----
- materialize.public.mv1:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential
- implementation
- %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # EXPLAIN CREATE in c1 with an explain-level feature override (should be
- # running with the feature flag turned off).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS, ENABLE EAGER DELTA JOINS = FALSE) AS VERBOSE TEXT FOR
- CREATE MATERIALIZED VIEW mv1 IN CLUSTER c1 AS
- SELECT
- t1.y as f1,
- t2.y as f2,
- t3.y as f3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- ----
- materialize.public.mv1:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential
- implementation
- %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # Test indexed views
- # ------------------
- # Same as the mv1 / mv2 definitions above.
- statement ok
- CREATE VIEW v AS
- SELECT
- t1.y as f1,
- t2.y as f2,
- t3.y as f3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- statement ok
- CREATE INDEX v_idx_in_c1 IN CLUSTER c1 ON v(f1);
- statement ok
- CREATE INDEX v_idx_in_c2 IN CLUSTER c2 ON v(f1);
- # EXPLAIN v in c2 (should be running with the feature flag turned on).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS) AS VERBOSE TEXT FOR
- INDEX v_idx_in_c1;
- ----
- materialize.public.v_idx_in_c1:
- ArrangeBy keys=[[#0{f1}]]
- ReadGlobalFromSameDataflow materialize.public.v
- materialize.public.v:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta
- implementation
- %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K
- %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}], [#1{y}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # EXPLAIN v in c2 (should be running with the feature flag turned off).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS) AS VERBOSE TEXT FOR
- INDEX v_idx_in_c2;
- ----
- materialize.public.v_idx_in_c2:
- ArrangeBy keys=[[#0{f1}]]
- ReadGlobalFromSameDataflow materialize.public.v
- materialize.public.v:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential
- implementation
- %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c2
- EOF
- # EXPLAIN REPLAN v in c1 (should be running with the feature flag turned on).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS) AS VERBOSE TEXT FOR
- REPLAN INDEX v_idx_in_c1;
- ----
- materialize.public.v_idx_in_c1:
- ArrangeBy keys=[[#0{f1}]]
- ReadGlobalFromSameDataflow materialize.public.v
- materialize.public.v:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta
- implementation
- %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K
- %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}], [#1{y}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # EXPLAIN REPLAN v in c1 with an explain-level feature override (should be
- # running with the feature flag turned off).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS, ENABLE EAGER DELTA JOINS = FALSE) AS VERBOSE TEXT FOR
- REPLAN INDEX v_idx_in_c1;
- ----
- materialize.public.v_idx_in_c1:
- ArrangeBy keys=[[#0{f1}]]
- ReadGlobalFromSameDataflow materialize.public.v
- materialize.public.v:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential
- implementation
- %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # Delete the existing index in order to get the expected output in the next
- # test.
- statement ok
- DROP INDEX v_idx_in_c1;
- # EXPLAIN CREATE in c1 with an explain-level feature override (should be
- # running with the feature flag turned off).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(JOIN IMPLEMENTATIONS, HUMANIZED EXPRESSIONS, ENABLE EAGER DELTA JOINS = FALSE) AS VERBOSE TEXT FOR
- CREATE INDEX v_idx_in_c1 IN CLUSTER c1 ON v(f1);
- ----
- materialize.public.v_idx_in_c1:
- ArrangeBy keys=[[#0{f1}]]
- ReadGlobalFromSameDataflow materialize.public.v
- materialize.public.v:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential
- implementation
- %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- # Test peeks
- # ----------
- statement ok
- SET cluster = c1;
- # EXPLAIN in c1 (should be running with the feature flag turned on).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT
- t1.y as f1,
- t2.y as f2,
- t3.y as f3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- ----
- Explained Query:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}], [#1{y}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c1
- EOF
- statement ok
- SET cluster = c2;
- # EXPLAIN in c2 (should be running with the feature flag turned off).
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
- SELECT
- t1.y as f1,
- t2.y as f2,
- t3.y as f3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- ----
- Explained Query:
- Project (#1{y}, #3{y}, #3{y})
- Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL
- ReadStorage materialize.public.t1
- ArrangeBy keys=[[#0{x}]]
- Filter (#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t2
- ArrangeBy keys=[[#0{y}]]
- Project (#1{y})
- Filter (#1{y}) IS NOT NULL
- ReadStorage materialize.public.t3
- Source materialize.public.t1
- filter=((#0{x}) IS NOT NULL)
- Source materialize.public.t2
- filter=((#0{x}) IS NOT NULL AND (#1{y}) IS NOT NULL)
- Source materialize.public.t3
- filter=((#1{y}) IS NOT NULL)
- Target cluster: c2
- EOF
|