@@ -59,8 +59,8 @@ use sqlparser::ast::{
5959 BinaryOperator , DataType as SQLDataType , DateTimeField , Expr as SQLExpr , FunctionArg ,
6060 FunctionArgExpr , Ident , Join , JoinConstraint , JoinOperator , ObjectName ,
6161 Offset as SQLOffset , Query , Select , SelectItem , SetExpr , SetOperator ,
62- ShowCreateObject , ShowStatementFilter , TableFactor , TableWithJoins , TrimWhereField ,
63- UnaryOperator , Value , Values as SQLValues ,
62+ ShowCreateObject , ShowStatementFilter , TableFactor , TableWithJoins , TimezoneInfo ,
63+ TrimWhereField , UnaryOperator , Value , Values as SQLValues ,
6464} ;
6565use sqlparser:: ast:: { ColumnDef as SQLColumnDef , ColumnOption } ;
6666use sqlparser:: ast:: { ObjectType , OrderByExpr , Statement } ;
@@ -2703,13 +2703,18 @@ pub fn convert_simple_data_type(sql_type: &SQLDataType) -> Result<DataType> {
27032703 | SQLDataType :: Varchar ( _)
27042704 | SQLDataType :: Text
27052705 | SQLDataType :: String => Ok ( DataType :: Utf8 ) ,
2706- SQLDataType :: Timestamp => Ok ( DataType :: Timestamp ( TimeUnit :: Nanosecond , None ) ) ,
2707- SQLDataType :: TimestampTz => Ok ( DataType :: Timestamp (
2708- TimeUnit :: Nanosecond ,
2709- Some ( "UTC" . into ( ) ) ,
2710- ) ) ,
2706+ SQLDataType :: Timestamp ( tz_info) => {
2707+ let tz = if matches ! ( tz_info, TimezoneInfo :: Tz )
2708+ || matches ! ( tz_info, TimezoneInfo :: WithTimeZone )
2709+ {
2710+ Some ( "UTC" . to_string ( ) )
2711+ } else {
2712+ None
2713+ } ;
2714+ Ok ( DataType :: Timestamp ( TimeUnit :: Nanosecond , tz) )
2715+ }
27112716 SQLDataType :: Date => Ok ( DataType :: Date32 ) ,
2712- SQLDataType :: Time => Ok ( DataType :: Time64 ( TimeUnit :: Nanosecond ) ) ,
2717+ SQLDataType :: Time ( _ ) => Ok ( DataType :: Time64 ( TimeUnit :: Nanosecond ) ) ,
27132718 SQLDataType :: Decimal ( precision, scale) => make_decimal_type ( * precision, * scale) ,
27142719 SQLDataType :: Bytea => Ok ( DataType :: Binary ) ,
27152720 // Explicitly list all other types so that if sqlparser
0 commit comments