123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- # Copyright Materialize, Inc. and contributors. All rights reserved.
- #
- # Use of this software is governed by the Business Source License
- # included in the LICENSE file at the root of this repository.
- #
- # As of the Change Date specified in that file, in accordance with
- # the Business Source License, use of this software will be governed
- # by the Apache License, Version 2.0.
- # Regression test for database-issues#7892.
- simple conn=mz_system,user=mz_system
- ALTER SYSTEM SET enable_variadic_left_join_lowering TO true;
- ----
- COMPLETE 0
- statement ok
- CREATE TABLE ft(k INT, v INT NOT NULL);
- statement ok
- CREATE TABLE dt(k INT, v INT NOT NULL);
- statement ok
- INSERT INTO ft VALUES
- -- one NULL row in ft
- (NULL, 0),
- (1, 1),
- (2, 2),
- (3, 3),
- (4, 4),
- -- mixed row for 5
- (5, 5)
- -- 7 is not present in either table
- ;
- statement ok
- INSERT INTO dt VALUES
- (NULL, 0),
- -- 1 not present in dt
- (2, 2),
- (3, 3),
- (4, 4),
- (NULL, 5)
- -- 6 not present in dt
- -- 7 is not present in either table
- ;
- # The predicate on d1: (ft.k = d1.k AND ft.v = d1.k) implies a local predicate
- # on fk: (ft.k = ft.v). However, we should not filter out fk rows where this
- # predicate does not hold.
- #
- # At the moment, we `variadic_left::attempt_left_join_magic` just bails in such
- # cases.
- query IIIIII rowsort
- SELECT
- ft.k AS ft_k,
- ft.v AS ft_v,
- d1.k AS d1_k,
- d1.v AS d1_v,
- d2.k AS d2_k,
- d2.v AS d2_v
- FROM
- ft
- LEFT JOIN dt AS d1 ON (ft.k = d1.k AND ft.v = d1.k)
- LEFT JOIN dt AS d2 ON (ft.k = d2.v);
- ----
- 1
- 1
- NULL
- NULL
- NULL
- NULL
- 2
- 2
- 2
- 2
- 2
- 2
- 3
- 3
- 3
- 3
- 3
- 3
- 4
- 4
- 4
- 4
- 4
- 4
- 5
- 5
- NULL
- NULL
- NULL
- 5
- NULL
- 0
- NULL
- NULL
- NULL
- NULL
|