1919## Common timestamp data
2020#
2121# ts_data: Int64 nanoseconds
22- # ts_data_nanos: Timestamp(Nanosecond, None )
23- # ts_data_micros: Timestamp(Microsecond, None )
24- # ts_data_millis: Timestamp(Millisecond, None )
25- # ts_data_secs: Timestamp(Second, None )
22+ # ts_data_nanos: Timestamp(ns )
23+ # ts_data_micros: Timestamp(µs )
24+ # ts_data_millis: Timestamp(ms )
25+ # ts_data_secs: Timestamp(s )
2626##########
2727
2828# Create timestamp tables with different precisions but the same logical values
@@ -34,16 +34,16 @@ create table ts_data(ts bigint, value int) as values
3434 (1599565349190855123, 3);
3535
3636statement ok
37- create table ts_data_nanos as select arrow_cast(ts, 'Timestamp(Nanosecond, None )') as ts, value from ts_data;
37+ create table ts_data_nanos as select arrow_cast(ts, 'Timestamp(ns )') as ts, value from ts_data;
3838
3939statement ok
40- create table ts_data_micros as select arrow_cast(ts / 1000, 'Timestamp(Microsecond, None )') as ts, value from ts_data;
40+ create table ts_data_micros as select arrow_cast(ts / 1000, 'Timestamp(µs )') as ts, value from ts_data;
4141
4242statement ok
43- create table ts_data_millis as select arrow_cast(ts / 1000000, 'Timestamp(Millisecond, None )') as ts, value from ts_data;
43+ create table ts_data_millis as select arrow_cast(ts / 1000000, 'Timestamp(ms )') as ts, value from ts_data;
4444
4545statement ok
46- create table ts_data_secs as select arrow_cast(ts / 1000000000, 'Timestamp(Second, None )') as ts, value from ts_data;
46+ create table ts_data_secs as select arrow_cast(ts / 1000000000, 'Timestamp(s )') as ts, value from ts_data;
4747
4848statement ok
4949create table ts_data_micros_kolkata as select arrow_cast(ts / 1000, 'Timestamp(Microsecond, Some("Asia/Kolkata"))') as ts, value from ts_data;
@@ -1579,13 +1579,13 @@ second 2020-09-08T13:42:29
15791579
15801580# test date trunc on different timestamp scalar types and ensure they are consistent
15811581query P rowsort
1582- SELECT DATE_TRUNC('second', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(Second, None )')) as ts
1582+ SELECT DATE_TRUNC('second', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(s )')) as ts
15831583 UNION ALL
1584- SELECT DATE_TRUNC('second', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(Nanosecond, None )')) as ts
1584+ SELECT DATE_TRUNC('second', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(ns )')) as ts
15851585 UNION ALL
1586- SELECT DATE_TRUNC('day', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(Microsecond, None )')) as ts
1586+ SELECT DATE_TRUNC('day', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(µs )')) as ts
15871587 UNION ALL
1588- SELECT DATE_TRUNC('day', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(Millisecond, None )')) as ts
1588+ SELECT DATE_TRUNC('day', arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(ms )')) as ts
15891589----
159015902023-08-03T00:00:00
159115912023-08-03T00:00:00
@@ -2706,7 +2706,7 @@ drop table ts_utf8_data
27062706##########
27072707
27082708query B
2709- select arrow_cast(now(), 'Date64') < arrow_cast('2022-02-02 02:02:02', 'Timestamp(Nanosecond, None )');
2709+ select arrow_cast(now(), 'Date64') < arrow_cast('2022-02-02 02:02:02', 'Timestamp(ns )');
27102710----
27112711false
27122712
@@ -3640,7 +3640,7 @@ select to_char(arrow_cast(12344567890000, 'Time64(Nanosecond)'), '%H-%M-%S %f')
3640364003-25-44 567890000
36413641
36423642query T
3643- select to_char(arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(Second, None )'), '%d-%m-%Y %H-%M-%S')
3643+ select to_char(arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(s )'), '%d-%m-%Y %H-%M-%S')
36443644----
3645364503-08-2023 14-38-50
36463646
@@ -3732,7 +3732,7 @@ select to_unixtime(arrow_cast(to_timestamp('2023-01-14T01:01:30'), 'Timestamp(Se
373237321673638290
37333733
37343734query I
3735- select to_unixtime(arrow_cast(to_timestamp('2023-01-14T01:01:30'), 'Timestamp(Millisecond, None )'));
3735+ select to_unixtime(arrow_cast(to_timestamp('2023-01-14T01:01:30'), 'Timestamp(ms )'));
37363736----
373737371673658090
37383738
@@ -4307,58 +4307,58 @@ SELECT CAST(CAST(one AS decimal(17,2)) AS timestamp(3)) AS a FROM (VALUES (1)) t
430743071970-01-01T00:00:00.001
43084308
43094309query P
4310- SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(Nanosecond, None )') AS a UNION ALL
4311- SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(Nanosecond, None )') AS a FROM (VALUES (1)) t(one);
4310+ SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(ns )') AS a UNION ALL
4311+ SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(ns )') AS a FROM (VALUES (1)) t(one);
43124312----
431343131970-01-01T00:00:00.000000001
431443141970-01-01T00:00:00.000000001
43154315
43164316query P
4317- SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(Microsecond, None )') AS a UNION ALL
4318- SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(Microsecond, None )') AS a FROM (VALUES (1)) t(one);
4317+ SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(µs )') AS a UNION ALL
4318+ SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(µs )') AS a FROM (VALUES (1)) t(one);
43194319----
432043201970-01-01T00:00:00.000001
432143211970-01-01T00:00:00.000001
43224322
43234323query P
4324- SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(Millisecond, None )') AS a UNION ALL
4325- SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(Millisecond, None )') AS a FROM (VALUES (1)) t(one);
4324+ SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(ms )') AS a UNION ALL
4325+ SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(ms )') AS a FROM (VALUES (1)) t(one);
43264326----
432743271970-01-01T00:00:00.001
432843281970-01-01T00:00:00.001
43294329
43304330query P
4331- SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(Second, None )') AS a UNION ALL
4332- SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(Second, None )') AS a FROM (VALUES (1)) t(one);
4331+ SELECT arrow_cast(CAST(1 AS decimal(17,2)), 'Timestamp(s )') AS a UNION ALL
4332+ SELECT arrow_cast(CAST(one AS decimal(17,2)), 'Timestamp(s )') AS a FROM (VALUES (1)) t(one);
43334333----
433443341970-01-01T00:00:01
433543351970-01-01T00:00:01
43364336
43374337
43384338query P
4339- SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(Nanosecond, None )') AS a UNION ALL
4340- SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(Nanosecond, None )') AS a FROM (VALUES (1.123)) t(one);
4339+ SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(ns )') AS a UNION ALL
4340+ SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(ns )') AS a FROM (VALUES (1.123)) t(one);
43414341----
434243421970-01-01T00:00:00.000000001
434343431970-01-01T00:00:00.000000001
43444344
43454345query P
4346- SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(Microsecond, None )') AS a UNION ALL
4347- SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(Microsecond, None )') AS a FROM (VALUES (1.123)) t(one);
4346+ SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(µs )') AS a UNION ALL
4347+ SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(µs )') AS a FROM (VALUES (1.123)) t(one);
43484348----
434943491970-01-01T00:00:00.000001
435043501970-01-01T00:00:00.000001
43514351
43524352query P
4353- SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(Millisecond, None )') AS a UNION ALL
4354- SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(Millisecond, None )') AS a FROM (VALUES (1.123)) t(one);
4353+ SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(ms )') AS a UNION ALL
4354+ SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(ms )') AS a FROM (VALUES (1.123)) t(one);
43554355----
435643561970-01-01T00:00:00.001
435743571970-01-01T00:00:00.001
43584358
43594359query P
4360- SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(Second, None )') AS a UNION ALL
4361- SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(Second, None )') AS a FROM (VALUES (1.123)) t(one);
4360+ SELECT arrow_cast(CAST(1.123 AS decimal(17,3)), 'Timestamp(s )') AS a UNION ALL
4361+ SELECT arrow_cast(CAST(one AS decimal(17,3)), 'Timestamp(s )') AS a FROM (VALUES (1.123)) t(one);
43624362----
436343631970-01-01T00:00:01
436443641970-01-01T00:00:01
@@ -4410,7 +4410,7 @@ FROM ts_data_micros_kolkata
44104410## Casting between timestamp with and without timezone
44114411##########
44124412
4413- # Test casting from Timestamp(Nanosecond, Some("UTC")) to Timestamp(Nanosecond, None )
4413+ # Test casting from Timestamp(Nanosecond, Some("UTC")) to Timestamp(ns )
44144414# Verifies that the underlying nanosecond values are preserved when removing timezone
44154415
44164416# Verify input type
@@ -4421,13 +4421,13 @@ Timestamp(ns, "UTC")
44214421
44224422# Verify output type after casting
44234423query T
4424- SELECT arrow_typeof(arrow_cast(arrow_cast(1, 'Timestamp(Nanosecond, Some("UTC"))'), 'Timestamp(Nanosecond, None )'));
4424+ SELECT arrow_typeof(arrow_cast(arrow_cast(1, 'Timestamp(Nanosecond, Some("UTC"))'), 'Timestamp(ns )'));
44254425----
44264426Timestamp(ns)
44274427
44284428# Verify values are preserved when casting from timestamp with timezone to timestamp without timezone
44294429query P rowsort
4430- SELECT arrow_cast(column1, 'Timestamp(Nanosecond, None )')
4430+ SELECT arrow_cast(column1, 'Timestamp(ns )')
44314431FROM (VALUES
44324432 (arrow_cast(1, 'Timestamp(Nanosecond, Some("UTC"))')),
44334433 (arrow_cast(2, 'Timestamp(Nanosecond, Some("UTC"))')),
@@ -4442,30 +4442,30 @@ FROM (VALUES
444244421970-01-01T00:00:00.000000004
444344431970-01-01T00:00:00.000000005
44444444
4445- # Test casting from Timestamp(Nanosecond, None ) to Timestamp(Nanosecond, Some("UTC"))
4445+ # Test casting from Timestamp(ns ) to Timestamp(Nanosecond, Some("UTC"))
44464446# Verifies that the underlying nanosecond values are preserved when adding timezone
44474447
44484448# Verify input type
44494449query T
4450- SELECT arrow_typeof(arrow_cast(1, 'Timestamp(Nanosecond, None )'));
4450+ SELECT arrow_typeof(arrow_cast(1, 'Timestamp(ns )'));
44514451----
44524452Timestamp(ns)
44534453
44544454# Verify output type after casting
44554455query T
4456- SELECT arrow_typeof(arrow_cast(arrow_cast(1, 'Timestamp(Nanosecond, None )'), 'Timestamp(Nanosecond, Some("UTC"))'));
4456+ SELECT arrow_typeof(arrow_cast(arrow_cast(1, 'Timestamp(ns )'), 'Timestamp(Nanosecond, Some("UTC"))'));
44574457----
44584458Timestamp(ns, "UTC")
44594459
44604460# Verify values are preserved when casting from timestamp without timezone to timestamp with timezone
44614461query P rowsort
44624462SELECT arrow_cast(column1, 'Timestamp(Nanosecond, Some("UTC"))')
44634463FROM (VALUES
4464- (arrow_cast(1, 'Timestamp(Nanosecond, None )')),
4465- (arrow_cast(2, 'Timestamp(Nanosecond, None )')),
4466- (arrow_cast(3, 'Timestamp(Nanosecond, None )')),
4467- (arrow_cast(4, 'Timestamp(Nanosecond, None )')),
4468- (arrow_cast(5, 'Timestamp(Nanosecond, None )'))
4464+ (arrow_cast(1, 'Timestamp(ns )')),
4465+ (arrow_cast(2, 'Timestamp(ns )')),
4466+ (arrow_cast(3, 'Timestamp(ns )')),
4467+ (arrow_cast(4, 'Timestamp(ns )')),
4468+ (arrow_cast(5, 'Timestamp(ns )'))
44694469) t;
44704470----
447144711970-01-01T00:00:00.000000001Z
0 commit comments