github-7892.slt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 database-issues#7892.
  10. simple conn=mz_system,user=mz_system
  11. ALTER SYSTEM SET enable_variadic_left_join_lowering TO true;
  12. ----
  13. COMPLETE 0
  14. statement ok
  15. CREATE TABLE ft(k INT, v INT NOT NULL);
  16. statement ok
  17. CREATE TABLE dt(k INT, v INT NOT NULL);
  18. statement ok
  19. INSERT INTO ft VALUES
  20. -- one NULL row in ft
  21. (NULL, 0),
  22. (1, 1),
  23. (2, 2),
  24. (3, 3),
  25. (4, 4),
  26. -- mixed row for 5
  27. (5, 5)
  28. -- 7 is not present in either table
  29. ;
  30. statement ok
  31. INSERT INTO dt VALUES
  32. (NULL, 0),
  33. -- 1 not present in dt
  34. (2, 2),
  35. (3, 3),
  36. (4, 4),
  37. (NULL, 5)
  38. -- 6 not present in dt
  39. -- 7 is not present in either table
  40. ;
  41. # The predicate on d1: (ft.k = d1.k AND ft.v = d1.k) implies a local predicate
  42. # on fk: (ft.k = ft.v). However, we should not filter out fk rows where this
  43. # predicate does not hold.
  44. #
  45. # At the moment, we `variadic_left::attempt_left_join_magic` just bails in such
  46. # cases.
  47. query IIIIII rowsort
  48. SELECT
  49. ft.k AS ft_k,
  50. ft.v AS ft_v,
  51. d1.k AS d1_k,
  52. d1.v AS d1_v,
  53. d2.k AS d2_k,
  54. d2.v AS d2_v
  55. FROM
  56. ft
  57. LEFT JOIN dt AS d1 ON (ft.k = d1.k AND ft.v = d1.k)
  58. LEFT JOIN dt AS d2 ON (ft.k = d2.v);
  59. ----
  60. 1
  61. 1
  62. NULL
  63. NULL
  64. NULL
  65. NULL
  66. 2
  67. 2
  68. 2
  69. 2
  70. 2
  71. 2
  72. 3
  73. 3
  74. 3
  75. 3
  76. 3
  77. 3
  78. 4
  79. 4
  80. 4
  81. 4
  82. 4
  83. 4
  84. 5
  85. 5
  86. NULL
  87. NULL
  88. NULL
  89. 5
  90. NULL
  91. 0
  92. NULL
  93. NULL
  94. NULL
  95. NULL