github-2969.slt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. # Regression test for https://github.com/MaterializeInc/database-issues/issues/2969.
  10. statement ok
  11. CREATE TABLE table_f1 (f1 INTEGER);
  12. statement ok
  13. CREATE TAble table_f4 (f4 INTEGER);
  14. query T multiline
  15. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * FROM table_f1 , LATERAL ( SELECT * FROM ( table_f4 AS a1 LEFT JOIN table_f4 AS a2 ON a1.f4 = a2.f4 ) WHERE a1.f4 <= f1 ) WHERE f1 IS NULL;
  16. ----
  17. Explained Query (fast path):
  18. Constant <empty>
  19. Target cluster: quickstart
  20. EOF
  21. query T multiline
  22. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * FROM table_f1 , LATERAL ( SELECT * FROM ( table_f4 AS a1 LEFT JOIN table_f4 AS a2 ON a1.f4 = a2.f4 ) WHERE a1.f4 <= f1 ) WHERE f1 IS NULL;
  23. ----
  24. Explained Query (fast path):
  25. Constant <empty>
  26. Target cluster: quickstart
  27. EOF
  28. query T multiline
  29. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * FROM table_f1 , LATERAL ( SELECT * FROM ( table_f4 AS a1 LEFT JOIN table_f4 AS a2 ON a1.f4 = a2.f4 ) WHERE a1.f4 <= f1 ) WHERE f1 IS NULL;
  30. ----
  31. Explained Query (fast path):
  32. Constant <empty>
  33. Target cluster: quickstart
  34. EOF
  35. query T multiline
  36. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * FROM table_f1 , LATERAL ( SELECT * FROM ( table_f4 AS a1 LEFT JOIN table_f4 AS a2 ON a1.f4 = a2.f4 ) WHERE a1.f4 <= f1 ) WHERE f1 IS NULL;
  37. ----
  38. Explained Query (fast path):
  39. Constant <empty>
  40. Target cluster: quickstart
  41. EOF
  42. query T multiline
  43. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * FROM table_f1 , LATERAL ( SELECT * FROM ( table_f4 AS a1 LEFT JOIN table_f4 AS a2 ON a1.f4 = a2.f4 ) WHERE a1.f4 <= f1 ) WHERE f1 IS NULL;
  44. ----
  45. Explained Query (fast path):
  46. Constant <empty>
  47. Target cluster: quickstart
  48. EOF
  49. statement ok
  50. CREATE TAble table_f4_f5_f6 (f4 INTEGER, f5 INTEGER, f6 INTEGER);
  51. statement ok
  52. CREATE TAble table_f5_f6 (f5 INTEGER, f6 INTEGER);
  53. query T multiline
  54. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * FROM table_f1 , ( table_f4_f5_f6 AS a2 LEFT JOIN table_f5_f6 AS a3 USING ( f5 , f6 ) ) WHERE f5 = f6 AND f4 = f6;
  55. ----
  56. Explained Query:
  57. With
  58. cte l0 =
  59. Project (#0{f4}..=#2{f6}) // { arity: 3 }
  60. Join on=(#1{f5} = #3{f5}) type=differential // { arity: 4 }
  61. implementation
  62. %0:table_f4_f5_f6[#1]Kf » %1:table_f5_f6[#0{f5}]Kf
  63. ArrangeBy keys=[[#1{f5}]] // { arity: 3 }
  64. Filter (#1{f5} = #2{f6}) // { arity: 3 }
  65. ReadStorage materialize.public.table_f4_f5_f6 // { arity: 3 }
  66. ArrangeBy keys=[[#0{f5}]] // { arity: 1 }
  67. Project (#0{f5}) // { arity: 1 }
  68. Filter (#0{f5} = #1{f6}) // { arity: 2 }
  69. ReadStorage materialize.public.table_f5_f6 // { arity: 2 }
  70. cte l1 =
  71. Filter (#0{f4} = #1{f5}) AND (#0{f4} = #2{f6}) AND (#1{f5} = #2{f6}) // { arity: 3 }
  72. ReadStorage materialize.public.table_f4_f5_f6 // { arity: 3 }
  73. Return // { arity: 4 }
  74. Project (#0{f1}, #2{f5}, #3{f6}, #1{f4}) // { arity: 4 }
  75. CrossJoin type=differential // { arity: 4 }
  76. implementation
  77. %0:table_f1[×] » %1[×]
  78. ArrangeBy keys=[[]] // { arity: 1 }
  79. ReadStorage materialize.public.table_f1 // { arity: 1 }
  80. ArrangeBy keys=[[]] // { arity: 3 }
  81. Union // { arity: 3 }
  82. Negate // { arity: 3 }
  83. Project (#0{f4}..=#2{f6}) // { arity: 3 }
  84. Join on=(#0{f4} = #3{f5}) type=differential // { arity: 4 }
  85. implementation
  86. %0:l1[#0]Kf » %1[#0]Kf
  87. ArrangeBy keys=[[#0{f4}]] // { arity: 3 }
  88. Get l1 // { arity: 3 }
  89. ArrangeBy keys=[[#0{f5}]] // { arity: 1 }
  90. Project (#0{f5}) // { arity: 1 }
  91. Distinct project=[#0{f5}, #1{f6}] // { arity: 2 }
  92. Project (#1{f5}, #2{f6}) // { arity: 2 }
  93. Get l0 // { arity: 3 }
  94. Get l1 // { arity: 3 }
  95. Filter (#0{f4} = #1{f5}) // { arity: 3 }
  96. Get l0 // { arity: 3 }
  97. Source materialize.public.table_f1
  98. Source materialize.public.table_f4_f5_f6
  99. filter=((#1{f5} = #2{f6}))
  100. Source materialize.public.table_f5_f6
  101. filter=((#0{f5} = #1{f6}))
  102. Target cluster: quickstart
  103. EOF