github-5126.slt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/5126
  10. mode cockroach
  11. # reset
  12. statement ok
  13. DROP TABLE IF EXISTS t1 CASCADE
  14. statement ok
  15. DROP TABLE IF EXISTS t2 CASCADE
  16. # schema
  17. statement ok
  18. CREATE TABLE t1(f1 INT, f2 INT, f3 INT)
  19. statement ok
  20. CREATE TABLE t2(f2 INT, f3 INT)
  21. # data
  22. statement ok
  23. INSERT INTO t1 VALUES (1, 2, 3)
  24. statement ok
  25. INSERT INTO t2 VALUES (2, 3)
  26. query T multiline
  27. EXPLAIN DECORRELATED PLAN WITH(arity) FOR
  28. SELECT
  29. sq1.*
  30. FROM
  31. (
  32. SELECT * FROM t1
  33. ) AS sq0,
  34. LATERAL(
  35. SELECT
  36. ( sq0.f2 * f2 ) as c0,
  37. ( SELECT 3 ) as c1,
  38. ( sq0.f2 * f2 ) * 2 as c2
  39. FROM t2
  40. ) AS sq1
  41. ----
  42. With
  43. cte l0 =
  44. CrossJoin // { arity: 3 }
  45. Constant // { arity: 0 }
  46. - ()
  47. Get materialize.public.t1 // { arity: 3 }
  48. cte l1 =
  49. CrossJoin // { arity: 3 }
  50. Distinct project=[#1] // { arity: 1 }
  51. Get l0 // { arity: 3 }
  52. Get materialize.public.t2 // { arity: 2 }
  53. cte l2 =
  54. Distinct project=[#0..=#2] // { arity: 3 }
  55. Get l1 // { arity: 3 }
  56. cte l3 =
  57. Project (#0..=#3) // { arity: 4 }
  58. Map (3) // { arity: 4 }
  59. Get l2 // { arity: 3 }
  60. cte l4 =
  61. Union // { arity: 4 }
  62. Get l3 // { arity: 4 }
  63. Project (#0..=#2, #4) // { arity: 4 }
  64. FlatMap guard_subquery_size(#3) // { arity: 5 }
  65. Reduce group_by=[#0..=#2] aggregates=[count(*)] // { arity: 4 }
  66. Get l3 // { arity: 4 }
  67. Return // { arity: 3 }
  68. Project (#3..=#5) // { arity: 3 }
  69. Project (#0..=#2, #4..=#6) // { arity: 6 }
  70. Join on=(#1 = #3) // { arity: 7 }
  71. Get l0 // { arity: 3 }
  72. Project (#0, #3..=#5) // { arity: 4 }
  73. Map ((#3{"?column?"} * 2)) // { arity: 6 }
  74. Project (#0..=#2, #7, #8) // { arity: 5 }
  75. Map ((#0{f2} * #1{f2}), #6) // { arity: 9 }
  76. Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) // { arity: 7 }
  77. Get l1 // { arity: 3 }
  78. Union // { arity: 4 }
  79. Get l4 // { arity: 4 }
  80. CrossJoin // { arity: 4 }
  81. Project (#0..=#2) // { arity: 3 }
  82. Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) // { arity: 6 }
  83. Union // { arity: 3 }
  84. Negate // { arity: 3 }
  85. Distinct project=[#0..=#2] // { arity: 3 }
  86. Get l4 // { arity: 4 }
  87. Distinct project=[#0..=#2] // { arity: 3 }
  88. Get l2 // { arity: 3 }
  89. Get l2 // { arity: 3 }
  90. Constant // { arity: 1 }
  91. - (null)
  92. Target cluster: quickstart
  93. EOF
  94. query III rowsort
  95. SELECT
  96. sq1.*
  97. FROM
  98. (
  99. SELECT * FROM t1
  100. ) AS sq0,
  101. LATERAL(
  102. SELECT
  103. ( sq0.f2 * f2 ) as c0,
  104. ( SELECT 3 ) as c1,
  105. ( sq0.f2 * f2 ) * 2 as c2
  106. FROM t2
  107. ) AS sq1
  108. ----
  109. 4 3 8