record.slt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. statement ok
  10. CREATE TABLE t1 (a int, b int)
  11. statement ok
  12. INSERT INTO t1 values (1, 2)
  13. query T multiline
  14. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT (record).f2 FROM (SELECT ROW(a, a) AS record FROM t1);
  15. ----
  16. Explained Query:
  17. Project (#0{a}) // { arity: 1 }
  18. ReadStorage materialize.public.t1 // { arity: 2 }
  19. Source materialize.public.t1
  20. Target cluster: quickstart
  21. EOF
  22. query T multiline
  23. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT record, (record).f2 FROM (SELECT ROW(a, a) AS record FROM t1);
  24. ----
  25. Explained Query:
  26. Project (#2, #3) // { arity: 2 }
  27. Map (row(#0{a}, #0{a}), record_get[1](#2{record})) // { arity: 4 }
  28. ReadStorage materialize.public.t1 // { arity: 2 }
  29. Source materialize.public.t1
  30. Target cluster: quickstart
  31. EOF
  32. query T multiline
  33. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT (COALESCE(record, ROW(NULL, NULL))).f2 FROM (SELECT ROW(a, a) AS record FROM t1)
  34. ----
  35. Explained Query:
  36. Project (#0{a}) // { arity: 1 }
  37. ReadStorage materialize.public.t1 // { arity: 2 }
  38. Source materialize.public.t1
  39. Target cluster: quickstart
  40. EOF
  41. query T
  42. SELECT abc FROM (VALUES (1, 2, (3,4), ROW(5, 6, 7))) as abc;
  43. ----
  44. (1,2,"(3,4)","(5,6,7)")
  45. # MirScalarExpr::reduce() should transform
  46. # Literal([c1, c2]) = record_create(e1, e2)
  47. # into
  48. # c1 = e1 AND c2 = e2
  49. #
  50. # If this test fails in the future, one possible reason is the canonical ordering having been changed between
  51. # MirScalarExpr::Literal and MirScalarExpr::CallVariadic, because then the argument ordering of the `Eq` changes, so
  52. # reduce() doesn't recognize the pattern anymore.
  53. query T multiline
  54. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE (t1.a, t1.b) IN ((1,2))
  55. ----
  56. Explained Query:
  57. Filter (#0{a} = 1) AND (#1{b} = 2) // { arity: 2 }
  58. ReadStorage materialize.public.t1 // { arity: 2 }
  59. Source materialize.public.t1
  60. filter=((#0{a} = 1) AND (#1{b} = 2))
  61. Target cluster: quickstart
  62. EOF