dataflow.slt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Tests of optimizing across views
  10. ## Tests that not-materialized dependent views get inlined when planning to
  11. ## materialize a view
  12. statement ok
  13. CREATE TABLE foo (a int, b int)
  14. statement ok
  15. CREATE VIEW foo2 as select b from foo where a = 5;
  16. statement ok
  17. CREATE VIEW foo3 as select b from foo2 where b = 6;
  18. query T multiline
  19. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * from foo3
  20. ----
  21. Explained Query:
  22. Project (#1{b}) // { arity: 1 }
  23. Filter (#0{a} = 5) AND (#1{b} = 6) // { arity: 2 }
  24. ReadStorage materialize.public.foo // { arity: 2 }
  25. Source materialize.public.foo
  26. filter=((#0{a} = 5) AND (#1{b} = 6))
  27. Target cluster: quickstart
  28. EOF
  29. statement ok
  30. CREATE DEFAULT INDEX ON foo2
  31. query T multiline
  32. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * from foo3
  33. ----
  34. Explained Query (fast path):
  35. Project (#0{b})
  36. ReadIndex on=materialize.public.foo2 foo2_primary_idx=[lookup value=(6)]
  37. Used Indexes:
  38. - materialize.public.foo2_primary_idx (lookup)
  39. Target cluster: quickstart
  40. EOF