github-14116.slt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 test1 (a int, b int);
  12. statement ok
  13. create table test2 (a int, b int);
  14. statement ok
  15. create view test3 as select a, b, count(*) as c from test2 group by a, b;
  16. statement ok
  17. insert into test1 values (1, 3);
  18. statement ok
  19. insert into test2 values (1, 2), (1, 3);
  20. statement error more than one record produced in subquery
  21. select a, b, ( select c from test3 where a = test3.a and b = test3.b) from test1;
  22. query T multiline
  23. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR select a, b, ( select c from test3 where a = test3.a and b = test3.b) from test1;
  24. ----
  25. Explained Query:
  26. With
  27. cte l0 =
  28. Project (#2{count}) // { arity: 1 }
  29. Reduce group_by=[#0{a}, #1{b}] aggregates=[count(*)] // { arity: 3 }
  30. Filter (#0{a} = #0{a}) AND (#1{b} = #1{b}) // { arity: 2 }
  31. ReadStorage materialize.public.test2 // { arity: 2 }
  32. cte l1 =
  33. Union // { arity: 1 }
  34. Get l0 // { arity: 1 }
  35. Project (#1) // { arity: 1 }
  36. FlatMap guard_subquery_size(#0{count}) // { arity: 2 }
  37. Reduce aggregates=[count(*)] // { arity: 1 }
  38. Project () // { arity: 0 }
  39. Get l0 // { arity: 1 }
  40. Return // { arity: 3 }
  41. CrossJoin type=differential // { arity: 3 }
  42. implementation
  43. %0:test1[×] » %1[×]
  44. ArrangeBy keys=[[]] // { arity: 2 }
  45. ReadStorage materialize.public.test1 // { arity: 2 }
  46. ArrangeBy keys=[[]] // { arity: 1 }
  47. Union // { arity: 1 }
  48. Get l1 // { arity: 1 }
  49. Map (null) // { arity: 1 }
  50. Union // { arity: 0 }
  51. Negate // { arity: 0 }
  52. Distinct project=[] // { arity: 0 }
  53. Project () // { arity: 0 }
  54. Get l1 // { arity: 1 }
  55. Constant // { arity: 0 }
  56. - ()
  57. Source materialize.public.test1
  58. Source materialize.public.test2
  59. filter=((#0{a} = #0{a}) AND (#1{b} = #1{b}))
  60. Target cluster: quickstart
  61. EOF