@@ -348,7 +348,9 @@ fn batches_to_paths(batches: &[RecordBatch]) -> Vec<PartitionedFile> {
348
348
( 0 ..batch. num_rows ( ) ) . map ( move |row| PartitionedFile {
349
349
file_meta : FileMeta {
350
350
last_modified : match modified_array. is_null ( row) {
351
- false => Some ( Utc . timestamp_millis ( modified_array. value ( row) ) ) ,
351
+ false => {
352
+ Some ( to_timestamp_millis ( modified_array. value ( row) ) . unwrap ( ) )
353
+ }
352
354
true => None ,
353
355
} ,
354
356
sized_file : SizedFile {
@@ -366,6 +368,20 @@ fn batches_to_paths(batches: &[RecordBatch]) -> Vec<PartitionedFile> {
366
368
. collect ( )
367
369
}
368
370
371
+ fn to_timestamp_millis ( v : i64 ) -> Result < chrono:: DateTime < Utc > > {
372
+ match Utc . timestamp_millis_opt ( v) {
373
+ chrono:: LocalResult :: None => Err ( DataFusionError :: Execution ( format ! (
374
+ "Can not convert {} to UTC millisecond timestamp" ,
375
+ v
376
+ ) ) ) ,
377
+ chrono:: LocalResult :: Single ( v) => Ok ( v) ,
378
+ chrono:: LocalResult :: Ambiguous ( _, _) => Err ( DataFusionError :: Execution ( format ! (
379
+ "Ambiguous timestamp when converting {} to UTC millisecond timestamp" ,
380
+ v
381
+ ) ) ) ,
382
+ }
383
+ }
384
+
369
385
/// Extract the partition values for the given `file_path` (in the given `table_path`)
370
386
/// associated to the partitions defined by `table_partition_cols`
371
387
fn parse_partitions_for_path < ' a > (
@@ -649,7 +665,7 @@ mod tests {
649
665
path: String :: from( "mybucket/tablepath/part1=val1/file.parquet" ) ,
650
666
size: 100 ,
651
667
} ,
652
- last_modified: Some ( Utc . timestamp_millis ( 1634722979123 ) ) ,
668
+ last_modified: Some ( to_timestamp_millis ( 1634722979123 ) . unwrap ( ) ) ,
653
669
} ,
654
670
FileMeta {
655
671
sized_file: SizedFile {
@@ -683,7 +699,7 @@ mod tests {
683
699
path: String :: from( "mybucket/tablepath/part1=val1/file.parquet" ) ,
684
700
size: 100 ,
685
701
} ,
686
- last_modified: Some ( Utc . timestamp_millis ( 1634722979123 ) ) ,
702
+ last_modified: Some ( to_timestamp_millis ( 1634722979123 ) . unwrap ( ) ) ,
687
703
} ,
688
704
FileMeta {
689
705
sized_file: SizedFile {
0 commit comments