diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-16 09:41:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-16 09:41:15 +0000 |
commit | 358a09296d7198a4cc142f1976de8f3eb3318e58 (patch) | |
tree | 762db96c44014dc4db5e9fc7f6709c138589155e /tests/fixtures/optimizer/optimizer.sql | |
parent | Adding upstream version 15.2.0. (diff) | |
download | sqlglot-358a09296d7198a4cc142f1976de8f3eb3318e58.tar.xz sqlglot-358a09296d7198a4cc142f1976de8f3eb3318e58.zip |
Adding upstream version 16.2.1.upstream/16.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/fixtures/optimizer/optimizer.sql')
-rw-r--r-- | tests/fixtures/optimizer/optimizer.sql | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql index e0567d7..0cb1a58 100644 --- a/tests/fixtures/optimizer/optimizer.sql +++ b/tests/fixtures/optimizer/optimizer.sql @@ -101,10 +101,10 @@ SELECT "x"."a" AS "a", SUM("y"."b") AS "sum_b" FROM "x" AS "x" -JOIN "y" AS "y" - ON "x"."b" = "y"."b" LEFT JOIN "_u_0" AS "_u_0" ON "x"."b" = "_u_0"."_u_1" +JOIN "y" AS "y" + ON "x"."b" = "y"."b" WHERE "_u_0"."_col_0" >= 0 AND "x"."a" > 1 GROUP BY @@ -210,10 +210,10 @@ SELECT "n"."b" AS "b", "o"."b" AS "b" FROM "n" -FULL JOIN "o" - ON "n"."a" = "o"."a" JOIN "n" AS "n2" ON "n"."a" = "n2"."a" +FULL JOIN "o" + ON "n"."a" = "o"."a" WHERE "o"."b" > 0; @@ -619,3 +619,30 @@ WITH "foO" AS ( SELECT "foO"."x" AS "x" FROM "foO" AS "foO"; + +# title: lateral subquery +# execute: false +# dialect: postgres +SELECT u.user_id, l.log_date +FROM users u +CROSS JOIN LATERAL ( + SELECT l.log_date + FROM logs l + WHERE l.user_id = u.user_id AND l.log_date <= 100 + ORDER BY l.log_date DESC NULLS LAST + LIMIT 1 +) l; +SELECT + "u"."user_id" AS "user_id", + "l"."log_date" AS "log_date" +FROM "users" AS "u" +CROSS JOIN LATERAL ( + SELECT + "l"."log_date" + FROM "logs" AS "l" + WHERE + "l"."log_date" <= 100 AND "l"."user_id" = "u"."user_id" + ORDER BY + "l"."log_date" DESC NULLS LAST + LIMIT 1 +) AS "l"; |