diff options
author | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-19 14:11:52 +0300 |
---|---|---|
committer | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-19 14:22:01 +0300 |
commit | 72b3cd51dc3fb9d16975d353ea82fd85701393cc (patch) | |
tree | 318141940b8bf6bdb37ad6154e745e2ebfe3613f /yql/essentials/tests/postgresql/cases/timestamptz.out | |
parent | 223625eed56ec3e2808c010eac46dba1c9a64d13 (diff) | |
download | ydb-72b3cd51dc3fb9d16975d353ea82fd85701393cc.tar.gz |
YQL-19206 Move contrib/ydb/library/yql/tests/postgresql -> yql/essentials/tests/postgresql
commit_hash:46fdf59714b20cf2b61233a06e58365227d3c8b2
Diffstat (limited to 'yql/essentials/tests/postgresql/cases/timestamptz.out')
-rw-r--r-- | yql/essentials/tests/postgresql/cases/timestamptz.out | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/yql/essentials/tests/postgresql/cases/timestamptz.out b/yql/essentials/tests/postgresql/cases/timestamptz.out new file mode 100644 index 0000000000..d666f9851b --- /dev/null +++ b/yql/essentials/tests/postgresql/cases/timestamptz.out @@ -0,0 +1,264 @@ +-- +-- TIMESTAMPTZ +-- +CREATE TABLE TIMESTAMPTZ_TBL (d1 timestamp(2) with time zone); +-- Test shorthand input values +-- We can't just "select" the results since they aren't constants; test for +-- equality instead. We can do that by running the test inside a transaction +-- block, within which the value of 'now' shouldn't change, and so these +-- related values shouldn't either. +BEGIN; +INSERT INTO TIMESTAMPTZ_TBL VALUES ('today'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('yesterday'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow'); +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'today'; + one +----- + 1 +(1 row) + +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow'; + one +----- + 1 +(1 row) + +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'yesterday'; + one +----- + 1 +(1 row) + +COMMIT; +-- Verify that 'now' *does* change over a reasonable interval such as 100 msec, +-- and that it doesn't change over the same interval within a transaction block +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now'); +SELECT pg_sleep(0.1); + pg_sleep +---------- + +(1 row) + +BEGIN; +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now'); +SELECT pg_sleep(0.1); + pg_sleep +---------- + +(1 row) + +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now'); +SELECT pg_sleep(0.1); + pg_sleep +---------- + +(1 row) + +COMMIT; +-- Special values +INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch'); +-- ISO 8601 format +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02 03:04:05'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-08'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-0800'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 -08:00'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 -0800'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 17:32:01 -07:00'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2001-09-22T18:19:20'); +-- POSIX format (note that the timezone abbrev is just decoration here) +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 08:14:01 GMT+8'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 13:14:02 GMT-1'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 12:14:03 GMT-2'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 03:14:04 PST+8'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 02:14:05 MST+7:00'); +-- Variations for acceptable input formats +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997 -0800'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 5:32PM 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997/02/10 17:32:01-0800'); +set datestyle to ymd; +reset datestyle; +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/Does_not_exist'); +ERROR: time zone "america/does_not_exist" not recognized +LINE 1: INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America... + ^ +SELECT '19970710 173201' AT TIME ZONE 'America/Does_not_exist'; +ERROR: time zone "America/Does_not_exist" not recognized +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 11 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 12 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 13 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 14 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 15 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097 BC'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0597'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1097'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1697'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1797'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1897'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 2097'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1996'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1996'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1996'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1996'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997'); +ERROR: date/time field value out of range: "Feb 29 17:32:01 1997" +LINE 1: INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997'); + ^ +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1999'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2000'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000'); +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001'); +-- Currently unsupported syntax and ranges +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097'); +ERROR: time zone displacement out of range: "Feb 16 17:32:01 -0097" +LINE 1: INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097')... + ^ +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC'); +ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC" +LINE 1: INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC... + ^ +SELECT '4714-11-23 23:59:59+00 BC'::timestamptz; -- out of range +ERROR: timestamp out of range: "4714-11-23 23:59:59+00 BC" +LINE 1: SELECT '4714-11-23 23:59:59+00 BC'::timestamptz; + ^ +SELECT '294277-01-01 00:00:00+00'::timestamptz; -- out of range +ERROR: timestamp out of range: "294277-01-01 00:00:00+00" +LINE 1: SELECT '294277-01-01 00:00:00+00'::timestamptz; + ^ +SELECT '294277-12-31 16:00:00-08'::timestamptz; -- out of range +ERROR: timestamp out of range: "294277-12-31 16:00:00-08" +LINE 1: SELECT '294277-12-31 16:00:00-08'::timestamptz; + ^ +-- disallow intervals with months or years +SELECT date_bin('5 months'::interval, timestamp with time zone '2020-02-01 01:01:01+00', timestamp with time zone '2001-01-01+00'); +ERROR: timestamps cannot be binned into intervals containing months or years +SELECT date_bin('5 years'::interval, timestamp with time zone '2020-02-01 01:01:01+00', timestamp with time zone '2001-01-01+00'); +ERROR: timestamps cannot be binned into intervals containing months or years +-- disallow zero intervals +SELECT date_bin('0 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00'); +ERROR: stride must be greater than zero +-- disallow negative intervals +SELECT date_bin('-2 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00'); +ERROR: stride must be greater than zero +-- value near upper bound uses special case in code +SELECT date_part('epoch', '294270-01-01 00:00:00+00'::timestamptz); + date_part +--------------- + 9224097091200 +(1 row) + +SELECT extract(epoch from '294270-01-01 00:00:00+00'::timestamptz); + extract +---------------------- + 9224097091200.000000 +(1 row) + +-- another internal overflow test case +SELECT extract(epoch from '5000-01-01 00:00:00+00'::timestamptz); + extract +-------------------- + 95617584000.000000 +(1 row) + +SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US') + FROM (VALUES + ('2018-11-02 12:34:56'::timestamptz), + ('2018-11-02 12:34:56.78'), + ('2018-11-02 12:34:56.78901'), + ('2018-11-02 12:34:56.78901234') + ) d(d); + to_char +-------------------------------------------------------------------- + 0 00 000 0000 00000 000000 0 00 000 0000 00000 000000 000 000000 + 7 78 780 7800 78000 780000 7 78 780 7800 78000 780000 780 780000 + 7 78 789 7890 78901 789010 7 78 789 7890 78901 789010 789 789010 + 7 78 789 7890 78901 789012 7 78 789 7890 78901 789012 789 789012 +(4 rows) + +-- Check OF, TZH, TZM with various zone offsets, particularly fractional hours +SET timezone = '00:00'; +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM"; + OF | TZH:TZM +-----+--------- + +00 | +00:00 +(1 row) + +SET timezone = '+02:00'; +SET timezone = '-13:00'; +SET timezone = '-00:30'; +SET timezone = '00:30'; +SET timezone = '-04:30'; +SET timezone = '04:30'; +SET timezone = '-04:15'; +SET timezone = '04:15'; +RESET timezone; +CREATE TABLE TIMESTAMPTZ_TST (a int , b timestamptz); +--Cleanup +DROP TABLE TIMESTAMPTZ_TST; +-- test timestamptz constructors +set TimeZone to 'America/New_York'; +-- these should fail +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '2'); +ERROR: invalid input syntax for type numeric time zone: "2" +HINT: Numeric time zones must have "-" or "+" as first character. +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '+16'); +ERROR: numeric time zone "+16" out of range +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '-16'); +ERROR: numeric time zone "-16" out of range +-- should be true +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '+2') = '1973-07-15 08:15:55.33+02'::timestamptz; + ?column? +---------- + t +(1 row) + +SELECT make_timestamptz(1910, 12, 24, 0, 0, 0, 'Nehwon/Lankhmar'); +ERROR: time zone "Nehwon/Lankhmar" not recognized +RESET TimeZone; +-- errors +select * from generate_series('2020-01-01 00:00'::timestamptz, + '2020-01-02 03:00'::timestamptz, + '0 hour'::interval); +ERROR: step size cannot equal zero +-- +-- Test behavior with a dynamic (time-varying) timezone abbreviation. +-- These tests rely on the knowledge that MSK (Europe/Moscow standard time) +-- moved forwards in Mar 2011 and backwards again in Oct 2014. +-- +SET TimeZone to 'UTC'; +-- upper limit varies between integer and float timestamps, so hard to test +-- nonfinite values +SELECT to_timestamp(' Infinity'::float); + to_timestamp +-------------- + infinity +(1 row) + +SELECT to_timestamp('-Infinity'::float); + to_timestamp +-------------- + -infinity +(1 row) + +SELECT to_timestamp('NaN'::float); +ERROR: timestamp cannot be NaN +SET TimeZone to 'Europe/Moscow'; +RESET TimeZone; +-- +-- Test that AT TIME ZONE isn't misoptimized when using an index (bug #14504) +-- +create temp table tmptz (f1 timestamptz primary key); +insert into tmptz values ('2017-01-18 00:00+00'); |