aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/datetime
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-11-20 11:14:58 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-11-20 11:14:58 +0000
commit31773f157bf8164364649b5f470f52dece0a4317 (patch)
tree33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /yql/essentials/tests/sql/suites/datetime
parent2c7938962d8689e175574fc1e817c05049f27905 (diff)
parenteff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff)
downloadydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'yql/essentials/tests/sql/suites/datetime')
-rw-r--r--yql/essentials/tests/sql/suites/datetime/all_timezones.sql7
-rw-r--r--yql/essentials/tests/sql/suites/datetime/current_date.sql5
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_arithmetic.sql26
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_bitcast.sql36
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_cast.sql97
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_convert.sql24
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_diff_compare.sql24
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_diff_sub.sql7
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_in.sql35
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_out.sql17
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_scale.sql7
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_types.sql15
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz.txt2
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_addremove.sql5
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_arithmetic.sql24
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_bitcast.sql27
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_bounds.sql17
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_bounds_scale.sql31
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_bytes.sql10
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_cast.sql47
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_compare_diff_zones.sql24
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_compare_gmt.sql42
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_compare_same_zones.sql42
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_expand_gmt.sql5
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.cfg1
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.sql6
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_io.sql5
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_scale.sql14
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.cfg2
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.sql12
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.cfg2
-rw-r--r--yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.sql12
-rw-r--r--yql/essentials/tests/sql/suites/datetime/default.cfg1
-rw-r--r--yql/essentials/tests/sql/suites/datetime/input.txt4
34 files changed, 635 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/datetime/all_timezones.sql b/yql/essentials/tests/sql/suites/datetime/all_timezones.sql
new file mode 100644
index 0000000000..517f03c1cf
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/all_timezones.sql
@@ -0,0 +1,7 @@
+/* syntax version 1 */
+$zones = CAST(ListMap(
+ ListFromRange(0us, 1000us),
+ ($i) -> { RETURN AsStruct($i AS id, SUBSTRING(CAST(YQL::AddTimezone(CurrentUtcDate(), $i) AS String), 11, NULL) AS zone) }
+) AS List<Struct<id:Uint16, zone:Utf8>>);
+
+SELECT * FROM AS_TABLE($zones);
diff --git a/yql/essentials/tests/sql/suites/datetime/current_date.sql b/yql/essentials/tests/sql/suites/datetime/current_date.sql
new file mode 100644
index 0000000000..4743ca6b87
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/current_date.sql
@@ -0,0 +1,5 @@
+/* postgres can not */
+SELECT
+ cast(CurrentUtcDate() as string) as `date`,
+ cast(CurrentUtcDatetime() as string) as `datetime`,
+ cast(CurrentUtcTimestamp() as string) as `timestamp`;
diff --git a/yql/essentials/tests/sql/suites/datetime/date_arithmetic.sql b/yql/essentials/tests/sql/suites/datetime/date_arithmetic.sql
new file mode 100644
index 0000000000..ac921b75d3
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_arithmetic.sql
@@ -0,0 +1,26 @@
+/* postgres can not */
+select cast(date("1970-01-02") - date("1970-01-01") as string);
+
+select cast(date("1970-01-01") + interval("P1D") as string);
+select cast(interval("P1D") + date("1970-01-01") as string);
+select cast(date("1970-01-02") - interval("P1D") as string);
+
+select cast(datetime("1970-01-02T00:00:00Z") - datetime("1970-01-01T00:00:00Z") as string);
+
+select cast(datetime("1970-01-01T00:00:00Z") + interval("P1D") as string);
+select cast(interval("P1D") + datetime("1970-01-01T00:00:00Z") as string);
+select cast(datetime("1970-01-02T00:00:00Z") - interval("P1D") as string);
+
+select cast(timestamp("1970-01-02T00:00:00.6Z") - timestamp("1970-01-01T00:00:00.3Z") as string);
+
+select cast(timestamp("1970-01-01T00:00:00.6Z") + interval("P1D") as string);
+select cast(interval("P1D") + timestamp("1970-01-01T00:00:00.6Z") as string);
+select cast(timestamp("1970-01-02T00:00:00.6Z") - interval("P1D") as string);
+
+select cast(interval("P1D") + interval("P1D") as string);
+select cast(interval("P1D") - interval("P1D") as string);
+
+select cast(interval("P1D") * 2l as string);
+select cast(2u * interval("P1D") as string);
+select cast(interval("P1D") / 2 as string);
+select cast(interval("P1D") / 0ut as string);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_bitcast.sql b/yql/essentials/tests/sql/suites/datetime/date_bitcast.sql
new file mode 100644
index 0000000000..94b5628605
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_bitcast.sql
@@ -0,0 +1,36 @@
+/* postgres can not */
+select bitcast(Yql::Date(AsAtom("1")) as Uint8);
+select bitcast(Yql::Date(AsAtom("1")) as Int8);
+select bitcast(Yql::Date(AsAtom("1")) as Uint16);
+select bitcast(Yql::Date(AsAtom("1")) as Int16);
+select bitcast(Yql::Date(AsAtom("1")) as Uint32);
+select bitcast(Yql::Date(AsAtom("1")) as Int32);
+select bitcast(Yql::Date(AsAtom("1")) as Uint64);
+select bitcast(Yql::Date(AsAtom("1")) as Int64);
+
+select bitcast(Yql::Datetime(AsAtom("1")) as Uint8);
+select bitcast(Yql::Datetime(AsAtom("1")) as Int8);
+select bitcast(Yql::Datetime(AsAtom("1")) as Uint16);
+select bitcast(Yql::Datetime(AsAtom("1")) as Int16);
+select bitcast(Yql::Datetime(AsAtom("1")) as Uint32);
+select bitcast(Yql::Datetime(AsAtom("1")) as Int32);
+select bitcast(Yql::Datetime(AsAtom("1")) as Uint64);
+select bitcast(Yql::Datetime(AsAtom("1")) as Int64);
+
+select bitcast(Yql::Timestamp(AsAtom("1")) as Uint8);
+select bitcast(Yql::Timestamp(AsAtom("1")) as Int8);
+select bitcast(Yql::Timestamp(AsAtom("1")) as Uint16);
+select bitcast(Yql::Timestamp(AsAtom("1")) as Int16);
+select bitcast(Yql::Timestamp(AsAtom("1")) as Uint32);
+select bitcast(Yql::Timestamp(AsAtom("1")) as Int32);
+select bitcast(Yql::Timestamp(AsAtom("1")) as Uint64);
+select bitcast(Yql::Timestamp(AsAtom("1")) as Int64);
+
+select bitcast(Yql::Interval(AsAtom("1")) as Uint8);
+select bitcast(Yql::Interval(AsAtom("1")) as Int8);
+select bitcast(Yql::Interval(AsAtom("1")) as Uint16);
+select bitcast(Yql::Interval(AsAtom("1")) as Int16);
+select bitcast(Yql::Interval(AsAtom("1")) as Uint32);
+select bitcast(Yql::Interval(AsAtom("1")) as Int32);
+select bitcast(Yql::Interval(AsAtom("1")) as Uint64);
+select bitcast(Yql::Interval(AsAtom("1")) as Int64);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_cast.sql b/yql/essentials/tests/sql/suites/datetime/date_cast.sql
new file mode 100644
index 0000000000..0cea9766c7
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_cast.sql
@@ -0,0 +1,97 @@
+/* postgres can not */
+select cast(Yql::Date(AsAtom("1")) as Uint8);
+select cast(Yql::Date(AsAtom("1")) as Uint32);
+select cast(Yql::Date(AsAtom("1")) as Int32);
+select cast(Yql::Date(AsAtom("1")) as Uint64);
+select cast(Yql::Date(AsAtom("1")) as Int64);
+
+select cast(Yql::Datetime(AsAtom("1")) as Uint8);
+select cast(Yql::Datetime(AsAtom("1")) as Uint32);
+select cast(Yql::Datetime(AsAtom("1")) as Int32);
+select cast(Yql::Datetime(AsAtom("1")) as Uint64);
+select cast(Yql::Datetime(AsAtom("1")) as Int64);
+
+select cast(Yql::Timestamp(AsAtom("1")) as Uint8);
+select cast(Yql::Timestamp(AsAtom("1")) as Uint32);
+select cast(Yql::Timestamp(AsAtom("1")) as Int32);
+select cast(Yql::Timestamp(AsAtom("1")) as Uint64);
+select cast(Yql::Timestamp(AsAtom("1")) as Int64);
+
+select cast(Yql::Interval(AsAtom("1")) as Uint8);
+select cast(Yql::Interval(AsAtom("1")) as Uint32);
+select cast(Yql::Interval(AsAtom("1")) as Int32);
+select cast(Yql::Interval(AsAtom("1")) as Uint64);
+select cast(Yql::Interval(AsAtom("1")) as Int64);
+
+select cast(1ut as Date);
+select cast(1u as Date);
+select cast(1 as Date);
+select cast(1ul as Date);
+select cast(1l as Date);
+select cast(-1 as Date);
+select cast(1/1 as Date);
+select cast(-1/1 as Date);
+/* postgres can not */
+select cast(Yql::Date(AsAtom("1")) as Uint8);
+select cast(Yql::Date(AsAtom("1")) as Uint32);
+select cast(Yql::Date(AsAtom("1")) as Int32);
+select cast(Yql::Date(AsAtom("1")) as Uint64);
+select cast(Yql::Date(AsAtom("1")) as Int64);
+
+select cast(Yql::Datetime(AsAtom("1")) as Uint8);
+select cast(Yql::Datetime(AsAtom("1")) as Uint32);
+select cast(Yql::Datetime(AsAtom("1")) as Int32);
+select cast(Yql::Datetime(AsAtom("1")) as Uint64);
+select cast(Yql::Datetime(AsAtom("1")) as Int64);
+
+select cast(Yql::Timestamp(AsAtom("1")) as Uint8);
+select cast(Yql::Timestamp(AsAtom("1")) as Uint32);
+select cast(Yql::Timestamp(AsAtom("1")) as Int32);
+select cast(Yql::Timestamp(AsAtom("1")) as Uint64);
+select cast(Yql::Timestamp(AsAtom("1")) as Int64);
+
+select cast(Yql::Interval(AsAtom("1")) as Uint8);
+select cast(Yql::Interval(AsAtom("1")) as Uint32);
+select cast(Yql::Interval(AsAtom("1")) as Int32);
+select cast(Yql::Interval(AsAtom("1")) as Uint64);
+select cast(Yql::Interval(AsAtom("1")) as Int64);
+
+select cast(1ut as Date);
+select cast(1u as Date);
+select cast(1 as Date);
+select cast(1ul as Date);
+select cast(1l as Date);
+select cast(-1 as Date);
+select cast(1/1 as Date);
+select cast(-1/1 as Date);
+select cast(1/0 as Date);
+
+select cast(1ut as Datetime);
+select cast(1u as Datetime);
+select cast(1 as Datetime);
+select cast(1ul as Datetime);
+select cast(1l as Datetime);
+select cast(-1 as Datetime);
+select cast(1/1 as Datetime);
+select cast(-1/1 as Datetime);
+select cast(1/0 as Datetime);
+
+select cast(1ut as Timestamp);
+select cast(1u as Timestamp);
+select cast(1 as Timestamp);
+select cast(1ul as Timestamp);
+select cast(1l as Timestamp);
+select cast(-1 as Timestamp);
+select cast(1/1 as Timestamp);
+select cast(-1/1 as Timestamp);
+select cast(1/0 as Timestamp);
+
+select cast(1ut as Interval);
+select cast(1u as Interval);
+select cast(-1 as Interval);
+select cast(1ul as Interval);
+select cast(-1l as Interval);
+select cast(-1 as Interval);
+select cast(1/1 as Interval);
+select cast(-1/1 as Interval);
+select cast(1/0 as Interval);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_convert.sql b/yql/essentials/tests/sql/suites/datetime/date_convert.sql
new file mode 100644
index 0000000000..01d8e296cf
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_convert.sql
@@ -0,0 +1,24 @@
+/* postgres can not */
+select Yql::Convert(Yql::Date(AsAtom("1")),AsAtom("Uint8"));
+select Yql::Convert(Yql::Date(AsAtom("1")),AsAtom("Uint32"));
+select Yql::Convert(Yql::Date(AsAtom("1")),AsAtom("Int32"));
+select Yql::Convert(Yql::Date(AsAtom("1")),AsAtom("Uint64"));
+select Yql::Convert(Yql::Date(AsAtom("1")),AsAtom("Int64"));
+
+select Yql::Convert(Yql::Datetime(AsAtom("1")),AsAtom("Uint8"));
+select Yql::Convert(Yql::Datetime(AsAtom("1")),AsAtom("Uint32"));
+select Yql::Convert(Yql::Datetime(AsAtom("1")),AsAtom("Int32"));
+select Yql::Convert(Yql::Datetime(AsAtom("1")),AsAtom("Uint64"));
+select Yql::Convert(Yql::Datetime(AsAtom("1")),AsAtom("Int64"));
+
+select Yql::Convert(Yql::Timestamp(AsAtom("1")),AsAtom("Uint8"));
+select Yql::Convert(Yql::Timestamp(AsAtom("1")),AsAtom("Uint32"));
+select Yql::Convert(Yql::Timestamp(AsAtom("1")),AsAtom("Int32"));
+select Yql::Convert(Yql::Timestamp(AsAtom("1")),AsAtom("Uint64"));
+select Yql::Convert(Yql::Timestamp(AsAtom("1")),AsAtom("Int64"));
+
+select Yql::Convert(Yql::Interval(AsAtom("1")),AsAtom("Uint8"));
+select Yql::Convert(Yql::Interval(AsAtom("1")),AsAtom("Uint32"));
+select Yql::Convert(Yql::Interval(AsAtom("1")),AsAtom("Int32"));
+select Yql::Convert(Yql::Interval(AsAtom("1")),AsAtom("Uint64"));
+select Yql::Convert(Yql::Interval(AsAtom("1")),AsAtom("Int64"));
diff --git a/yql/essentials/tests/sql/suites/datetime/date_diff_compare.sql b/yql/essentials/tests/sql/suites/datetime/date_diff_compare.sql
new file mode 100644
index 0000000000..862ecde03e
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_diff_compare.sql
@@ -0,0 +1,24 @@
+/* postgres can not */
+select Date("2001-01-01") == Datetime("2001-01-01T00:00:00Z");
+select Date("2001-01-01") == Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") == Timestamp("2001-01-01T00:00:00Z");
+
+select Date("2001-01-01") != Datetime("2001-01-01T00:00:00Z");
+select Date("2001-01-01") != Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") != Timestamp("2001-01-01T00:00:00Z");
+
+select Date("2001-01-01") < Datetime("2001-01-01T00:00:00Z");
+select Date("2001-01-01") < Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") < Timestamp("2001-01-01T00:00:00Z");
+
+select Date("2001-01-01") <= Datetime("2001-01-01T00:00:00Z");
+select Date("2001-01-01") <= Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") <= Timestamp("2001-01-01T00:00:00Z");
+
+select Date("2001-01-01") > Datetime("2001-01-01T00:00:00Z");
+select Date("2001-01-01") > Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") > Timestamp("2001-01-01T00:00:00Z");
+
+select Date("2001-01-01") >= Datetime("2001-01-01T00:00:00Z");
+select Date("2001-01-01") >= Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") >= Timestamp("2001-01-01T00:00:00Z");
diff --git a/yql/essentials/tests/sql/suites/datetime/date_diff_sub.sql b/yql/essentials/tests/sql/suites/datetime/date_diff_sub.sql
new file mode 100644
index 0000000000..1de62ff2ec
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_diff_sub.sql
@@ -0,0 +1,7 @@
+/* postgres can not */
+select Date("2001-01-01") - Datetime("2001-01-01T00:00:00Z");
+select Date("2001-01-01") - Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") - Timestamp("2001-01-01T00:00:00Z");
+select Datetime("2001-01-01T00:00:00Z") - Date("2001-01-01");
+select Timestamp("2001-01-01T00:00:00Z") - Date("2001-01-01");
+select Timestamp("2001-01-01T00:00:00Z") - Datetime("2001-01-01T00:00:00Z");
diff --git a/yql/essentials/tests/sql/suites/datetime/date_in.sql b/yql/essentials/tests/sql/suites/datetime/date_in.sql
new file mode 100644
index 0000000000..158c08c964
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_in.sql
@@ -0,0 +1,35 @@
+/* postgres can not */
+select cast("1970-01-01" as date),cast(cast("1970-01-01" as date) as string);
+select cast("2000-04-05" as date),cast(cast("2000-04-05" as date) as string);
+select cast("2100-02-29" as date),cast(cast("2100-02-29" as date) as string);
+select cast("2100-03-01" as date),cast(cast("2100-03-01" as date) as string);
+
+select cast("2000-04-05T06:07:08Z" as datetime),cast(cast("2000-04-05T06:07:08Z" as datetime) as string);
+select cast("2000-04-05T06:07:08Z" as timestamp),cast(cast("2000-04-05T06:07:08Z" as timestamp) as string);
+select cast("2000-04-05T06:07:08.9Z" as timestamp),cast(cast("2000-04-05T06:07:08.9Z" as timestamp) as string);
+select cast("2000-04-05T06:07:08.000009Z" as timestamp),cast(cast("2000-04-05T06:07:08.000009Z" as timestamp) as string);
+
+select cast("P" as interval),cast(cast("P" as interval) as string);
+select cast("P1D" as interval),cast(cast("P1D" as interval) as string);
+select cast("-P1D" as interval),cast(cast("-P1D" as interval) as string);
+select cast("PT2H" as interval),cast(cast("PT2H" as interval) as string);
+select cast("PT2H3M" as interval),cast(cast("PT2H3M" as interval) as string);
+select cast("PT3M" as interval),cast(cast("PT3M" as interval) as string);
+select cast("PT3M4S" as interval),cast(cast("PT3M4S" as interval) as string);
+select cast("PT4S" as interval),cast(cast("PT4S" as interval) as string);
+select cast("PT0S" as interval),cast(cast("PT0S" as interval) as string);
+select cast("PT4.5S" as interval),cast(cast("PT4.5S" as interval) as string);
+select cast("PT4.000005S" as interval),cast(cast("PT4.000005S" as interval) as string);
+select cast("P1DT2H3M4.5S" as interval),cast(cast("P1DT2H3M4.5S" as interval) as string);
+
+select cast("2105-12-31" as date),cast(cast("2105-12-31" as date) as string);
+select cast("2106-01-01" as date),cast(cast("2106-01-01" as date) as string);
+
+select cast("2105-12-31T23:59:59Z" as datetime),cast(cast("2105-12-31T23:59:59Z" as datetime) as string);
+select cast("2106-01-01T00:00:00Z" as datetime),cast(cast("2106-01-01T00:00:00Z" as datetime) as string);
+
+select cast("2105-12-31T23:59:59.999999Z" as timestamp),cast(cast("2105-12-31T23:59:59.999999Z" as timestamp) as string);
+select cast("2106-01-01T00:00:00.000000Z" as timestamp),cast(cast("2106-01-01T00:00:00.000000Z" as timestamp) as string);
+
+select cast("P49672DT23H59M59.999999S" as interval),cast(cast("P49672DT23H59M59.999999S" as interval) as string);
+select cast("P49673D" as interval),cast(cast("P49673D" as interval) as string);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_out.sql b/yql/essentials/tests/sql/suites/datetime/date_out.sql
new file mode 100644
index 0000000000..bdf6f6909c
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_out.sql
@@ -0,0 +1,17 @@
+/* postgres can not */
+select cast(cast(18000u as date) as string);
+select cast(cast(18000u*86400ul+1u*3600u+2u*60u+3u as datetime) as string);
+select cast(cast(18000u*86400000000ul+1u*3600000000ul+2u*60000000ul+3000000ul+4u as timestamp) as string);
+select cast(cast(18000u*86400000000ul+1u*3600000000ul+2u*60000000ul+3000000ul+4u as interval) as string);
+
+select cast(cast(49673u - 1u as date) as string);
+select cast(cast(49673u as date) as string);
+
+select cast(cast(49673u*86400ul - 1u as datetime) as string);
+select cast(cast(49673u*86400ul as datetime) as string);
+
+select cast(cast(49673u*86400000000ul - 1u as timestamp) as string);
+select cast(cast(49673u*86400000000ul as timestamp) as string);
+
+select cast(cast(49673u*86400000000ul - 1u as interval) as string);
+select cast(cast(49673u*86400000000ul as interval) as string); \ No newline at end of file
diff --git a/yql/essentials/tests/sql/suites/datetime/date_scale.sql b/yql/essentials/tests/sql/suites/datetime/date_scale.sql
new file mode 100644
index 0000000000..d5fe663fca
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_scale.sql
@@ -0,0 +1,7 @@
+/* postgres can not */
+select cast(cast(1u as date) as datetime);
+select cast(cast(1u as date) as timestamp);
+select cast(cast(86400u as datetime) as timestamp);
+select cast(cast(86400u as datetime) as date);
+select cast(cast(86400000000ul as timestamp) as date);
+select cast(cast(86400000000ul as timestamp) as datetime);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_types.sql b/yql/essentials/tests/sql/suites/datetime/date_types.sql
new file mode 100644
index 0000000000..ed6cf55519
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_types.sql
@@ -0,0 +1,15 @@
+/* postgres can not */
+USE plato;
+
+SELECT
+ Yql::Date(AsAtom("1")),
+ Yql::Datetime(AsAtom("2")),
+ Yql::Timestamp(AsAtom("3")),
+ Yql::Interval(AsAtom("4"))
+FROM Input;
+
+SELECT
+ Yql::Date(AsAtom("1")),
+ Yql::Datetime(AsAtom("2")),
+ Yql::Timestamp(AsAtom("3")),
+ Yql::Interval(AsAtom("4"));
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz.txt b/yql/essentials/tests/sql/suites/datetime/date_tz.txt
new file mode 100644
index 0000000000..1cc4231129
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz.txt
@@ -0,0 +1,2 @@
+{"key"="023";"subkey"="3";"value"="2001-01-01T12:00:00,GMT"};
+{"key"="037";"subkey"="5";"value"="2001-01-01T15:00:00,Europe/Moscow"};
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_addremove.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_addremove.sql
new file mode 100644
index 0000000000..2050d7153d
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_addremove.sql
@@ -0,0 +1,5 @@
+/* postgres can not */
+select AddTimezone(Datetime("2000-01-01T12:00:00Z"),"Europe/Moscow"),
+ AddTimezone(Datetime("2000-01-01T12:00:00Z"),"America/Los_Angeles"),
+ cast(RemoveTimezone(TzDatetime("2000-01-01T12:00:00,Europe/Moscow")) as string),
+ cast(RemoveTimezone(TzDatetime("2000-01-01T12:00:00,America/Los_Angeles")) as string);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_arithmetic.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_arithmetic.sql
new file mode 100644
index 0000000000..438b92cc2f
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_arithmetic.sql
@@ -0,0 +1,24 @@
+/* postgres can not */
+select cast(date("1970-01-02") - tzdate("1970-01-01,America/Los_Angeles") as string);
+select cast(tzdate("1970-01-02,America/Los_Angeles") - date("1970-01-01") as string);
+select cast(tzdate("1970-01-02,America/Los_Angeles") - tzdate("1970-01-01,America/Los_Angeles") as string);
+
+select cast(tzdate("1970-01-01,America/Los_Angeles") + interval("P1D") as string);
+select cast(interval("P1D") + tzdate("1970-01-01,America/Los_Angeles") as string);
+select cast(tzdate("1970-01-02,America/Los_Angeles") - interval("P1D") as string);
+
+select cast(datetime("1970-01-02T00:00:00Z") - tzdatetime("1970-01-01T00:00:00,America/Los_Angeles") as string);
+select cast(tzdatetime("1970-01-02T00:00:00,America/Los_Angeles") - datetime("1970-01-01T00:00:00Z") as string);
+select cast(tzdatetime("1970-01-02T00:00:00,America/Los_Angeles") - tzdatetime("1970-01-01T00:00:00,America/Los_Angeles") as string);
+
+select cast(tzdatetime("1970-01-01T00:00:00,America/Los_Angeles") + interval("P1D") as string);
+select cast(interval("P1D") + tzdatetime("1970-01-01T00:00:00,America/Los_Angeles") as string);
+select cast(tzdatetime("1970-01-02T00:00:00,America/Los_Angeles") - interval("P1D") as string);
+
+select cast(timestamp("1970-01-02T00:00:00.6Z") - tztimestamp("1970-01-01T00:00:00.3,America/Los_Angeles") as string);
+select cast(tztimestamp("1970-01-02T00:00:00.6,America/Los_Angeles") - timestamp("1970-01-01T00:00:00.3Z") as string);
+select cast(tztimestamp("1970-01-02T00:00:00.6,America/Los_Angeles") - tztimestamp("1970-01-01T00:00:00.3,America/Los_Angeles") as string);
+
+select cast(tztimestamp("1970-01-01T00:00:00.6,America/Los_Angeles") + interval("P1D") as string);
+select cast(interval("P1D") + tztimestamp("1970-01-01T00:00:00.6,America/Los_Angeles") as string);
+select cast(tztimestamp("1970-01-02T00:00:00.6,America/Los_Angeles") - interval("P1D") as string);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_bitcast.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_bitcast.sql
new file mode 100644
index 0000000000..77d8f430e1
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_bitcast.sql
@@ -0,0 +1,27 @@
+/* postgres can not */
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Uint8);
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Int8);
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Uint16);
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Int16);
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Uint32);
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Int32);
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Uint64);
+select bitcast(Yql::TzDate(AsAtom("1,UTC")) as Int64);
+
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Uint8);
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Int8);
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Uint16);
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Int16);
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Uint32);
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Int32);
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Uint64);
+select bitcast(Yql::TzDatetime(AsAtom("1,UTC")) as Int64);
+
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Uint8);
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Int8);
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Uint16);
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Int16);
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Uint32);
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Int32);
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Uint64);
+select bitcast(Yql::TzTimestamp(AsAtom("1,UTC")) as Int64);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_bounds.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_bounds.sql
new file mode 100644
index 0000000000..2dac802c9b
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_bounds.sql
@@ -0,0 +1,17 @@
+/* postgres can not */
+select
+ TZDATE("1970-01-02,Europe/Moscow"),
+ TZDATE("1970-01-01,America/Los_Angeles"),
+ TZDATE("2105-12-31,Europe/Moscow"),
+ TZDATE("2105-12-31,America/Los_Angeles"),
+
+ TZDATETIME("1970-01-01T03:00:00,Europe/Moscow"),
+ TZDATETIME("1969-12-31T16:00:00,America/Los_Angeles"),
+ TZDATETIME("2106-01-01T02:59:59,Europe/Moscow"),
+ TZDATETIME("2105-12-31T15:59:59,America/Los_Angeles"),
+
+ TZTIMESTAMP("1970-01-01T03:00:00.000000,Europe/Moscow"),
+ TZTIMESTAMP("1969-12-31T16:00:00.000000,America/Los_Angeles"),
+ TZTIMESTAMP("2106-01-01T02:59:59.999999,Europe/Moscow"),
+ TZTIMESTAMP("2105-12-31T15:59:59.999999,America/Los_Angeles")
+
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_bounds_scale.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_bounds_scale.sql
new file mode 100644
index 0000000000..0bf37288ad
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_bounds_scale.sql
@@ -0,0 +1,31 @@
+/* postgres can not */
+select
+ cast(TZDATE("1970-01-02,Europe/Moscow") as TzDatetime),
+ cast(TZDATE("1970-01-01,America/Los_Angeles") as TzDatetime),
+ cast(TZDATE("2105-12-31,Europe/Moscow") as TzDatetime),
+ cast(TZDATE("2105-12-31,America/Los_Angeles") as TzDatetime),
+
+ cast(TZDATE("1970-01-02,Europe/Moscow") as TzTimestamp),
+ cast(TZDATE("1970-01-01,America/Los_Angeles") as TzTimestamp),
+ cast(TZDATE("2105-12-31,Europe/Moscow") as TzTimestamp),
+ cast(TZDATE("2105-12-31,America/Los_Angeles") as TzTimestamp),
+
+ cast(TZDATETIME("1970-01-02T00:00:00,Europe/Moscow") as TzDate),
+ cast(TZDATETIME("1970-01-01T00:00:00,America/Los_Angeles") as TzDate),
+ cast(TZDATETIME("2106-01-01T02:59:59,Europe/Moscow") as TzDate),
+ cast(TZDATETIME("2105-12-31T15:59:59,America/Los_Angeles") as TzDate),
+
+ cast(TZDATETIME("1970-01-02T00:00:00,Europe/Moscow") as TzTimestamp),
+ cast(TZDATETIME("1970-01-01T00:00:00,America/Los_Angeles") as TzTimestamp),
+ cast(TZDATETIME("2106-01-01T02:59:59,Europe/Moscow") as TzTimestamp),
+ cast(TZDATETIME("2105-12-31T15:59:59,America/Los_Angeles") as TzTimestamp),
+
+ cast(TZTIMESTAMP("1970-01-02T00:00:00.000000,Europe/Moscow") as TzDate),
+ cast(TZTIMESTAMP("1970-01-01T00:00:00.000000,America/Los_Angeles") as TzDate),
+ cast(TZTIMESTAMP("2106-01-01T02:59:59.999999,Europe/Moscow") as TzDate),
+ cast(TZTIMESTAMP("2105-12-31T15:59:59.999999,America/Los_Angeles") as TzDate),
+
+ cast(TZTIMESTAMP("1970-01-02T00:00:00.000000,Europe/Moscow") as TzDatetime),
+ cast(TZTIMESTAMP("1970-01-01T00:00:00.000000,America/Los_Angeles") as TzDatetime),
+ cast(TZTIMESTAMP("2106-01-01T02:59:59.999999,Europe/Moscow") as TzDatetime),
+ cast(TZTIMESTAMP("2105-12-31T15:59:59.999999,America/Los_Angeles") as TzDatetime)
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_bytes.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_bytes.sql
new file mode 100644
index 0000000000..06187182f9
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_bytes.sql
@@ -0,0 +1,10 @@
+/* postgres can not */
+/* syntax version 1 */
+select ToBytes(TzDate("2001-01-01,Europe/Moscow"));
+select cast(FromBytes(ToBytes(TzDate("2001-01-01,Europe/Moscow")),TzDate) as string);
+
+select ToBytes(TzDatetime("2001-01-01T01:02:03,Europe/Moscow"));
+select cast(FromBytes(ToBytes(TzDatetime("2001-01-01T01:02:03,Europe/Moscow")),TzDatetime) as string);
+
+select ToBytes(TzTimestamp("2001-01-01T01:02:03.456789,Europe/Moscow"));
+select cast(FromBytes(ToBytes(TzTimestamp("2001-01-01T01:02:03.456789,Europe/Moscow")),TzTimestamp) as string);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_cast.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_cast.sql
new file mode 100644
index 0000000000..84b60de923
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_cast.sql
@@ -0,0 +1,47 @@
+/* postgres can not */
+select cast(Yql::TzDate(AsAtom("1,UTC")) as Uint8);
+select cast(Yql::TzDate(AsAtom("1,UTC")) as Uint32);
+select cast(Yql::TzDate(AsAtom("1,UTC")) as Int32);
+select cast(Yql::TzDate(AsAtom("1,UTC")) as Uint64);
+select cast(Yql::TzDate(AsAtom("1,UTC")) as Int64);
+
+select cast(Yql::TzDatetime(AsAtom("1,UTC")) as Uint8);
+select cast(Yql::TzDatetime(AsAtom("1,UTC")) as Uint32);
+select cast(Yql::TzDatetime(AsAtom("1,UTC")) as Int32);
+select cast(Yql::TzDatetime(AsAtom("1,UTC")) as Uint64);
+select cast(Yql::TzDatetime(AsAtom("1,UTC")) as Int64);
+
+select cast(Yql::TzTimestamp(AsAtom("1,UTC")) as Uint8);
+select cast(Yql::TzTimestamp(AsAtom("1,UTC")) as Uint32);
+select cast(Yql::TzTimestamp(AsAtom("1,UTC")) as Int32);
+select cast(Yql::TzTimestamp(AsAtom("1,UTC")) as Uint64);
+select cast(Yql::TzTimestamp(AsAtom("1,UTC")) as Int64);
+
+select cast(1ut as TzDate);
+select cast(1u as TzDate);
+select cast(1 as TzDate);
+select cast(1ul as TzDate);
+select cast(1l as TzDate);
+select cast(-1 as TzDate);
+select cast(1/1 as TzDate);
+select cast(-1/1 as TzDate);
+
+select cast(1ut as TzDatetime);
+select cast(1u as TzDatetime);
+select cast(1 as TzDatetime);
+select cast(1ul as TzDatetime);
+select cast(1l as TzDatetime);
+select cast(-1 as TzDatetime);
+select cast(1/1 as TzDatetime);
+select cast(-1/1 as TzDatetime);
+select cast(1/0 as TzDatetime);
+
+select cast(1ut as TzTimestamp);
+select cast(1u as TzTimestamp);
+select cast(1 as TzTimestamp);
+select cast(1ul as TzTimestamp);
+select cast(1l as TzTimestamp);
+select cast(-1 as TzTimestamp);
+select cast(1/1 as TzTimestamp);
+select cast(-1/1 as TzTimestamp);
+select cast(1/0 as TzTimestamp);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_compare_diff_zones.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_compare_diff_zones.sql
new file mode 100644
index 0000000000..61582cb6b5
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_compare_diff_zones.sql
@@ -0,0 +1,24 @@
+/* postgres can not */
+select cast("2000-01-01,GMT" as tzdate) > tzdate("2000-01-01,Europe/Moscow");
+select cast("1999-12-31,GMT" as tzdate) == tzdate("2000-01-01,Europe/Moscow");
+select RemoveTimezone(cast("1999-12-31,GMT" as tzdate)) == RemoveTimezone(tzdate("2000-01-01,Europe/Moscow"));
+
+select cast("2000-01-01,GMT" as tzdate) == tzdate("2000-01-01,America/Los_Angeles"); -- same time value
+select RemoveTimezone(cast("2000-01-01,GMT" as tzdate)) == RemoveTimezone(tzdate("2000-01-01,America/Los_Angeles"));
+
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) > tzdatetime("2000-01-01T12:00:00,Europe/Moscow");
+select cast("2000-01-01T09:00:00,GMT" as tzdatetime) == tzdatetime("2000-01-01T12:00:00,Europe/Moscow");
+select RemoveTimezone(cast("2000-01-01T09:00:00,GMT" as tzdatetime)) == RemoveTimezone(tzdatetime("2000-01-01T12:00:00,Europe/Moscow"));
+
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) < tzdatetime("2000-01-01T12:00:00,America/Los_Angeles");
+select cast("2000-01-01T20:00:00,GMT" as tzdatetime) == tzdatetime("2000-01-01T12:00:00,America/Los_Angeles");
+select RemoveTimezone(cast("2000-01-01T20:00:00,GMT" as tzdatetime)) == RemoveTimezone(tzdatetime("2000-01-01T12:00:00,America/Los_Angeles"));
+
+select cast("2000-01-01T12:00:00,GMT" as tztimestamp) > tztimestamp("2000-01-01T12:00:00,Europe/Moscow");
+select cast("2000-01-01T09:00:00,GMT" as tztimestamp) == tztimestamp("2000-01-01T12:00:00,Europe/Moscow");
+select RemoveTimezone(cast("2000-01-01T09:00:00,GMT" as tztimestamp)) == RemoveTimezone(tztimestamp("2000-01-01T12:00:00,Europe/Moscow"));
+
+select cast("2000-01-01T12:00:00,GMT" as tztimestamp) < tztimestamp("2000-01-01T12:00:00,America/Los_Angeles");
+select cast("2000-01-01T20:00:00,GMT" as tztimestamp) == tztimestamp("2000-01-01T12:00:00,America/Los_Angeles");
+select RemoveTimezone(cast("2000-01-01T20:00:00,GMT" as tztimestamp)) == RemoveTimezone(tztimestamp("2000-01-01T12:00:00,America/Los_Angeles"));
+
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_compare_gmt.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_compare_gmt.sql
new file mode 100644
index 0000000000..d6d805a826
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_compare_gmt.sql
@@ -0,0 +1,42 @@
+/* postgres can not */
+select cast("2000-01-01,GMT" as tzdate) == cast("2000-01-01" as date);
+select cast("2000-01-01,GMT" as tzdate) < cast("2000-01-01" as date);
+select cast("2000-01-01,GMT" as tzdate) <= cast("2000-01-01" as date);
+select cast("2000-01-01,GMT" as tzdate) > cast("2000-01-01" as date);
+select cast("2000-01-01,GMT" as tzdate) >= cast("2000-01-01" as date);
+select cast("2000-01-01,GMT" as tzdate) != cast("2000-01-01" as date);
+
+select cast("2000-01-01" as date) == cast("2000-01-01,GMT" as tzdate);
+select cast("2000-01-01" as date) < cast("2000-01-01,GMT" as tzdate);
+select cast("2000-01-01" as date) <= cast("2000-01-01,GMT" as tzdate);
+select cast("2000-01-01" as date) > cast("2000-01-01,GMT" as tzdate);
+select cast("2000-01-01" as date) >= cast("2000-01-01,GMT" as tzdate);
+select cast("2000-01-01" as date) != cast("2000-01-01,GMT" as tzdate);
+
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) == cast("2000-01-01T12:00:00Z" as datetime);
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) < cast("2000-01-01T12:00:00Z" as datetime);
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) <= cast("2000-01-01T12:00:00Z" as datetime);
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) > cast("2000-01-01T12:00:00Z" as datetime);
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) >= cast("2000-01-01T12:00:00Z" as datetime);
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) != cast("2000-01-01T12:00:00Z" as datetime);
+
+select cast("2000-01-01T12:00:00Z" as datetime) == cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select cast("2000-01-01T12:00:00Z" as datetime) < cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select cast("2000-01-01T12:00:00Z" as datetime) <= cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select cast("2000-01-01T12:00:00Z" as datetime) > cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select cast("2000-01-01T12:00:00Z" as datetime) >= cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select cast("2000-01-01T12:00:00Z" as datetime) != cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) == cast("2000-01-01T12:00:00.123456Z" as timestamp);
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) < cast("2000-01-01T12:00:00.123456Z" as timestamp);
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) <= cast("2000-01-01T12:00:00.123456Z" as timestamp);
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) > cast("2000-01-01T12:00:00.123456Z" as timestamp);
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) >= cast("2000-01-01T12:00:00.123456Z" as timestamp);
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) != cast("2000-01-01T12:00:00.123456Z" as timestamp);
+
+select cast("2000-01-01T12:00:00.123456Z" as timestamp) == cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select cast("2000-01-01T12:00:00.123456Z" as timestamp) < cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select cast("2000-01-01T12:00:00.123456Z" as timestamp) <= cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select cast("2000-01-01T12:00:00.123456Z" as timestamp) > cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select cast("2000-01-01T12:00:00.123456Z" as timestamp) >= cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select cast("2000-01-01T12:00:00.123456Z" as timestamp) != cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_compare_same_zones.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_compare_same_zones.sql
new file mode 100644
index 0000000000..862c0e2b94
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_compare_same_zones.sql
@@ -0,0 +1,42 @@
+/* postgres can not */
+select cast("2000-01-01,GMT" as tzdate) == tzdate("2000-01-01,GMT");
+select cast("2000-01-01,GMT" as tzdate) < cast("2000-01-01" as date);
+select cast("2000-01-01,GMT" as tzdate) <= tzdate("2000-01-01,GMT");
+select cast("2000-01-01,GMT" as tzdate) > tzdate("2000-01-01,GMT");
+select cast("2000-01-01,GMT" as tzdate) >= tzdate("2000-01-01,GMT");
+select cast("2000-01-01,GMT" as tzdate) != tzdate("2000-01-01,GMT");
+
+select tzdate("2000-01-01,GMT") == cast("2000-01-01,GMT" as tzdate);
+select tzdate("2000-01-01,GMT") < cast("2000-01-01,GMT" as tzdate);
+select tzdate("2000-01-01,GMT") <= cast("2000-01-01,GMT" as tzdate);
+select tzdate("2000-01-01,GMT") > cast("2000-01-01,GMT" as tzdate);
+select tzdate("2000-01-01,GMT") >= cast("2000-01-01,GMT" as tzdate);
+select tzdate("2000-01-01,GMT") != cast("2000-01-01,GMT" as tzdate);
+
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) == tzdatetime("2000-01-01T12:00:00,GMT");
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) < tzdatetime("2000-01-01T12:00:00,GMT");
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) <= tzdatetime("2000-01-01T12:00:00,GMT");
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) > tzdatetime("2000-01-01T12:00:00,GMT");
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) >= tzdatetime("2000-01-01T12:00:00,GMT");
+select cast("2000-01-01T12:00:00,GMT" as tzdatetime) != tzdatetime("2000-01-01T12:00:00,GMT");
+
+select tzdatetime("2000-01-01T12:00:00,GMT") == cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select tzdatetime("2000-01-01T12:00:00,GMT") < cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select tzdatetime("2000-01-01T12:00:00,GMT") <= cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select tzdatetime("2000-01-01T12:00:00,GMT") > cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select tzdatetime("2000-01-01T12:00:00,GMT") >= cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+select tzdatetime("2000-01-01T12:00:00,GMT") != cast("2000-01-01T12:00:00,GMT" as tzdatetime);
+
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) == tztimestamp("2000-01-01T12:00:00.123456,GMT");
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) < tztimestamp("2000-01-01T12:00:00.123456,GMT");
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) <= tztimestamp("2000-01-01T12:00:00.123456,GMT");
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) > tztimestamp("2000-01-01T12:00:00.123456,GMT");
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) >= tztimestamp("2000-01-01T12:00:00.123456,GMT");
+select cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp) != tztimestamp("2000-01-01T12:00:00.123456,GMT");
+
+select tztimestamp("2000-01-01T12:00:00.123456,GMT") == cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select tztimestamp("2000-01-01T12:00:00.123456,GMT") < cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select tztimestamp("2000-01-01T12:00:00.123456,GMT") <= cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select tztimestamp("2000-01-01T12:00:00.123456,GMT") > cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select tztimestamp("2000-01-01T12:00:00.123456,GMT") >= cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
+select tztimestamp("2000-01-01T12:00:00.123456,GMT") != cast("2000-01-01T12:00:00.123456,GMT" as tztimestamp);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_expand_gmt.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_expand_gmt.sql
new file mode 100644
index 0000000000..f0e62cc37e
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_expand_gmt.sql
@@ -0,0 +1,5 @@
+/* postgres can not */
+select
+ cast(Date("2000-01-01") as TzDate),
+ cast(Datetime("2000-01-01T01:02:03Z") as TzDatetime),
+ cast(Timestamp("2000-01-01T01:02:03.456789Z") as TzTimestamp);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.cfg b/yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.cfg
new file mode 100644
index 0000000000..5dae597903
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.cfg
@@ -0,0 +1 @@
+xfail
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.sql
new file mode 100644
index 0000000000..f8f220c217
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_impossible_cast.sql
@@ -0,0 +1,6 @@
+SELECT
+ CAST(AddTimezone(
+ /* "1970-01-01T20:59:59Z" */
+ CAST(75599 AS DateTime),
+ "Europe/Moscow"
+ ) AS TzDate)
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_io.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_io.sql
new file mode 100644
index 0000000000..76e9243cd4
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_io.sql
@@ -0,0 +1,5 @@
+/* postgres can not */
+select
+ cast(cast(TzDate("2000-01-01,Europe/Moscow") as string) as TzDate),
+ cast(cast(TzDatetime("2000-01-01T01:02:03,Europe/Moscow") as string) as TzDatetime),
+ cast(cast(TzTimestamp("2000-01-01T01:02:03.456789,Europe/Moscow") as string) as TzTimestamp);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_scale.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_scale.sql
new file mode 100644
index 0000000000..84ffa55471
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_scale.sql
@@ -0,0 +1,14 @@
+/* postgres can not */
+select cast(TzDate("2000-01-01,Europe/Moscow") as TzDatetime);
+select cast(TzDate("2000-01-01,Europe/Moscow") as TzTimestamp);
+select cast(TzDatetime("2000-01-01T12:00:00,Europe/Moscow") as TzDate);
+select cast(TzDatetime("2000-01-01T12:00:00,Europe/Moscow") as TzTimestamp);
+select cast(TzTimestamp("2000-01-01T12:00:00.456789,Europe/Moscow") as TzDate);
+select cast(TzTimestamp("2000-01-01T12:00:00.456789,Europe/Moscow") as TzDatetime);
+
+select cast(TzDate("2000-01-01,America/Los_Angeles") as TzDatetime);
+select cast(TzDate("2000-01-01,America/Los_Angeles") as TzTimestamp);
+select cast(TzDatetime("2000-01-01T12:00:00,America/Los_Angeles") as TzDate);
+select cast(TzDatetime("2000-01-01T12:00:00,America/Los_Angeles") as TzTimestamp);
+select cast(TzTimestamp("2000-01-01T12:00:00.456789,America/Los_Angeles") as TzDate);
+select cast(TzTimestamp("2000-01-01T12:00:00.456789,America/Los_Angeles") as TzDatetime);
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.cfg b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.cfg
new file mode 100644
index 0000000000..4e01ee544a
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.cfg
@@ -0,0 +1,2 @@
+in Input date_tz.txt
+out Output output.txt
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.sql
new file mode 100644
index 0000000000..72954c51bf
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_asc.sql
@@ -0,0 +1,12 @@
+/* postgres can not */
+/* multirun can not */
+use plato;
+
+insert into Output with truncate
+select
+ cast(value as tzdatetime) as x
+from Input
+order by x asc;
+commit;
+
+select * from Output;
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.cfg b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.cfg
new file mode 100644
index 0000000000..4e01ee544a
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.cfg
@@ -0,0 +1,2 @@
+in Input date_tz.txt
+out Output output.txt
diff --git a/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.sql b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.sql
new file mode 100644
index 0000000000..4f21122ede
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/date_tz_table_sort_desc.sql
@@ -0,0 +1,12 @@
+/* postgres can not */
+/* multirun can not */
+use plato;
+
+insert into Output with truncate
+select
+ cast(value as tzdatetime) as x
+from Input
+order by x desc;
+commit;
+
+select * from Output;
diff --git a/yql/essentials/tests/sql/suites/datetime/default.cfg b/yql/essentials/tests/sql/suites/datetime/default.cfg
new file mode 100644
index 0000000000..58878f8945
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/default.cfg
@@ -0,0 +1 @@
+in Input input.txt
diff --git a/yql/essentials/tests/sql/suites/datetime/input.txt b/yql/essentials/tests/sql/suites/datetime/input.txt
new file mode 100644
index 0000000000..65949ea745
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/datetime/input.txt
@@ -0,0 +1,4 @@
+{"key"="075";"subkey"="1";"value"="abc"};
+{"key"="800";"subkey"="2";"value"="ddd"};
+{"key"="020";"subkey"="3";"value"="q"};
+{"key"="150";"subkey"="4";"value"="qzz"};