is_null_propagation.slt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. mode cockroach
  10. statement ok
  11. CREATE TABLE t1 (f1 DOUBLE PRECISION, f2 DOUBLE PRECISION NOT NULL);
  12. statement ok
  13. CREATE TABLE t2 (f1 DOUBLE PRECISION, f2 DOUBLE PRECISION NOT NULL);
  14. query T multiline
  15. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT FROM ( SELECT FROM t2 a1 RIGHT JOIN t2 ON a1.f1 IS NULL WHERE TRUE AND a1.f1 = a1.f2 )
  16. ----
  17. Explained Query (fast path):
  18. Constant <empty>
  19. Target cluster: quickstart
  20. EOF
  21. # TODO missing !isnull(#0) in %1
  22. query T multiline
  23. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT FROM t1, t2 WHERE t1.f2 + t2.f1 = t1.f1 AND t2.f1 IS NOT NULL
  24. ----
  25. Explained Query:
  26. Project () // { arity: 0 }
  27. Join on=(#0{f1} = (#1{f2} + #2{f1})) type=differential // { arity: 3 }
  28. implementation
  29. %0:t1[×] » %1:t2[×]
  30. ArrangeBy keys=[[]] // { arity: 2 }
  31. Filter (#0{f1}) IS NOT NULL // { arity: 2 }
  32. ReadStorage materialize.public.t1 // { arity: 2 }
  33. ArrangeBy keys=[[]] // { arity: 1 }
  34. Project (#0{f1}) // { arity: 1 }
  35. ReadStorage materialize.public.t2 // { arity: 2 }
  36. Source materialize.public.t1
  37. filter=((#0{f1}) IS NOT NULL)
  38. Source materialize.public.t2
  39. Target cluster: quickstart
  40. EOF
  41. query T multiline
  42. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT FROM t1 WHERE f2 IN ( SELECT agg1 FROM ( SELECT COUNT ( TRUE ) agg1 FROM t2 a1 JOIN ( SELECT a2.f2 FROM t1 LEFT JOIN t1 a2 ON TRUE ) a2 ON TRUE WHERE a2.f2 IS NOT NULL AND a2.f2 > a1.f2 ) )
  43. ----
  44. Explained Query:
  45. With
  46. cte l0 =
  47. Project (#1{f2}) // { arity: 1 }
  48. ReadStorage materialize.public.t1 // { arity: 2 }
  49. cte l1 =
  50. Distinct project=[#0{f2}] // { arity: 1 }
  51. Get l0 // { arity: 1 }
  52. cte l2 =
  53. Reduce group_by=[#0{f2}] aggregates=[count(*)] // { arity: 2 }
  54. Project (#0{f2}) // { arity: 1 }
  55. Filter (#2{f2} > #1{f2}) // { arity: 3 }
  56. CrossJoin type=delta // { arity: 3 }
  57. implementation
  58. %0:l1 » %1:t2[×] » %2:t1[×] » %3:l0[×]
  59. %1:t2 » %0:l1[×] » %2:t1[×] » %3:l0[×]
  60. %2:t1 » %0:l1[×] » %1:t2[×] » %3:l0[×]
  61. %3:l0 » %0:l1[×] » %1:t2[×] » %2:t1[×]
  62. ArrangeBy keys=[[]] // { arity: 1 }
  63. Get l1 // { arity: 1 }
  64. ArrangeBy keys=[[]] // { arity: 1 }
  65. Project (#1{f2}) // { arity: 1 }
  66. ReadStorage materialize.public.t2 // { arity: 2 }
  67. ArrangeBy keys=[[]] // { arity: 0 }
  68. Project () // { arity: 0 }
  69. ReadStorage materialize.public.t1 // { arity: 2 }
  70. ArrangeBy keys=[[]] // { arity: 1 }
  71. Get l0 // { arity: 1 }
  72. Return // { arity: 0 }
  73. Project () // { arity: 0 }
  74. Join on=(#0{f2} = #1{f2}) type=differential // { arity: 2 }
  75. implementation
  76. %1[#0]UKA » %0:l0[#0]K
  77. ArrangeBy keys=[[#0{f2}]] // { arity: 1 }
  78. Get l0 // { arity: 1 }
  79. ArrangeBy keys=[[#0{f2}]] // { arity: 1 }
  80. Distinct project=[#0{f2}] // { arity: 1 }
  81. Union // { arity: 1 }
  82. Project (#0{f2}) // { arity: 1 }
  83. Filter (#0{f2} = bigint_to_double(#1{count})) // { arity: 2 }
  84. Get l2 // { arity: 2 }
  85. Negate // { arity: 1 }
  86. Project (#0{f2}) // { arity: 1 }
  87. Filter (#0{f2} = 0) // { arity: 2 }
  88. Get l2 // { arity: 2 }
  89. Filter (#0{f2} = 0) // { arity: 1 }
  90. Get l1 // { arity: 1 }
  91. Source materialize.public.t1
  92. Source materialize.public.t2
  93. Target cluster: quickstart
  94. EOF