1
- use chrono:: {
2
- format:: {
3
- Fixed , Item ,
4
- Numeric :: { Day , Hour , Minute , Month , Second , Year } ,
5
- Pad :: Zero ,
6
- } ,
7
- prelude:: * ,
8
- } ;
9
- use chrono_tz:: Tz ;
1
+ use chrono:: prelude:: * ;
10
2
use comfy_table:: { Cell , Table } ;
11
3
use datafusion:: arrow:: {
12
4
array:: {
@@ -18,15 +10,10 @@ use datafusion::arrow::{
18
10
} ,
19
11
datatypes:: { DataType , IntervalUnit , Schema , TimeUnit } ,
20
12
record_batch:: RecordBatch ,
21
- temporal_conversions,
22
13
} ;
23
- use pg_srv:: IntervalValue ;
24
14
use rust_decimal:: prelude:: * ;
25
15
use serde:: { Serialize , Serializer } ;
26
- use std:: {
27
- fmt:: { self , Debug , Formatter } ,
28
- io,
29
- } ;
16
+ use std:: fmt:: Debug ;
30
17
31
18
use super :: { ColumnFlags , ColumnType } ;
32
19
use crate :: CubeError ;
@@ -88,6 +75,10 @@ impl Row {
88
75
}
89
76
}
90
77
78
+ // Type aliases for compatibility - actual implementations are in pg-srv
79
+ pub type IntervalValue = pg_srv:: IntervalValue ;
80
+ pub type TimestampValue = pg_srv:: TimestampValue ;
81
+
91
82
#[ derive( Debug ) ]
92
83
pub enum TableValue {
93
84
Null ,
@@ -207,83 +198,6 @@ impl DataFrame {
207
198
}
208
199
}
209
200
210
- #[ derive( Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
211
- pub struct TimestampValue {
212
- unix_nano : i64 ,
213
- tz : Option < String > ,
214
- }
215
-
216
- impl TimestampValue {
217
- pub fn new ( mut unix_nano : i64 , tz : Option < String > ) -> TimestampValue {
218
- // This is a hack to workaround a mismatch between on-disk and in-memory representations.
219
- // We use millisecond precision on-disk.
220
- unix_nano -= unix_nano % 1000 ;
221
- TimestampValue { unix_nano, tz }
222
- }
223
-
224
- pub fn to_naive_datetime ( & self ) -> NaiveDateTime {
225
- assert ! ( self . tz. is_none( ) ) ;
226
-
227
- temporal_conversions:: timestamp_ns_to_datetime ( self . unix_nano )
228
- }
229
-
230
- pub fn to_fixed_datetime ( & self ) -> io:: Result < DateTime < Tz > > {
231
- assert ! ( self . tz. is_some( ) ) ;
232
-
233
- let tz = self
234
- . tz
235
- . as_ref ( )
236
- . unwrap ( )
237
- . parse :: < Tz > ( )
238
- . map_err ( |err| io:: Error :: new ( io:: ErrorKind :: Other , err. to_string ( ) ) ) ?;
239
-
240
- let ndt = temporal_conversions:: timestamp_ns_to_datetime ( self . unix_nano ) ;
241
- Ok ( tz. from_utc_datetime ( & ndt) )
242
- }
243
-
244
- pub fn tz_ref ( & self ) -> & Option < String > {
245
- & self . tz
246
- }
247
-
248
- pub fn get_time_stamp ( & self ) -> i64 {
249
- self . unix_nano
250
- }
251
- }
252
-
253
- impl Debug for TimestampValue {
254
- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
255
- f. debug_struct ( "TimestampValue" )
256
- . field ( "unix_nano" , & self . unix_nano )
257
- . field ( "tz" , & self . tz )
258
- . field ( "str" , & self . to_string ( ) )
259
- . finish ( )
260
- }
261
- }
262
-
263
- impl ToString for TimestampValue {
264
- fn to_string ( & self ) -> String {
265
- Utc . timestamp_nanos ( self . unix_nano )
266
- . format_with_items (
267
- [
268
- Item :: Numeric ( Year , Zero ) ,
269
- Item :: Literal ( "-" ) ,
270
- Item :: Numeric ( Month , Zero ) ,
271
- Item :: Literal ( "-" ) ,
272
- Item :: Numeric ( Day , Zero ) ,
273
- Item :: Literal ( "T" ) ,
274
- Item :: Numeric ( Hour , Zero ) ,
275
- Item :: Literal ( ":" ) ,
276
- Item :: Numeric ( Minute , Zero ) ,
277
- Item :: Literal ( ":" ) ,
278
- Item :: Numeric ( Second , Zero ) ,
279
- Item :: Fixed ( Fixed :: Nanosecond3 ) ,
280
- ]
281
- . iter ( ) ,
282
- )
283
- . to_string ( )
284
- }
285
- }
286
-
287
201
#[ derive( Debug , Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
288
202
pub struct Decimal128Value {
289
203
n : i128 ,
0 commit comments