exec_hash_join.slt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # This file is derived from the logic test suite in CockroachDB. The
  12. # original file was retrieved on June 10, 2019 from:
  13. #
  14. # https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/exec_hash_join
  15. #
  16. # The original source code is subject to the terms of the Apache
  17. # 2.0 license, a copy of which can be found in the LICENSE file at the
  18. # root of this repository.
  19. mode cockroach
  20. simple conn=mz_system,user=mz_system
  21. ALTER SYSTEM SET unsafe_enable_table_keys = true
  22. ----
  23. COMPLETE 0
  24. # Test that the exec HashJoiner follows SQL NULL semantics for ON predicate
  25. # equivalence. The use of sorts here force the planning of merge join.
  26. statement ok
  27. CREATE TABLE t1 (k INT PRIMARY KEY, v INT)
  28. statement ok
  29. INSERT INTO t1 VALUES (0, 4), (2, 1), (5, 4), (3, 4), (-1, -1)
  30. statement ok
  31. CREATE TABLE t2 (x INT PRIMARY KEY, y INT)
  32. statement ok
  33. INSERT INTO t2 VALUES (1, 3), (4, 6), (0, 5), (3, 2)
  34. statement ok
  35. CREATE TABLE a (k INT, v INT)
  36. statement ok
  37. INSERT INTO a VALUES (0, 1), (1, 2), (2, 0)
  38. statement ok
  39. CREATE TABLE b (a INT, b INT, c TEXT)
  40. statement ok
  41. INSERT INTO b VALUES (0, 1, 'a'), (2, 1, 'b'), (0, 2, 'c'), (0, 1, 'd')
  42. statement ok
  43. CREATE TABLE c (a INT, b TEXT)
  44. statement ok
  45. INSERT INTO c VALUES (1, 'a'), (1, 'b'), (2, 'c')
  46. query IIII rowsort
  47. SELECT * FROM t1 JOIN t2 ON t1.k = t2.x
  48. ----
  49. 0 4 0 5
  50. 3 4 3 2
  51. query IIII rowsort
  52. SELECT * FROM a AS a1 JOIN a AS a2 ON a1.k = a2.v
  53. ----
  54. 0 1 2 0
  55. 1 2 0 1
  56. 2 0 1 2
  57. query IIII rowsort
  58. SELECT * FROM a AS a2 JOIN a AS a1 ON a1.k = a2.v
  59. ----
  60. 0 1 1 2
  61. 1 2 2 0
  62. 2 0 0 1
  63. query II rowsort
  64. SELECT t2.y, t1.v FROM t1 JOIN t2 ON t1.k = t2.x
  65. ----
  66. 5 4
  67. 2 4
  68. query IIII rowsort
  69. SELECT * FROM t1 JOIN t2 ON t1.v = t2.x
  70. ----
  71. 0 4 4 6
  72. 2 1 1 3
  73. 3 4 4 6
  74. 5 4 4 6
  75. query IIII rowsort
  76. SELECT * FROM t1 LEFT JOIN t2 ON t1.v = t2.x
  77. ----
  78. -1 -1 NULL NULL
  79. 0 4 4 6
  80. 2 1 1 3
  81. 3 4 4 6
  82. 5 4 4 6
  83. query IIII rowsort
  84. SELECT * FROM t1 RIGHT JOIN t2 ON t1.v = t2.x
  85. ----
  86. 0 4 4 6
  87. 2 1 1 3
  88. 3 4 4 6
  89. 5 4 4 6
  90. NULL NULL 0 5
  91. NULL NULL 3 2
  92. query IIII rowsort
  93. SELECT * FROM t1 FULL JOIN t2 ON t1.v = t2.x
  94. ----
  95. -1 -1 NULL NULL
  96. 0 4 4 6
  97. 2 1 1 3
  98. 3 4 4 6
  99. 5 4 4 6
  100. NULL NULL 3 2
  101. NULL NULL 0 5
  102. query IIT rowsort
  103. SELECT b.a, b.b, b.c FROM b JOIN a ON b.a = a.k AND a.v = b.b
  104. ----
  105. 0 1 a
  106. 0 1 d
  107. query ITI rowsort
  108. SELECT b.a, b.c, c.a FROM b JOIN c ON b.b = c.a AND b.c = c.b
  109. ----
  110. 0 a 1
  111. 2 b 1
  112. 0 c 2