@@ -348,7 +348,9 @@ fn batches_to_paths(batches: &[RecordBatch]) -> Vec<PartitionedFile> {
348348 ( 0 ..batch. num_rows ( ) ) . map ( move |row| PartitionedFile {
349349 file_meta : FileMeta {
350350 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+ }
352354 true => None ,
353355 } ,
354356 sized_file : SizedFile {
@@ -366,6 +368,20 @@ fn batches_to_paths(batches: &[RecordBatch]) -> Vec<PartitionedFile> {
366368 . collect ( )
367369}
368370
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+
369385/// Extract the partition values for the given `file_path` (in the given `table_path`)
370386/// associated to the partitions defined by `table_partition_cols`
371387fn parse_partitions_for_path < ' a > (
@@ -649,7 +665,7 @@ mod tests {
649665 path: String :: from( "mybucket/tablepath/part1=val1/file.parquet" ) ,
650666 size: 100 ,
651667 } ,
652- last_modified: Some ( Utc . timestamp_millis ( 1634722979123 ) ) ,
668+ last_modified: Some ( to_timestamp_millis ( 1634722979123 ) . unwrap ( ) ) ,
653669 } ,
654670 FileMeta {
655671 sized_file: SizedFile {
@@ -683,7 +699,7 @@ mod tests {
683699 path: String :: from( "mybucket/tablepath/part1=val1/file.parquet" ) ,
684700 size: 100 ,
685701 } ,
686- last_modified: Some ( Utc . timestamp_millis ( 1634722979123 ) ) ,
702+ last_modified: Some ( to_timestamp_millis ( 1634722979123 ) . unwrap ( ) ) ,
687703 } ,
688704 FileMeta {
689705 sized_file: SizedFile {
0 commit comments