should be it
This commit is contained in:
60
external/duckdb/test/sql/timezone/disable_timestamptz_casts.test
vendored
Normal file
60
external/duckdb/test/sql/timezone/disable_timestamptz_casts.test
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# name: test/sql/timezone/disable_timestamptz_casts.test
|
||||
# description: Test for disabling timestamp => timestamptz casts
|
||||
# group: [timezone]
|
||||
|
||||
# Setting has no effect when ICU is not loaded as the two types are equivalent
|
||||
statement ok
|
||||
set disable_timestamptz_casts=false;
|
||||
|
||||
query I
|
||||
select cast('2020-01-01T00:00:00'::timestamp as timestamptz)
|
||||
----
|
||||
2020-01-01 00:00:00+00
|
||||
|
||||
query I
|
||||
select cast('2020-01-01T15:00:00+0000'::timestamptz as timestamp)
|
||||
----
|
||||
2020-01-01 15:00:00
|
||||
|
||||
statement ok
|
||||
set disable_timestamptz_casts=true;
|
||||
|
||||
query I
|
||||
select cast('2020-01-01T00:00:00'::timestamp as timestamptz)
|
||||
----
|
||||
2020-01-01 00:00:00+00
|
||||
|
||||
query I
|
||||
select cast('2020-01-01T15:00:00+0000'::timestamptz as timestamp)
|
||||
----
|
||||
2020-01-01 15:00:00
|
||||
|
||||
# With ICU loaded, the casts are disabled in both directions when the flag is set.
|
||||
require icu
|
||||
|
||||
statement ok
|
||||
set calendar='gregorian';
|
||||
|
||||
statement ok
|
||||
set TimeZone='America/Los_Angeles';
|
||||
|
||||
statement ok
|
||||
set disable_timestamptz_casts=false;
|
||||
|
||||
query I
|
||||
select cast('2020-01-01T00:00:00'::timestamp as timestamptz)
|
||||
----
|
||||
2020-01-01 00:00:00-08
|
||||
|
||||
statement ok
|
||||
set disable_timestamptz_casts=true;
|
||||
|
||||
statement error
|
||||
select cast('2020-01-01T00:00:00'::timestamp as timestamptz)
|
||||
----
|
||||
Casting from TIMESTAMP to TIMESTAMP WITH TIME ZONE without an explicit time zone has been disabled
|
||||
|
||||
statement error
|
||||
select cast('2020-01-01T15:00:00+0000'::timestamptz as timestamp)
|
||||
----
|
||||
Casting from TIMESTAMP WITH TIME ZONE to TIMESTAMP without an explicit time zone has been disabled
|
||||
40
external/duckdb/test/sql/timezone/icu_calendar_operations.test
vendored
Normal file
40
external/duckdb/test/sql/timezone/icu_calendar_operations.test
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# name: test/sql/timezone/icu_calendar_operations.test
|
||||
# description: Test the ICU calendar interface
|
||||
# group: [timezone]
|
||||
|
||||
require icu
|
||||
|
||||
# Normalise the testing locale
|
||||
statement ok
|
||||
SET TimeZone = 'UTC';
|
||||
|
||||
# Test intervals for lunar calendars
|
||||
foreach cal hebrew coptic ethiopic
|
||||
|
||||
statement ok
|
||||
SET Calendar = '${cal}';
|
||||
|
||||
statement error
|
||||
select age('2020-01-01'::timestamptz);
|
||||
----
|
||||
INTERVALs do not work with 13 month calendars. Try using DATE_DIFF instead.
|
||||
|
||||
statement error
|
||||
select '2020-01-01'::timestamptz + interval '380 days'
|
||||
----
|
||||
INTERVALs do not work with 13 month calendars. Try using DATE_DIFF instead.
|
||||
|
||||
statement error
|
||||
select '2021-01-01'::timestamptz - interval '380 days'
|
||||
----
|
||||
INTERVALs do not work with 13 month calendars. Try using DATE_DIFF instead.
|
||||
|
||||
statement error
|
||||
select
|
||||
'2020-01-01'::timestamptz as start_date,
|
||||
'2021-01-01'::timestamptz as end_date,
|
||||
age(end_date, start_date) as delta;
|
||||
----
|
||||
INTERVALs do not work with 13 month calendars. Try using DATE_DIFF instead.
|
||||
|
||||
endloop
|
||||
123
external/duckdb/test/sql/timezone/test_icu_calendar.test
vendored
Normal file
123
external/duckdb/test/sql/timezone/test_icu_calendar.test
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
# name: test/sql/timezone/test_icu_calendar.test
|
||||
# description: Test the ICU calendar interface
|
||||
# group: [timezone]
|
||||
|
||||
require icu
|
||||
|
||||
# Normalise the testing locale
|
||||
statement ok
|
||||
SET Calendar = 'gregorian';
|
||||
|
||||
statement ok
|
||||
SET TimeZone = 'America/Los_Angeles';
|
||||
|
||||
query I
|
||||
SELECT name FROM icu_calendar_names()
|
||||
GROUP BY 1
|
||||
ORDER BY 1;
|
||||
----
|
||||
buddhist
|
||||
chinese
|
||||
coptic
|
||||
dangi
|
||||
ethiopic
|
||||
ethiopic-amete-alem
|
||||
gregorian
|
||||
hebrew
|
||||
indian
|
||||
islamic
|
||||
islamic-civil
|
||||
islamic-rgsa
|
||||
islamic-tbla
|
||||
islamic-umalqura
|
||||
iso8601
|
||||
japanese
|
||||
persian
|
||||
roc
|
||||
|
||||
query IIIII
|
||||
SELECT name, value, description, input_type, scope FROM duckdb_settings() WHERE name = 'Calendar';
|
||||
----
|
||||
Calendar gregorian The current calendar VARCHAR LOCAL
|
||||
|
||||
statement error
|
||||
SET Calendar = 'fnord';
|
||||
----
|
||||
|
||||
#
|
||||
# Japanese calendar testing
|
||||
#
|
||||
|
||||
# Create the table before changing calendars
|
||||
# Otherwise the parser will assume they are Japanese dates
|
||||
statement ok
|
||||
SET TimeZone = 'Asia/Tokyo';
|
||||
|
||||
statement ok
|
||||
CREATE TABLE timestamps AS SELECT ts::TIMESTAMPTZ AS ts, era FROM (VALUES
|
||||
('0645-06-30 00:00:00+00', 'Taika'),
|
||||
('1867-01-01 00:00:00+00', 'Keiou'),
|
||||
('1868-09-07 00:00:00+00', 'Keiou'),
|
||||
('1868-09-08 00:00:00+00', 'Meiji'),
|
||||
('1912-07-29 00:00:00+00', 'Meiji'),
|
||||
('1912-07-30 00:00:00+00', 'Taisho'),
|
||||
('1926-12-24 00:00:00+00', 'Taisho'),
|
||||
('1926-12-25 00:00:00+00', 'Showa'),
|
||||
('1989-01-06 00:00:00+00', 'Showa'),
|
||||
('1989-01-08 00:00:00+00', 'Heisei'),
|
||||
('2019-05-01 00:00:00+00', 'Reiwa'),
|
||||
('2022-01-01 00:00:00+00', 'Reiwa')
|
||||
) tbl(ts, era);
|
||||
|
||||
statement ok
|
||||
SET Calendar = 'japanese';
|
||||
|
||||
query IIIII
|
||||
SELECT name, value, description, input_type, scope FROM duckdb_settings() WHERE name = 'Calendar';
|
||||
----
|
||||
Calendar japanese The current calendar VARCHAR LOCAL
|
||||
|
||||
# See http://www.meijigakuin.ac.jp/~watson/ref/mtsh.html for details on recent era boundaries.
|
||||
query III
|
||||
SELECT era, ts, DATE_PART(['era', 'year', 'month', 'day'], ts)
|
||||
FROM timestamps
|
||||
ORDER BY 2
|
||||
----
|
||||
Taika 0645-06-27 09:18:59+09:18 {'era': 0, 'year': 1, 'month': 6, 'day': 27}
|
||||
Keiou 1867-01-01 09:18:59+09:18 {'era': 231, 'year': 3, 'month': 1, 'day': 1}
|
||||
Keiou 1868-09-07 09:18:59+09:18 {'era': 231, 'year': 4, 'month': 9, 'day': 7}
|
||||
Meiji 1868-09-08 09:18:59+09:18 {'era': 232, 'year': 1, 'month': 9, 'day': 8}
|
||||
Meiji 1912-07-29 09:00:00+09 {'era': 232, 'year': 45, 'month': 7, 'day': 29}
|
||||
Taisho 1912-07-30 09:00:00+09 {'era': 233, 'year': 1, 'month': 7, 'day': 30}
|
||||
Taisho 1926-12-24 09:00:00+09 {'era': 233, 'year': 15, 'month': 12, 'day': 24}
|
||||
Showa 1926-12-25 09:00:00+09 {'era': 234, 'year': 1, 'month': 12, 'day': 25}
|
||||
Showa 1989-01-06 09:00:00+09 {'era': 234, 'year': 64, 'month': 1, 'day': 6}
|
||||
Heisei 1989-01-08 09:00:00+09 {'era': 235, 'year': 1, 'month': 1, 'day': 8}
|
||||
Reiwa 2019-05-01 09:00:00+09 {'era': 236, 'year': 1, 'month': 5, 'day': 1}
|
||||
Reiwa 2022-01-01 09:00:00+09 {'era': 236, 'year': 4, 'month': 1, 'day': 1}
|
||||
|
||||
# Issue #5234
|
||||
statement ok
|
||||
SET CALENDAR='islamic-umalqura';
|
||||
|
||||
statement ok
|
||||
SELECT strftime(TIMESTAMPTZ '-260722-3-4 0:3:52',TIMESTAMP '-285441-5-3 8:3:4'::VARCHAR);
|
||||
|
||||
# Issue #5235
|
||||
statement ok
|
||||
SET CALENDAR='indian';
|
||||
|
||||
query I
|
||||
SELECT TIMESTAMPTZ '-276069-9-30 0:0:00 America/Whitehorse';
|
||||
----
|
||||
276070-10-01 (BC) 18:19:11+09:18
|
||||
|
||||
# Issue #5237
|
||||
statement ok
|
||||
PRAGMA CALENDAR='japanese';
|
||||
|
||||
# The TIMETZ cast is not valid (checked against PG)
|
||||
statement error
|
||||
SELECT strftime(TIMESTAMPTZ '-23831-1-15 2:5:17 America/La_Paz',TIMETZ '0:8:29 America/Cayman'::VARCHAR);
|
||||
----
|
||||
time field value out of range
|
||||
1002
external/duckdb/test/sql/timezone/test_icu_timezone.test
vendored
Normal file
1002
external/duckdb/test/sql/timezone/test_icu_timezone.test
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user