123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- # 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
- simple conn=mz_system,user=mz_system
- ALTER SYSTEM SET enable_eager_delta_joins TO false;
- ----
- COMPLETE 0
- 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
- # -----------------------
- # A query that will produce different plans depending on the value of the
- # `enable eager delta joins` feature flag.
- statement ok
- CREATE MATERIALIZED VIEW mv AS
- SELECT
- t1.y as c1,
- t2.y as c2,
- t3.y as c3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- # EXPLAIN and EXPLAIN REPLAN should coincide.
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR
- MATERIALIZED VIEW mv;
- ----
- materialize.public.mv:
- 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: quickstart
- EOF
- # EXPLAIN and EXPLAIN REPLAN should coincide.
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR
- REPLAN MATERIALIZED VIEW mv;
- ----
- materialize.public.mv:
- 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: quickstart
- EOF
- # EXPLAIN REPLAN WITH(enable eager delta joins) should differ.
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(join implementations, enable eager delta joins, humanized expressions) AS VERBOSE TEXT FOR
- REPLAN MATERIALIZED VIEW mv;
- ----
- materialize.public.mv:
- 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: quickstart
- EOF
- # Test indexed views
- # ------------------
- # Same as above, but as an indexed view.
- statement ok
- CREATE VIEW v AS
- SELECT
- t1.y as c1,
- t2.y as c2,
- t3.y as c3
- FROM
- t1, t2, t3
- where
- t1.x = t2.x AND
- t2.y = t3.y;
- statement ok
- CREATE INDEX v_idx ON v(c1);
- # EXPLAIN and EXPLAIN REPLAN should coincide.
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR
- INDEX v_idx;
- ----
- materialize.public.v_idx:
- ArrangeBy keys=[[#0{c1}]]
- 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: quickstart
- EOF
- # EXPLAIN and EXPLAIN REPLAN should coincide.
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR
- REPLAN INDEX v_idx;
- ----
- materialize.public.v_idx:
- ArrangeBy keys=[[#0{c1}]]
- 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: quickstart
- EOF
- # EXPLAIN REPLAN WITH(enable eager delta joins) should differ.
- query T multiline
- EXPLAIN OPTIMIZED PLAN WITH(join implementations, enable eager delta joins, humanized expressions) AS VERBOSE TEXT FOR
- REPLAN INDEX v_idx;
- ----
- materialize.public.v_idx:
- ArrangeBy keys=[[#0{c1}]]
- 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: quickstart
- EOF
|