# 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. # Tests of optimizing across views ## Tests that not-materialized dependent views get inlined when planning to ## materialize a view statement ok CREATE TABLE foo (a int, b int) statement ok CREATE VIEW foo2 as select b from foo where a = 5; statement ok CREATE VIEW foo3 as select b from foo2 where b = 6; query T multiline EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * from foo3 ---- Explained Query: Project (#1{b}) // { arity: 1 } Filter (#0{a} = 5) AND (#1{b} = 6) // { arity: 2 } ReadStorage materialize.public.foo // { arity: 2 } Source materialize.public.foo filter=((#0{a} = 5) AND (#1{b} = 6)) Target cluster: quickstart EOF statement ok CREATE DEFAULT INDEX ON foo2 query T multiline EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * from foo3 ---- Explained Query (fast path): Project (#0{b}) ReadIndex on=materialize.public.foo2 foo2_primary_idx=[lookup value=(6)] Used Indexes: - materialize.public.foo2_primary_idx (lookup) Target cluster: quickstart EOF