@@ -1788,8 +1788,50 @@ SELECT TIMESTAMPTZ '2020-01-01 00:00:00Z' = TIMESTAMP '2020-01-01'
1788
1788
----
1789
1789
true
1790
1790
1791
- # verify to_timestamp edge cases to be in sync with postgresql
1792
- query PPPPP
1793
- SELECT to_timestamp(null), to_timestamp(-62125747200), to_timestamp(0), to_timestamp(1926632005177), to_timestamp(1926632005)
1794
- ----
1795
- NULL 0001-04-25T00:00:00 1970-01-01T00:00:00 +63022-07-16T12:59:37 2031-01-19T23:33:25
1791
+ # verify timestamp cast with integer input
1792
+ query PPPPPP
1793
+ SELECT to_timestamp(null), to_timestamp(0), to_timestamp(1926632005), to_timestamp(1), to_timestamp(-1), to_timestamp(0-1)
1794
+ ----
1795
+ NULL 1970-01-01T00:00:00 2031-01-19T23:33:25 1970-01-01T00:00:01 1969-12-31T23:59:59 1969-12-31T23:59:59
1796
+
1797
+ # verify timestamp syntax stlyes are consistent
1798
+ query BBBBBBBBBBBBB
1799
+ SELECT to_timestamp(null) is null as c1,
1800
+ null::timestamp is null as c2,
1801
+ cast(null as timestamp) is null as c3,
1802
+ to_timestamp(0) = 0::timestamp as c4,
1803
+ to_timestamp(1926632005) = 1926632005::timestamp as c5,
1804
+ to_timestamp(1) = 1::timestamp as c6,
1805
+ to_timestamp(-1) = -1::timestamp as c7,
1806
+ to_timestamp(0-1) = (0-1)::timestamp as c8,
1807
+ to_timestamp(0) = cast(0 as timestamp) as c9,
1808
+ to_timestamp(1926632005) = cast(1926632005 as timestamp) as c10,
1809
+ to_timestamp(1) = cast(1 as timestamp) as c11,
1810
+ to_timestamp(-1) = cast(-1 as timestamp) as c12,
1811
+ to_timestamp(0-1) = cast(0-1 as timestamp) as c13
1812
+ ----
1813
+ true true true true true true true true true true true true true
1814
+
1815
+ # verify timestamp output types
1816
+ query TTT
1817
+ SELECT arrow_typeof(to_timestamp(1)), arrow_typeof(to_timestamp(null)), arrow_typeof(to_timestamp('2023-01-10 12:34:56.000'))
1818
+ ----
1819
+ Timestamp(Nanosecond, None) Timestamp(Nanosecond, None) Timestamp(Nanosecond, None)
1820
+
1821
+ # verify timestamp output types using timestamp literal syntax
1822
+ query BBBBBB
1823
+ SELECT arrow_typeof(to_timestamp(1)) = arrow_typeof(1::timestamp) as c1,
1824
+ arrow_typeof(to_timestamp(null)) = arrow_typeof(null::timestamp) as c2,
1825
+ arrow_typeof(to_timestamp('2023-01-10 12:34:56.000')) = arrow_typeof('2023-01-10 12:34:56.000'::timestamp) as c3,
1826
+ arrow_typeof(to_timestamp(1)) = arrow_typeof(cast(1 as timestamp)) as c4,
1827
+ arrow_typeof(to_timestamp(null)) = arrow_typeof(cast(null as timestamp)) as c5,
1828
+ arrow_typeof(to_timestamp('2023-01-10 12:34:56.000')) = arrow_typeof(cast('2023-01-10 12:34:56.000' as timestamp)) as c6
1829
+ ----
1830
+ true true true true true true
1831
+
1832
+ # known issues. currently overflows (expects default precision to be microsecond instead of nanoseconds. Work pending)
1833
+ #verify extreme values
1834
+ #query PPPPPPPP
1835
+ #SELECT to_timestamp(-62125747200), to_timestamp(1926632005177), -62125747200::timestamp, 1926632005177::timestamp, cast(-62125747200 as timestamp), cast(1926632005177 as timestamp)
1836
+ #----
1837
+ #0001-04-25T00:00:00 +63022-07-16T12:59:37 0001-04-25T00:00:00 +63022-07-16T12:59:37 0001-04-25T00:00:00 +63022-07-16T12:59:37
0 commit comments