diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-16 16:50:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-16 16:50:34 +0000 |
commit | 7b2d028262d3e100dfc42b94bb705a09a5c7e93d (patch) | |
tree | a957a3e8fac83475e3652d4bae8cab896e6b22a6 /tests/test_optimizer.py | |
parent | Releasing debian version 25.20.1-1. (diff) | |
download | sqlglot-7b2d028262d3e100dfc42b94bb705a09a5c7e93d.tar.xz sqlglot-7b2d028262d3e100dfc42b94bb705a09a5c7e93d.zip |
Merging upstream version 25.21.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r-- | tests/test_optimizer.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index fe5a4d7..857ba1a 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -397,6 +397,38 @@ class TestOptimizer(unittest.TestCase): "SELECT u.user_id AS user_id, l.log_date AS log_date FROM users AS u CROSS JOIN LATERAL (SELECT l1.log_date AS log_date FROM (SELECT l.log_date AS log_date FROM logs AS l WHERE l.user_id = u.user_id AND l.log_date <= 100 ORDER BY l.log_date LIMIT 1) AS l1) AS l", ) + self.assertEqual( + optimizer.qualify.qualify( + parse_one( + "SELECT A.b_id FROM A JOIN B ON A.b_id=B.b_id JOIN C USING(c_id)", + dialect="postgres", + ), + schema={ + "A": {"b_id": "int"}, + "B": {"b_id": "int", "c_id": "int"}, + "C": {"c_id": "int"}, + }, + quote_identifiers=False, + ).sql("postgres"), + "SELECT a.b_id AS b_id FROM a AS a JOIN b AS b ON a.b_id = b.b_id JOIN c AS c ON b.c_id = c.c_id", + ) + self.assertEqual( + optimizer.qualify.qualify( + parse_one( + "SELECT A.b_id FROM A JOIN B ON A.b_id=B.b_id JOIN C ON B.b_id = C.b_id JOIN D USING(d_id)", + dialect="postgres", + ), + schema={ + "A": {"b_id": "int"}, + "B": {"b_id": "int", "d_id": "int"}, + "C": {"b_id": "int"}, + "D": {"d_id": "int"}, + }, + quote_identifiers=False, + ).sql("postgres"), + "SELECT a.b_id AS b_id FROM a AS a JOIN b AS b ON a.b_id = b.b_id JOIN c AS c ON b.b_id = c.b_id JOIN d AS d ON b.d_id = d.d_id", + ) + self.check_file( "qualify_columns", qualify_columns, |