File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1530,3 +1530,27 @@ async fn cast_timestamp_before_1970() -> Result<()> {
15301530
15311531 Ok ( ( ) )
15321532}
1533+
1534+ #[ tokio:: test]
1535+ async fn cast_timestamp_to_timestamptz ( ) -> Result < ( ) > {
1536+ let ctx = SessionContext :: new ( ) ;
1537+ let table_a = make_timestamp_table :: < TimestampNanosecondType > ( ) ?;
1538+
1539+ ctx. register_table ( "table_a" , table_a) ?;
1540+
1541+ let sql = "SELECT ts::timestamptz, arrow_typeof(ts::timestamptz) FROM table_a;" ;
1542+ let actual = execute_to_batches ( & ctx, sql) . await ;
1543+
1544+ let expected = vec ! [
1545+ "+----------------------------+------------------------------------+" ,
1546+ "| table_a.ts | arrowtypeof(table_a.ts) |" ,
1547+ "+----------------------------+------------------------------------+" ,
1548+ "| 2020-09-08 13:42:29.190855 | Timestamp(Nanosecond, Some(\" UTC\" )) |" ,
1549+ "| 2020-09-08 12:42:29.190855 | Timestamp(Nanosecond, Some(\" UTC\" )) |" ,
1550+ "| 2020-09-08 11:42:29.190855 | Timestamp(Nanosecond, Some(\" UTC\" )) |" ,
1551+ "+----------------------------+------------------------------------+" ,
1552+ ] ;
1553+ assert_batches_eq ! ( expected, & actual) ;
1554+
1555+ Ok ( ( ) )
1556+ }
Original file line number Diff line number Diff line change @@ -2703,6 +2703,10 @@ pub fn convert_simple_data_type(sql_type: &SQLDataType) -> Result<DataType> {
27032703 | SQLDataType :: Text
27042704 | SQLDataType :: String => Ok ( DataType :: Utf8 ) ,
27052705 SQLDataType :: Timestamp => Ok ( DataType :: Timestamp ( TimeUnit :: Nanosecond , None ) ) ,
2706+ SQLDataType :: TimestampTz => Ok ( DataType :: Timestamp (
2707+ TimeUnit :: Nanosecond ,
2708+ Some ( "UTC" . into ( ) ) ,
2709+ ) ) ,
27062710 SQLDataType :: Date => Ok ( DataType :: Date32 ) ,
27072711 SQLDataType :: Time => Ok ( DataType :: Time64 ( TimeUnit :: Nanosecond ) ) ,
27082712 SQLDataType :: Decimal ( precision, scale) => make_decimal_type ( * precision, * scale) ,
@@ -2716,7 +2720,6 @@ pub fn convert_simple_data_type(sql_type: &SQLDataType) -> Result<DataType> {
27162720 | SQLDataType :: Varbinary ( _)
27172721 | SQLDataType :: Blob ( _)
27182722 | SQLDataType :: Datetime
2719- | SQLDataType :: TimestampTz
27202723 | SQLDataType :: Interval
27212724 | SQLDataType :: Regclass
27222725 | SQLDataType :: Custom ( _)
You can’t perform that action at this time.
0 commit comments