@@ -749,6 +749,26 @@ impl ParquetSink {
749
749
}
750
750
}
751
751
752
+ /// Create writer properties based upon configuration settings,
753
+ /// including partitioning and the inclusion of arrow schema metadata.
754
+ fn create_writer_props ( & self ) -> Result < WriterProperties > {
755
+ let props = if !self . parquet_options . global . skip_arrow_metadata {
756
+ let schema = if self . parquet_options . global . allow_single_file_parallelism {
757
+ & self . get_writer_schema ( )
758
+ } else {
759
+ self . config . output_schema ( )
760
+ } ;
761
+ self . parquet_options
762
+ . into_writer_properties_builder_with_arrow_schema ( Some ( schema) ) ?
763
+ . build ( )
764
+ } else {
765
+ self . parquet_options
766
+ . into_writer_properties_builder ( ) ?
767
+ . build ( )
768
+ } ;
769
+ Ok ( props)
770
+ }
771
+
752
772
/// Creates an AsyncArrowWriter which serializes a parquet file to an ObjectStore
753
773
/// AsyncArrowWriters are used when individual parquet file serialization is not parallelized
754
774
async fn create_async_arrow_writer (
@@ -791,16 +811,7 @@ impl DataSink for ParquetSink {
791
811
data : SendableRecordBatchStream ,
792
812
context : & Arc < TaskContext > ,
793
813
) -> Result < u64 > {
794
- let parquet_props = if !self . parquet_options . global . skip_arrow_metadata {
795
- let schema = self . config . output_schema ( ) ;
796
- self . parquet_options
797
- . into_writer_properties_builder_with_arrow_schema ( Some ( schema) ) ?
798
- . build ( )
799
- } else {
800
- self . parquet_options
801
- . into_writer_properties_builder ( ) ?
802
- . build ( )
803
- } ;
814
+ let parquet_props = self . create_writer_props ( ) ?;
804
815
805
816
let object_store = context
806
817
. runtime_env ( )
0 commit comments