diff options
author | Mars Agliullin <marsaly@ydb.tech> | 2024-02-23 18:01:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 18:01:39 +0300 |
commit | 333feede63ea492968b7dc2fb822aae172567a99 (patch) | |
tree | 7df63e527aabe9484e88852406e8479548b664ae | |
parent | 9e3ac69a90c2b64c60e05875555b713407ca6ac9 (diff) | |
download | ydb-333feede63ea492968b7dc2fb822aae172567a99.tar.gz |
YQL-17315: PG test table deps, part 2 (#2209)
28 files changed, 557 insertions, 256 deletions
diff --git a/ydb/library/yql/tests/postgresql/cases/aggregates.err b/ydb/library/yql/tests/postgresql/cases/aggregates.err index df5a9734d2a..d0d2cfcca0e 100644 --- a/ydb/library/yql/tests/postgresql/cases/aggregates.err +++ b/ydb/library/yql/tests/postgresql/cases/aggregates.err @@ -1,7 +1,7 @@ Registering pre-existing tables INT4_TBL VARCHAR_TBL - INT8_TBL + int8_tbl <sql-statement> -- -- AGGREGATES @@ -543,10 +543,17 @@ SELECT oldcnt(*) AS cnt_1000 FROM onek; <sql-statement> SELECT sum2(q1,q2) FROM int8_tbl; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + SELECT sum2(q1,q2) FROM int8_tbl; + ^ + -stdin-:<main>:1:8: Error: At function: PgCall + SELECT sum2(q1,q2) FROM int8_tbl; + ^ + -stdin-:<main>:1:8: Error: No such proc: sum2 + SELECT sum2(q1,q2) FROM int8_tbl; + ^ <sql-statement> -- test for outer-level aggregates -- this should work @@ -2387,10 +2394,17 @@ drop view aggordview1; -- variadic aggregates select least_agg(q1,q2) from int8_tbl; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + -- variadic aggregates + ^ + -stdin-:<main>:2:8: Error: At function: PgCall + select least_agg(q1,q2) from int8_tbl; + ^ + -stdin-:<main>:2:8: Error: No such proc: least_agg + select least_agg(q1,q2) from int8_tbl; + ^ <sql-statement> select least_agg(variadic array[q1,q2]) from int8_tbl; </sql-statement> @@ -2402,10 +2416,17 @@ select least_agg(variadic array[q1,q2]) from int8_tbl; <sql-statement> select cleast_agg(q1,q2) from int8_tbl; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + select cleast_agg(q1,q2) from int8_tbl; + ^ + -stdin-:<main>:1:8: Error: At function: PgCall + select cleast_agg(q1,q2) from int8_tbl; + ^ + -stdin-:<main>:1:8: Error: No such proc: cleast_agg + select cleast_agg(q1,q2) from int8_tbl; + ^ <sql-statement> select cleast_agg(4.5,f1) from int4_tbl; </sql-statement> diff --git a/ydb/library/yql/tests/postgresql/cases/arrays.err b/ydb/library/yql/tests/postgresql/cases/arrays.err index 235953eb5f4..c07ae35fb1f 100644 --- a/ydb/library/yql/tests/postgresql/cases/arrays.err +++ b/ydb/library/yql/tests/postgresql/cases/arrays.err @@ -1,5 +1,5 @@ Registering pre-existing tables - INT8_TBL + int8_tbl <sql-statement> -- -- ARRAYS diff --git a/ydb/library/yql/tests/postgresql/cases/expressions.err b/ydb/library/yql/tests/postgresql/cases/expressions.err index 69cea1bc26f..d6382b06f01 100644 --- a/ydb/library/yql/tests/postgresql/cases/expressions.err +++ b/ydb/library/yql/tests/postgresql/cases/expressions.err @@ -1,3 +1,5 @@ +Registering pre-existing tables + date_tbl <sql-statement> -- -- expression evaluation tests that don't fit into a more specific file @@ -124,10 +126,6 @@ select count(*) from date_tbl select count(*) from date_tbl where f1 between '1997-01-01' and '1998-01-01'; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.date_tbl - <sql-statement> explain (costs off) select count(*) from date_tbl @@ -142,10 +140,6 @@ select count(*) from date_tbl select count(*) from date_tbl where f1 not between '1997-01-01' and '1998-01-01'; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.date_tbl - <sql-statement> explain (costs off) select count(*) from date_tbl @@ -160,10 +154,6 @@ select count(*) from date_tbl select count(*) from date_tbl where f1 between symmetric '1997-01-01' and '1998-01-01'; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.date_tbl - <sql-statement> explain (costs off) select count(*) from date_tbl @@ -178,10 +168,6 @@ select count(*) from date_tbl select count(*) from date_tbl where f1 not between symmetric '1997-01-01' and '1998-01-01'; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.date_tbl - <sql-statement> -- -- Test parsing of a no-op cast to a type with unspecified typmod diff --git a/ydb/library/yql/tests/postgresql/cases/expressions.out b/ydb/library/yql/tests/postgresql/cases/expressions.out index 42a99dbaaf8..42c42b5942e 100644 --- a/ydb/library/yql/tests/postgresql/cases/expressions.out +++ b/ydb/library/yql/tests/postgresql/cases/expressions.out @@ -38,6 +38,34 @@ SELECT length(current_timestamp::text) >= length(current_timestamp(0)::text); t (1 row) +select count(*) from date_tbl + where f1 between '1997-01-01' and '1998-01-01'; + count +------- + 3 +(1 row) + +select count(*) from date_tbl + where f1 not between '1997-01-01' and '1998-01-01'; + count +------- + 13 +(1 row) + +select count(*) from date_tbl + where f1 between symmetric '1997-01-01' and '1998-01-01'; + count +------- + 3 +(1 row) + +select count(*) from date_tbl + where f1 not between symmetric '1997-01-01' and '1998-01-01'; + count +------- + 13 +(1 row) + -- -- Test parsing of a no-op cast to a type with unspecified typmod -- diff --git a/ydb/library/yql/tests/postgresql/cases/expressions.sql b/ydb/library/yql/tests/postgresql/cases/expressions.sql index 1bacf1999b4..f578b1d2cb9 100644 --- a/ydb/library/yql/tests/postgresql/cases/expressions.sql +++ b/ydb/library/yql/tests/postgresql/cases/expressions.sql @@ -13,6 +13,14 @@ SELECT now()::timetz(4)::text = current_time(4)::text; SELECT current_timestamp = NOW(); -- precision SELECT length(current_timestamp::text) >= length(current_timestamp(0)::text); +select count(*) from date_tbl + where f1 between '1997-01-01' and '1998-01-01'; +select count(*) from date_tbl + where f1 not between '1997-01-01' and '1998-01-01'; +select count(*) from date_tbl + where f1 between symmetric '1997-01-01' and '1998-01-01'; +select count(*) from date_tbl + where f1 not between symmetric '1997-01-01' and '1998-01-01'; -- -- Test parsing of a no-op cast to a type with unspecified typmod -- diff --git a/ydb/library/yql/tests/postgresql/cases/horology.err b/ydb/library/yql/tests/postgresql/cases/horology.err index 1e88f5817d2..29a61b63233 100644 --- a/ydb/library/yql/tests/postgresql/cases/horology.err +++ b/ydb/library/yql/tests/postgresql/cases/horology.err @@ -1,3 +1,9 @@ +Registering pre-existing tables + TIME_TBL + TIMESTAMPTZ_TBL + TIMESTAMP_TBL + INTERVAL_TBL + TIMETZ_TBL <sql-statement> -- -- HOROLOGY @@ -368,17 +374,9 @@ SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_ <sql-statement> SELECT d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SELECT d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SELECT timestamp with time zone '1996-03-01' - interval '1 second' AS "Feb 29"; </sql-statement> @@ -451,17 +449,9 @@ SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_ <sql-statement> SELECT d1 + interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMPTZ_TBL - <sql-statement> SELECT d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMPTZ_TBL - <sql-statement> -- -- time, interval arithmetic @@ -537,28 +527,16 @@ SELECT t.d1 AS t, i.f1 AS i, t.d1 + i.f1 AS "add", t.d1 - i.f1 AS "subtract" AND i.f1 BETWEEN '00:00' AND '23:00' ORDER BY 1,2; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract" FROM TIME_TBL t, INTERVAL_TBL i ORDER BY 1,2; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIME_TBL - <sql-statement> SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract" FROM TIMETZ_TBL t, INTERVAL_TBL i ORDER BY 1,2; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.INTERVAL_TBL - <sql-statement> -- SQL9x OVERLAPS operator -- test with time zone @@ -761,10 +739,6 @@ INSERT INTO TEMP_TIMESTAMP (f1) WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997' OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010'; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SELECT f1 AS "timestamp" FROM TEMP_TIMESTAMP @@ -775,20 +749,12 @@ SELECT d.f1 AS "timestamp", t.f1 AS "interval", d.f1 + t.f1 AS plus FROM TEMP_TIMESTAMP d, INTERVAL_TBL t ORDER BY plus, "timestamp", "interval"; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.INTERVAL_TBL - <sql-statement> SELECT d.f1 AS "timestamp", t.f1 AS "interval", d.f1 - t.f1 AS minus FROM TEMP_TIMESTAMP d, INTERVAL_TBL t WHERE isfinite(d.f1) ORDER BY minus, "timestamp", "interval"; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.INTERVAL_TBL - <sql-statement> SELECT d.f1 AS "timestamp", timestamp with time zone '1980-01-06 00:00 GMT' AS gpstime_zero, @@ -909,10 +875,6 @@ SHOW DateStyle; <sql-statement> SELECT d1 AS us_postgres FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SET DateStyle TO 'US,ISO'; </sql-statement> @@ -924,10 +886,6 @@ SET DateStyle TO 'US,ISO'; <sql-statement> SELECT d1 AS us_iso FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SET DateStyle TO 'US,SQL'; </sql-statement> @@ -947,10 +905,6 @@ SHOW DateStyle; <sql-statement> SELECT d1 AS us_sql FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SET DateStyle TO 'European,Postgres'; </sql-statement> @@ -970,24 +924,22 @@ SHOW DateStyle; <sql-statement> INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957'); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Fatal: Execution + + -stdin-:<main>:1:1: Fatal: Execution of node: YtFill! + INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957'); + ^ + -stdin-:<main>:1:1: Fatal: ERROR: date/time field value out of range: "13/06/1957" +HINT: Perhaps you need a different "datestyle" setting. - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - + INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957'); + ^ <sql-statement> SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957'; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SELECT d1 AS european_postgres FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SET DateStyle TO 'European,ISO'; </sql-statement> @@ -1007,10 +959,6 @@ SHOW DateStyle; <sql-statement> SELECT d1 AS european_iso FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> SET DateStyle TO 'European,SQL'; </sql-statement> @@ -1030,10 +978,6 @@ SHOW DateStyle; <sql-statement> SELECT d1 AS european_sql FROM TIMESTAMP_TBL; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.TIMESTAMP_TBL - <sql-statement> RESET DateStyle; </sql-statement> diff --git a/ydb/library/yql/tests/postgresql/cases/horology.out b/ydb/library/yql/tests/postgresql/cases/horology.out index a67dd635b53..d4bc3dab5f5 100644 --- a/ydb/library/yql/tests/postgresql/cases/horology.out +++ b/ydb/library/yql/tests/postgresql/cases/horology.out @@ -253,6 +253,11 @@ SELECT (time '00:00', time '01:00') (1 row) CREATE TABLE TEMP_TIMESTAMP (f1 timestamp with time zone); +-- get some candidate input values +INSERT INTO TEMP_TIMESTAMP (f1) + SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997' + OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010'; DROP TABLE TEMP_TIMESTAMP; -- -- Comparisons between datetime types, especially overflow cases diff --git a/ydb/library/yql/tests/postgresql/cases/horology.sql b/ydb/library/yql/tests/postgresql/cases/horology.sql index 20f516ef804..2b77db230a0 100644 --- a/ydb/library/yql/tests/postgresql/cases/horology.sql +++ b/ydb/library/yql/tests/postgresql/cases/horology.sql @@ -59,6 +59,11 @@ SELECT (timestamp without time zone '2000-11-26', timestamp without time zone '2 SELECT (time '00:00', time '01:00') OVERLAPS (time '00:30', time '01:30') AS "True"; CREATE TABLE TEMP_TIMESTAMP (f1 timestamp with time zone); +-- get some candidate input values +INSERT INTO TEMP_TIMESTAMP (f1) + SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997' + OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010'; DROP TABLE TEMP_TIMESTAMP; -- -- Comparisons between datetime types, especially overflow cases diff --git a/ydb/library/yql/tests/postgresql/cases/join.err b/ydb/library/yql/tests/postgresql/cases/join.err index 4f618012986..f29bf6e62ce 100644 --- a/ydb/library/yql/tests/postgresql/cases/join.err +++ b/ydb/library/yql/tests/postgresql/cases/join.err @@ -1,9 +1,9 @@ Registering pre-existing tables INT4_TBL INT2_TBL - INT8_TBL TEXT_TBL FLOAT8_TBL + int8_tbl <sql-statement> -- -- JOIN @@ -874,10 +874,14 @@ select * from int8_tbl i1 left join (int8_tbl i2 join (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2 order by 1, 2; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem + select * from int8_tbl i1 left join (int8_tbl i2 join + ^ + -stdin-:<main>:2:35: Error: No such column: x + (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2 + ^ <sql-statement> -- -- regression test: check a case where join_clause_is_movable_into() gives @@ -1641,28 +1645,49 @@ select t1.q2, count(t2.*) from int8_tbl t1 left join int8_tbl t2 on (t1.q2 = t2.q1) group by t1.q2 order by 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + -- + ^ + -stdin-:<main>:4:15: Error: At function: PgAgg + select t1.q2, count(t2.*) + ^ + -stdin-:<main>:4:21: Error: Expected PG type, but got: Struct + select t1.q2, count(t2.*) + ^ <sql-statement> select t1.q2, count(t2.*) from int8_tbl t1 left join (select * from int8_tbl) t2 on (t1.q2 = t2.q1) group by t1.q2 order by 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + select t1.q2, count(t2.*) + ^ + -stdin-:<main>:1:15: Error: At function: PgAgg + select t1.q2, count(t2.*) + ^ + -stdin-:<main>:1:21: Error: Expected PG type, but got: Struct + select t1.q2, count(t2.*) + ^ <sql-statement> select t1.q2, count(t2.*) from int8_tbl t1 left join (select * from int8_tbl offset 0) t2 on (t1.q2 = t2.q1) group by t1.q2 order by 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + select t1.q2, count(t2.*) + ^ + -stdin-:<main>:1:15: Error: At function: PgAgg + select t1.q2, count(t2.*) + ^ + -stdin-:<main>:1:21: Error: Expected PG type, but got: Struct + select t1.q2, count(t2.*) + ^ <sql-statement> select t1.q2, count(t2.*) from int8_tbl t1 left join @@ -1670,10 +1695,17 @@ from int8_tbl t1 left join on (t1.q2 = t2.q1) group by t1.q2 order by 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + select t1.q2, count(t2.*) + ^ + -stdin-:<main>:3:15: Error: At function: If + (select q1, case when q2=1 then 1 else q2 end as q2 from int8_tbl) t2 + ^ + -stdin-:<main>:3:15: Error: Cannot infer common type for int4 and int8 + (select q1, case when q2=1 then 1 else q2 end as q2 from int8_tbl) t2 + ^ <sql-statement> -- -- test incorrect failure to NULL pulled-up subexpressions @@ -1965,10 +1997,6 @@ where 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) order by 1,2; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- -- variant where a PlaceHolderVar is needed at a join, but not above the join @@ -3089,10 +3117,6 @@ select a.q2, b.q1 from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1) where coalesce(b.q1, 1) > 0; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> reset enable_hashjoin; </sql-statement> @@ -3411,10 +3435,6 @@ SELECT * FROM FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss2 ON true; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> rollback; </sql-statement> @@ -3698,10 +3718,26 @@ explain (costs off) -- the first of these should return int8_tbl.q2, the second int8_tbl.q1 select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem + -- check scoping of lateral versus parent references + ^ + -stdin-:<main>:3:11: Error: At function: PgSubLink, At function: PgSelect + select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl; + ^ + -stdin-:<main>:3:11: Error: At function: PgSetItem, At function: PgSelect, At function: PgSetItem + select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl; + ^ + -stdin-:<main>:3:34: Error: Column reference can't be used without FROM + select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl; + ^ + -stdin-:<main>:3:11: Error: At function: PgSelect, At function: PgSetItem + select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl; + ^ + -stdin-:<main>:3:55: Error: Column reference can't be used without FROM + select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl; + ^ <sql-statement> select *, (select r from (select q1 as q2) x, lateral (select q2 as r) y) from int8_tbl; </sql-statement> diff --git a/ydb/library/yql/tests/postgresql/cases/join.out b/ydb/library/yql/tests/postgresql/cases/join.out index 23e3266f5b5..4374b0eec72 100644 --- a/ydb/library/yql/tests/postgresql/cases/join.out +++ b/ydb/library/yql/tests/postgresql/cases/join.out @@ -389,3 +389,22 @@ create temp table nt1 ( insert into nt1 values (1,true,true); insert into nt1 values (2,true,false); insert into nt1 values (3,false,false); +select * from + int8_tbl t1 left join + (select q1 as x, 42 as y from int8_tbl t2) ss + on t1.q2 = ss.x +where + 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) +order by 1,2; + q1 | q2 | x | y +------------------+------------------+------------------+---- + 123 | 4567890123456789 | 4567890123456789 | 42 + 123 | 4567890123456789 | 4567890123456789 | 42 + 123 | 4567890123456789 | 4567890123456789 | 42 + 4567890123456789 | 123 | 123 | 42 + 4567890123456789 | 123 | 123 | 42 + 4567890123456789 | 4567890123456789 | 4567890123456789 | 42 + 4567890123456789 | 4567890123456789 | 4567890123456789 | 42 + 4567890123456789 | 4567890123456789 | 4567890123456789 | 42 +(8 rows) + diff --git a/ydb/library/yql/tests/postgresql/cases/join.sql b/ydb/library/yql/tests/postgresql/cases/join.sql index fd1820a7d99..d7089302f89 100644 --- a/ydb/library/yql/tests/postgresql/cases/join.sql +++ b/ydb/library/yql/tests/postgresql/cases/join.sql @@ -254,3 +254,10 @@ create temp table nt1 ( insert into nt1 values (1,true,true); insert into nt1 values (2,true,false); insert into nt1 values (3,false,false); +select * from + int8_tbl t1 left join + (select q1 as x, 42 as y from int8_tbl t2) ss + on t1.q2 = ss.x +where + 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) +order by 1,2; diff --git a/ydb/library/yql/tests/postgresql/cases/limit.err b/ydb/library/yql/tests/postgresql/cases/limit.err index f7f0a573fe3..800d2f186bf 100644 --- a/ydb/library/yql/tests/postgresql/cases/limit.err +++ b/ydb/library/yql/tests/postgresql/cases/limit.err @@ -1,5 +1,5 @@ Registering pre-existing tables - INT8_TBL + int8_tbl <sql-statement> -- -- LIMIT @@ -90,17 +90,9 @@ SELECT ''::text AS five, unique1, unique2, stringu1 -- constant, so to ensure executor is exercised, do this: select * from int8_tbl limit (case when random() < 0.5 then null::bigint end); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> select * from int8_tbl offset (case when random() < 0.5 then null::bigint end); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- Test assorted cases involving backwards fetch from a LIMIT plan node begin; diff --git a/ydb/library/yql/tests/postgresql/cases/limit.out b/ydb/library/yql/tests/postgresql/cases/limit.out index c70d432bf1a..4191177502e 100644 --- a/ydb/library/yql/tests/postgresql/cases/limit.out +++ b/ydb/library/yql/tests/postgresql/cases/limit.out @@ -1,3 +1,25 @@ +-- Test null limit and offset. The planner would discard a simple null +-- constant, so to ensure executor is exercised, do this: +select * from int8_tbl limit (case when random() < 0.5 then null::bigint end); + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 + 4567890123456789 | -4567890123456789 +(5 rows) + +select * from int8_tbl offset (case when random() < 0.5 then null::bigint end); + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 + 4567890123456789 | -4567890123456789 +(5 rows) + -- Test assorted cases involving backwards fetch from a LIMIT plan node begin; rollback; diff --git a/ydb/library/yql/tests/postgresql/cases/limit.sql b/ydb/library/yql/tests/postgresql/cases/limit.sql index 8af04870f56..57c3a755f22 100644 --- a/ydb/library/yql/tests/postgresql/cases/limit.sql +++ b/ydb/library/yql/tests/postgresql/cases/limit.sql @@ -1,3 +1,7 @@ +-- Test null limit and offset. The planner would discard a simple null +-- constant, so to ensure executor is exercised, do this: +select * from int8_tbl limit (case when random() < 0.5 then null::bigint end); +select * from int8_tbl offset (case when random() < 0.5 then null::bigint end); -- Test assorted cases involving backwards fetch from a LIMIT plan node begin; rollback; diff --git a/ydb/library/yql/tests/postgresql/cases/select.err b/ydb/library/yql/tests/postgresql/cases/select.err index 99ad9ff6f78..23033ca4abb 100644 --- a/ydb/library/yql/tests/postgresql/cases/select.err +++ b/ydb/library/yql/tests/postgresql/cases/select.err @@ -1,5 +1,5 @@ Registering pre-existing tables - INT8_TBL + int8_tbl <sql-statement> -- -- SELECT @@ -316,10 +316,8 @@ SELECT 2+2, 57 UNION ALL TABLE int8_tbl; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Fatal: ydb/library/yql/core/yql_expr_type_annotation.cpp:6766 CheckExpectedTypeAndColumnOrder(): requirement IsSameAnnotation(*node.GetTypeAnn(), *it->second) failed, message: Rewrite error, type should be : List<Struct<'column0':pgint8,'column1':pgnumeric>>, but it is: List<Struct<'column0':Error<'<main>':1:1:'Uncompatible member column0 types: pgint4 and pgint8'>,'column1':pgnumeric>> for node AssumeColumnOrder - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- corner case: VALUES with no columns CREATE TEMP TABLE nocols(); diff --git a/ydb/library/yql/tests/postgresql/cases/select_into.err b/ydb/library/yql/tests/postgresql/cases/select_into.err index 0841f9533ed..b70e742b65b 100644 --- a/ydb/library/yql/tests/postgresql/cases/select_into.err +++ b/ydb/library/yql/tests/postgresql/cases/select_into.err @@ -1,5 +1,5 @@ Registering pre-existing tables - INT8_TBL + int8_tbl <sql-statement> -- -- SELECT_INTO diff --git a/ydb/library/yql/tests/postgresql/cases/subselect.err b/ydb/library/yql/tests/postgresql/cases/subselect.err index e9d991026d7..c7c417787b6 100644 --- a/ydb/library/yql/tests/postgresql/cases/subselect.err +++ b/ydb/library/yql/tests/postgresql/cases/subselect.err @@ -1,7 +1,7 @@ Registering pre-existing tables INT4_TBL - INT8_TBL TEXT_TBL + int8_tbl <sql-statement> -- -- SUBSELECT @@ -205,9 +205,12 @@ SELECT ss.f1 AS "Correlated Field", ss.f3 AS "Second Field" select q1, float8(count(*)) / (select count(*) from int8_tbl) from int8_tbl group by q1 order by q1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Fatal: Optimization - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl + -stdin-:<main>:1:1: Fatal: ydb/library/yql/core/common_opt/yql_co_pgselect.cpp:3236 ExpandPgSelectImpl(): requirement order failed + select q1, float8(count(*)) / (select count(*) from int8_tbl) + ^ + -stdin-:<main>: Fatal: ydb/library/yql/core/common_opt/yql_co_pgselect.cpp:704 RewriteSubLinksPartial(): requirement status.Level != IGraphTransformer::TStatus::Error failed <sql-statement> -- Unspecified-type literals in output columns should resolve as text @@ -808,7 +811,7 @@ from </sql-statement> -stdin-:<main>: Fatal: Table metadata loading - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl + -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int4_tbl <sql-statement> -- @@ -988,10 +991,22 @@ select '1'::text in (select '1'::name union all select '1'::name); -- this fails by default, of course select * from int8_tbl where q1 in (select c1 from inner_text); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect + -- + ^ + -stdin-:<main>: Error: At function: PgSetItem + + -stdin-:<main>:1:1: Error: At function: PgWhere + -- + ^ + -stdin-:<main>:6:33: Error: At function: PgSubLink, At function: PgOp + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>:6:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text) + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ <sql-statement> begin; </sql-statement> @@ -1025,10 +1040,22 @@ select * from int8_tbl where q1 in (select c1 from inner_text); <sql-statement> select * from int8_tbl where q1 in (select c1 from inner_text); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>: Error: At function: PgSetItem + + -stdin-:<main>:1:1: Error: At function: PgWhere + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>:1:33: Error: At function: PgSubLink, At function: PgOp + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>:1:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text) + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ <sql-statement> -- inlining of this function results in unusual number of hash clauses, -- which we can still cope with @@ -1052,10 +1079,22 @@ select * from int8_tbl where q1 in (select c1 from inner_text); <sql-statement> select * from int8_tbl where q1 in (select c1 from inner_text); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>: Error: At function: PgSetItem + + -stdin-:<main>:1:1: Error: At function: PgWhere + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>:1:33: Error: At function: PgSubLink, At function: PgOp + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>:1:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text) + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ <sql-statement> -- inlining of this function causes LHS and RHS to be switched, -- which we can't cope with, so hashing should be abandoned @@ -1079,10 +1118,22 @@ select * from int8_tbl where q1 in (select c1 from inner_text); <sql-statement> select * from int8_tbl where q1 in (select c1 from inner_text); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading +-stdin-:<main>: Error: Type annotation - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - + -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>: Error: At function: PgSetItem + + -stdin-:<main>:1:1: Error: At function: PgWhere + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>:1:33: Error: At function: PgSubLink, At function: PgOp + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ + -stdin-:<main>:1:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text) + select * from int8_tbl where q1 in (select c1 from inner_text); + ^ <sql-statement> rollback; -- to get rid of the bogus operator </sql-statement> diff --git a/ydb/library/yql/tests/postgresql/cases/union.err b/ydb/library/yql/tests/postgresql/cases/union.err index 1717541394b..8ed080cd15f 100644 --- a/ydb/library/yql/tests/postgresql/cases/union.err +++ b/ydb/library/yql/tests/postgresql/cases/union.err @@ -1,10 +1,10 @@ Registering pre-existing tables INT4_TBL VARCHAR_TBL - INT8_TBL CHAR_TBL TEXT_TBL FLOAT8_TBL + int8_tbl <sql-statement> -- -- UNION (also INTERSECT, EXCEPT) @@ -141,71 +141,30 @@ ORDER BY 1; -- SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl FOR NO KEY UPDATE; </sql-statement> --stdin-:<main>: Warning: Parse Sql - - -stdin-:<main>:1:1: Warning: SelectStmt: lockingClause is ignored - SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl FOR NO KEY UPDATE; - ^ --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- nested cases (SELECT 1,2,3 UNION SELECT 4,5,6) INTERSECT SELECT 4,5,6; @@ -714,45 +673,21 @@ SELECT f1 FROM float8_tbl EXCEPT SELECT f1 FROM int4_tbl ORDER BY 1; -- SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q1 FROM int8_tbl INTERSECT (((SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> (((SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl ORDER BY 1))) UNION ALL SELECT q2 FROM int8_tbl; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1))); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> (((SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- -- Subqueries with ORDER BY & LIMIT clauses @@ -761,10 +696,6 @@ SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FR SELECT q1,q2 FROM int8_tbl EXCEPT SELECT q2,q1 FROM int8_tbl ORDER BY q2,q1; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- This should fail, because q2 isn't a name of an EXCEPT output column SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1; @@ -789,10 +720,6 @@ SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))) -- (((((select * from int8_tbl))))); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- -- Check behavior with empty select list (allowed since 9.4) @@ -1352,10 +1279,6 @@ select distinct q1 from select distinct * from int8_tbl i82) ss where q2 = q2; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> explain (costs off) select distinct q1 from @@ -1376,10 +1299,6 @@ select distinct q1 from select distinct * from int8_tbl i82) ss where -q1 = q2; </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - <sql-statement> -- Test proper handling of parameterized appendrel paths when the -- potential join qual is expensive @@ -1468,7 +1387,3 @@ select * from select *, 1 as x from int8_tbl b) ss where (x = 0) or (q1 >= q2 and q1 <= q2); </sql-statement> --stdin-:<main>: Fatal: Table metadata loading - - -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.int8_tbl - diff --git a/ydb/library/yql/tests/postgresql/cases/union.out b/ydb/library/yql/tests/postgresql/cases/union.out index d0a00d49f42..2b575fb54a5 100644 --- a/ydb/library/yql/tests/postgresql/cases/union.out +++ b/ydb/library/yql/tests/postgresql/cases/union.out @@ -165,6 +165,61 @@ ORDER BY 1; hi de ho neighbor (5 rows) +-- +-- INTERSECT and EXCEPT +-- +SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------ + 123 + 4567890123456789 +(2 rows) + +SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------ + 123 + 4567890123456789 + 4567890123456789 +(3 rows) + +SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------- + -4567890123456789 + 456 +(2 rows) + +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------- + -4567890123456789 + 456 +(2 rows) + +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------- + -4567890123456789 + 456 + 4567890123456789 +(3 rows) + +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1; + q1 +------------------ + 123 + 4567890123456789 +(2 rows) + +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1; + q1 +------------------ + 123 + 4567890123456789 + 4567890123456789 +(3 rows) + -- nested cases (SELECT 1,2,3 UNION SELECT 4,5,6) INTERSECT SELECT 4,5,6; ?column? | ?column? | ?column? @@ -214,6 +269,77 @@ select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (v {1,3} (1 row) +-- +-- Operator precedence and (((((extra))))) parentheses +-- +SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1; + q1 +------------------- + -4567890123456789 + 123 + 123 + 456 + 4567890123456789 + 4567890123456789 + 4567890123456789 +(7 rows) + +SELECT q1 FROM int8_tbl INTERSECT (((SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) ORDER BY 1; + q1 +------------------ + 123 + 4567890123456789 +(2 rows) + +(((SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl ORDER BY 1))) UNION ALL SELECT q2 FROM int8_tbl; + q1 +------------------- + 123 + 4567890123456789 + 456 + 4567890123456789 + 123 + 4567890123456789 + -4567890123456789 +(7 rows) + +SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1))); + q1 +------------------- + 123 + 123 + 4567890123456789 + 4567890123456789 + 4567890123456789 + -4567890123456789 + 456 +(7 rows) + +-- +-- Subqueries with ORDER BY & LIMIT clauses +-- +-- In this syntax, ORDER BY/LIMIT apply to the result of the EXCEPT +SELECT q1,q2 FROM int8_tbl EXCEPT SELECT q2,q1 FROM int8_tbl +ORDER BY q2,q1; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 123 | 456 +(2 rows) + +-- +-- New syntaxes (7.1) permit new tests +-- +(((((select * from int8_tbl))))); + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 + 4567890123456789 | -4567890123456789 +(5 rows) + -- This should fail, but it should produce an error cursor SELECT '3.4'::numeric UNION SELECT 'foo'; ERROR: invalid input syntax for type numeric: "foo" @@ -259,3 +385,24 @@ ORDER BY x; 2 | 4 (1 row) +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where q2 = q2; + q1 +------------------ + 123 + 4567890123456789 +(2 rows) + +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where -q1 = q2; + q1 +------------------ + 4567890123456789 +(1 row) + diff --git a/ydb/library/yql/tests/postgresql/cases/union.sql b/ydb/library/yql/tests/postgresql/cases/union.sql index d1d952b73de..945fab6f3ff 100644 --- a/ydb/library/yql/tests/postgresql/cases/union.sql +++ b/ydb/library/yql/tests/postgresql/cases/union.sql @@ -33,6 +33,16 @@ SELECT f1 FROM VARCHAR_TBL UNION SELECT TRIM(TRAILING FROM f1) FROM CHAR_TBL ORDER BY 1; +-- +-- INTERSECT and EXCEPT +-- +SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1; +SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1; +SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1; +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1; +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1; +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1; -- nested cases (SELECT 1,2,3 UNION SELECT 4,5,6) INTERSECT SELECT 4,5,6; (SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) INTERSECT SELECT 4,5,6; @@ -42,6 +52,23 @@ select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x); select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x); select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x); +-- +-- Operator precedence and (((((extra))))) parentheses +-- +SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1; +SELECT q1 FROM int8_tbl INTERSECT (((SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) ORDER BY 1; +(((SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl ORDER BY 1))) UNION ALL SELECT q2 FROM int8_tbl; +SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1))); +-- +-- Subqueries with ORDER BY & LIMIT clauses +-- +-- In this syntax, ORDER BY/LIMIT apply to the result of the EXCEPT +SELECT q1,q2 FROM int8_tbl EXCEPT SELECT q2,q1 FROM int8_tbl +ORDER BY q2,q1; +-- +-- New syntaxes (7.1) permit new tests +-- +(((((select * from int8_tbl))))); -- This should fail, but it should produce an error cursor SELECT '3.4'::numeric UNION SELECT 'foo'; -- @@ -74,3 +101,13 @@ SELECT * FROM SELECT 2 AS t, 4 AS x) ss WHERE x > 3 ORDER BY x; +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where q2 = q2; +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where -q1 = q2; diff --git a/ydb/library/yql/tests/postgresql/initscripts/date_tbl.sql b/ydb/library/yql/tests/postgresql/initscripts/date_tbl.sql new file mode 100644 index 00000000000..f66a7531e51 --- /dev/null +++ b/ydb/library/yql/tests/postgresql/initscripts/date_tbl.sql @@ -0,0 +1,19 @@ +CREATE TABLE date_tbl (f1 date); + +INSERT INTO date_tbl VALUES ('1957-04-09'); +INSERT INTO date_tbl VALUES ('1957-06-13'); +INSERT INTO date_tbl VALUES ('1996-02-28'); +INSERT INTO date_tbl VALUES ('1996-02-29'); +INSERT INTO date_tbl VALUES ('1996-03-01'); +INSERT INTO date_tbl VALUES ('1996-03-02'); +INSERT INTO date_tbl VALUES ('1997-02-28'); +INSERT INTO date_tbl VALUES ('1997-03-01'); +INSERT INTO date_tbl VALUES ('1997-03-02'); +INSERT INTO date_tbl VALUES ('2000-04-01'); +INSERT INTO date_tbl VALUES ('2000-04-02'); +INSERT INTO date_tbl VALUES ('2000-04-03'); +INSERT INTO date_tbl VALUES ('2038-04-08'); +INSERT INTO date_tbl VALUES ('2039-04-09'); +INSERT INTO date_tbl VALUES ('2040-04-10'); +INSERT INTO date_tbl VALUES ('2040-04-10 BC'); + diff --git a/ydb/library/yql/tests/postgresql/initscripts/int8_tbl.sql b/ydb/library/yql/tests/postgresql/initscripts/int8_tbl.sql index eaee6cb3af7..a8d08d85ca3 100644 --- a/ydb/library/yql/tests/postgresql/initscripts/int8_tbl.sql +++ b/ydb/library/yql/tests/postgresql/initscripts/int8_tbl.sql @@ -1,8 +1,8 @@ -CREATE TABLE INT8_TBL(q1 int8, q2 int8); +CREATE TABLE int8_tbl(q1 int8, q2 int8); -INSERT INTO INT8_TBL VALUES(' 123 ',' 456'); -INSERT INTO INT8_TBL VALUES('123 ','4567890123456789'); -INSERT INTO INT8_TBL VALUES('4567890123456789','123'); -INSERT INTO INT8_TBL VALUES(+4567890123456789,'4567890123456789'); -INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789'); +INSERT INTO int8_tbl VALUES(' 123 ',' 456'); +INSERT INTO int8_tbl VALUES('123 ','4567890123456789'); +INSERT INTO int8_tbl VALUES('4567890123456789','123'); +INSERT INTO int8_tbl VALUES(+4567890123456789,'4567890123456789'); +INSERT INTO int8_tbl VALUES('+4567890123456789','-4567890123456789'); diff --git a/ydb/library/yql/tests/postgresql/initscripts/interval_tbl.sql b/ydb/library/yql/tests/postgresql/initscripts/interval_tbl.sql new file mode 100644 index 00000000000..f3de944b308 --- /dev/null +++ b/ydb/library/yql/tests/postgresql/initscripts/interval_tbl.sql @@ -0,0 +1,13 @@ +CREATE TABLE INTERVAL_TBL (f1 interval); + +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 1 minute'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 5 hour'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 10 day'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 34 year'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 3 months'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 14 seconds ago'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('1 day 2 hours 3 minutes 4 seconds'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('6 years'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months'); +INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months 12 hours'); + diff --git a/ydb/library/yql/tests/postgresql/initscripts/time_tbl.sql b/ydb/library/yql/tests/postgresql/initscripts/time_tbl.sql new file mode 100644 index 00000000000..89370b580c9 --- /dev/null +++ b/ydb/library/yql/tests/postgresql/initscripts/time_tbl.sql @@ -0,0 +1,13 @@ +CREATE TABLE TIME_TBL (f1 time(2)); + +INSERT INTO TIME_TBL VALUES ('00:00'); +INSERT INTO TIME_TBL VALUES ('01:00'); +INSERT INTO TIME_TBL VALUES ('02:03 PST'); +INSERT INTO TIME_TBL VALUES ('11:59 EDT'); +INSERT INTO TIME_TBL VALUES ('12:00'); +INSERT INTO TIME_TBL VALUES ('12:01'); +INSERT INTO TIME_TBL VALUES ('23:59'); +INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM'); +INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York'); +INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York'); + diff --git a/ydb/library/yql/tests/postgresql/initscripts/timestamp_tbl.sql b/ydb/library/yql/tests/postgresql/initscripts/timestamp_tbl.sql new file mode 100644 index 00000000000..5c8947332ee --- /dev/null +++ b/ydb/library/yql/tests/postgresql/initscripts/timestamp_tbl.sql @@ -0,0 +1,8 @@ +CREATE TABLE TIMESTAMP_TBL (d1 timestamp(2) without time zone); + +INSERT INTO TIMESTAMP_TBL VALUES ('today'); +INSERT INTO TIMESTAMP_TBL VALUES ('yesterday'); +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow'); +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow EST'); +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu'); + diff --git a/ydb/library/yql/tests/postgresql/initscripts/timestamptz_tbl.sql b/ydb/library/yql/tests/postgresql/initscripts/timestamptz_tbl.sql new file mode 100644 index 00000000000..5cd4d22d215 --- /dev/null +++ b/ydb/library/yql/tests/postgresql/initscripts/timestamptz_tbl.sql @@ -0,0 +1,8 @@ +CREATE TABLE TIMESTAMPTZ_TBL (d1 timestamp(2) with time zone); + +INSERT INTO TIMESTAMPTZ_TBL VALUES ('today'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('yesterday'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow EST'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow zulu'); + diff --git a/ydb/library/yql/tests/postgresql/initscripts/timetz_tbl.sql b/ydb/library/yql/tests/postgresql/initscripts/timetz_tbl.sql new file mode 100644 index 00000000000..00e9cb14c3a --- /dev/null +++ b/ydb/library/yql/tests/postgresql/initscripts/timetz_tbl.sql @@ -0,0 +1,15 @@ +CREATE TABLE TIMETZ_TBL (f1 time(2) with time zone); + +INSERT INTO TIMETZ_TBL VALUES ('00:01 PDT'); +INSERT INTO TIMETZ_TBL VALUES ('01:00 PDT'); +INSERT INTO TIMETZ_TBL VALUES ('02:03 PDT'); +INSERT INTO TIMETZ_TBL VALUES ('07:07 PST'); +INSERT INTO TIMETZ_TBL VALUES ('08:08 EDT'); +INSERT INTO TIMETZ_TBL VALUES ('11:59 PDT'); +INSERT INTO TIMETZ_TBL VALUES ('12:00 PDT'); +INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT'); +INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT'); +INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT'); +INSERT INTO TIMETZ_TBL VALUES ('2003-03-07 15:36:39 America/New_York'); +INSERT INTO TIMETZ_TBL VALUES ('2003-07-07 15:36:39 America/New_York'); + diff --git a/ydb/library/yql/tests/postgresql/pg_tests.csv b/ydb/library/yql/tests/postgresql/pg_tests.csv index 2b540af6f8c..217a998cbeb 100644 --- a/ydb/library/yql/tests/postgresql/pg_tests.csv +++ b/ydb/library/yql/tests/postgresql/pg_tests.csv @@ -12,24 +12,24 @@ create_table,368,48,13.04 date,264,202,76.52
dbsize,24,20,83.33
delete,10,5,50.0
-expressions,63,14,22.22
+expressions,63,18,28.57
float4,96,82,85.42
float8,168,139,82.74
functional_deps,40,7,17.5
-horology,306,79,25.82
+horology,306,80,26.14
insert,357,15,4.2
int2,49,47,95.92
int4,70,68,97.14
int8,142,127,89.44
interval,168,115,68.45
-join,591,134,22.67
+join,591,135,22.84
json,450,135,30.0
json_encoding,42,42,100.0
jsonb,1013,404,39.88
jsonb_jsonpath,427,88,20.61
jsonpath,169,152,89.94
jsonpath_encoding,31,31,100.0
-limit,84,5,5.95
+limit,84,7,8.33
name,40,22,55.0
numeric,915,813,88.85
numerology,24,16,66.67
@@ -49,7 +49,7 @@ timestamptz,315,97,30.79 timetz,45,19,42.22
truncate,193,41,21.24
unicode,13,4,30.77
-union,186,40,21.51
+union,186,55,29.57
update,288,23,7.99
varchar,24,15,62.5
window,298,5,1.68
|