@@ -85,6 +85,7 @@ pub enum Value {
8585 Number ( NumberValue ) ,
8686 /// Microseconds from 1970-01-01 00:00:00 UTC
8787 Timestamp ( i64 ) ,
88+ TimestampTz ( String ) ,
8889 Date ( i32 ) ,
8990 Array ( Vec < Value > ) ,
9091 Map ( Vec < ( Value , Value ) > ) ,
@@ -121,6 +122,7 @@ impl Value {
121122 NumberValue :: Decimal256 ( _, s) => DataType :: Decimal ( DecimalDataType :: Decimal256 ( * s) ) ,
122123 } ,
123124 Self :: Timestamp ( _) => DataType :: Timestamp ,
125+ Self :: TimestampTz ( _) => DataType :: TimestampTz ,
124126
125127 Self :: Date ( _) => DataType :: Date ,
126128 Self :: Interval ( _) => DataType :: Interval ,
@@ -223,6 +225,7 @@ impl TryFrom<(&DataType, String)> for Value {
223225 . and_utc ( )
224226 . timestamp_micros ( ) ,
225227 ) ) ,
228+ DataType :: TimestampTz => Ok ( Self :: TimestampTz ( v) ) ,
226229 DataType :: Date => Ok ( Self :: Date (
227230 NaiveDate :: parse_from_str ( v. as_str ( ) , "%Y-%m-%d" ) ?. num_days_from_ce ( )
228231 - DAYS_FROM_CE ,
@@ -884,6 +887,7 @@ fn encode_value(f: &mut std::fmt::Formatter<'_>, val: &Value, raw: bool) -> std:
884887 | Value :: Bitmap ( s)
885888 | Value :: Variant ( s)
886889 | Value :: Interval ( s)
890+ | Value :: TimestampTz ( s)
887891 | Value :: Geometry ( s)
888892 | Value :: Geography ( s) => {
889893 if raw {
@@ -1670,6 +1674,7 @@ impl ValueDecoder {
16701674 DataType :: String => self . read_string ( reader) ,
16711675 DataType :: Binary => self . read_binary ( reader) ,
16721676 DataType :: Timestamp => self . read_timestamp ( reader) ,
1677+ DataType :: TimestampTz => self . read_timestamp_tz ( reader) ,
16731678 DataType :: Date => self . read_date ( reader) ,
16741679 DataType :: Bitmap => self . read_bitmap ( reader) ,
16751680 DataType :: Variant => self . read_variant ( reader) ,
@@ -1817,6 +1822,14 @@ impl ValueDecoder {
18171822 Ok ( Value :: Interval ( unsafe { String :: from_utf8_unchecked ( buf) } ) )
18181823 }
18191824
1825+ fn read_timestamp_tz < R : AsRef < [ u8 ] > > ( & self , reader : & mut Cursor < R > ) -> Result < Value > {
1826+ let mut buf = Vec :: new ( ) ;
1827+ reader. read_quoted_text ( & mut buf, b'\'' ) ?;
1828+ Ok ( Value :: TimestampTz ( unsafe {
1829+ String :: from_utf8_unchecked ( buf)
1830+ } ) )
1831+ }
1832+
18201833 fn read_bitmap < R : AsRef < [ u8 ] > > ( & self , reader : & mut Cursor < R > ) -> Result < Value > {
18211834 let mut buf = Vec :: new ( ) ;
18221835 reader. read_quoted_text ( & mut buf, b'\'' ) ?;
@@ -2191,6 +2204,7 @@ impl Value {
21912204 let dt = DateTime :: from_timestamp_micros ( * ts) . unwrap ( ) ;
21922205 format ! ( "'{}'" , dt. format( TIMESTAMP_FORMAT ) )
21932206 }
2207+ Value :: TimestampTz ( t) => format ! ( "'{t}'" ) ,
21942208 Value :: Date ( d) => {
21952209 let date = NaiveDate :: from_num_days_from_ce_opt ( * d + DAYS_FROM_CE ) . unwrap ( ) ;
21962210 format ! ( "'{}'" , date. format( "%Y-%m-%d" ) )
0 commit comments