@@ -713,22 +713,38 @@ pub fn scan_csv(path: String, options: ScanCsvOptions) -> napi::Result<JsLazyFra
713
713
#[ napi( object) ]
714
714
pub struct ScanParquetOptions {
715
715
pub n_rows : Option < i64 > ,
716
+ pub row_index_name : Option < String > ,
717
+ pub row_index_offset : Option < u32 > ,
716
718
pub cache : Option < bool > ,
717
719
pub parallel : Wrap < ParallelStrategy > ,
718
- pub row_count : Option < JsRowCount > ,
720
+ pub glob : Option < bool > ,
721
+ pub hive_partitioning : Option < bool > ,
722
+ pub hive_schema : Option < Wrap < Schema > > ,
723
+ pub try_parse_hive_dates : Option < bool > ,
719
724
pub rechunk : Option < bool > ,
720
725
pub low_memory : Option < bool > ,
721
726
pub use_statistics : Option < bool > ,
722
727
pub cloud_options : Option < HashMap < String , String > > ,
723
728
pub retries : Option < i64 > ,
729
+ pub include_file_paths : Option < String > ,
724
730
}
725
731
726
732
#[ napi( catch_unwind) ]
727
733
pub fn scan_parquet ( path : String , options : ScanParquetOptions ) -> napi:: Result < JsLazyFrame > {
728
734
let n_rows = options. n_rows . map ( |i| i as usize ) ;
729
735
let cache = options. cache . unwrap_or ( true ) ;
736
+ let glob = options. glob . unwrap_or ( true ) ;
730
737
let parallel = options. parallel ;
731
- let row_index: Option < RowIndex > = options. row_count . map ( |rc| rc. into ( ) ) ;
738
+
739
+ let row_index: Option < RowIndex > = if let Some ( idn) = options. row_index_name {
740
+ Some ( RowIndex {
741
+ name : idn. into ( ) ,
742
+ offset : options. row_index_offset . unwrap_or ( 0 )
743
+ } )
744
+ } else {
745
+ None
746
+ } ;
747
+
732
748
let rechunk = options. rechunk . unwrap_or ( false ) ;
733
749
let low_memory = options. low_memory . unwrap_or ( false ) ;
734
750
let use_statistics = options. use_statistics . unwrap_or ( false ) ;
@@ -751,6 +767,16 @@ pub fn scan_parquet(path: String, options: ScanParquetOptions) -> napi::Result<J
751
767
} ) ;
752
768
}
753
769
770
+ let hive_schema = options. hive_schema . map ( |s| Arc :: new ( s. 0 ) ) ;
771
+ let hive_options = HiveOptions {
772
+ enabled : options. hive_partitioning ,
773
+ hive_start_idx : 0 ,
774
+ schema : hive_schema,
775
+ try_parse_dates : options. try_parse_hive_dates . unwrap_or ( true ) ,
776
+ } ;
777
+
778
+ let include_file_paths = options. include_file_paths ;
779
+
754
780
let args = ScanArgsParquet {
755
781
n_rows,
756
782
cache,
@@ -760,13 +786,9 @@ pub fn scan_parquet(path: String, options: ScanParquetOptions) -> napi::Result<J
760
786
low_memory,
761
787
cloud_options,
762
788
use_statistics,
763
- // TODO: Support Hive partitioning.
764
- hive_options : HiveOptions {
765
- enabled : Some ( false ) ,
766
- ..Default :: default ( )
767
- } ,
768
- glob : true ,
769
- include_file_paths : None
789
+ hive_options,
790
+ glob,
791
+ include_file_paths : include_file_paths. map ( Arc :: from) ,
770
792
} ;
771
793
let lf = LazyFrame :: scan_parquet ( path, args) . map_err ( JsPolarsErr :: from) ?;
772
794
Ok ( lf. into ( ) )
0 commit comments