5555 from datafusion ._internal import DataFrame as DataFrameInternal
5656 from datafusion ._internal import expr as expr_internal
5757
58+ from dataclasses import dataclass
5859from enum import Enum
5960
6061
@@ -873,7 +874,7 @@ def write_csv(self, path: str | pathlib.Path, with_header: bool = False) -> None
873874 def write_parquet (
874875 self ,
875876 path : str | pathlib .Path ,
876- compression : Union [str , Compression ] = Compression .ZSTD ,
877+ compression : Union [str , Compression , ParquetWriterOptions ] = Compression .ZSTD ,
877878 compression_level : int | None = None ,
878879 ) -> None :
879880 """Execute the :py:class:`DataFrame` and write the results to a Parquet file.
@@ -894,7 +895,13 @@ def write_parquet(
894895 recommended range is 1 to 22, with the default being 4. Higher levels
895896 provide better compression but slower speed.
896897 """
897- # Convert string to Compression enum if necessary
898+ if isinstance (compression , ParquetWriterOptions ):
899+ if compression_level is not None :
900+ msg = "compression_level should be None when using ParquetWriterOptions"
901+ raise ValueError (msg )
902+ self .write_parquet_with_options (path , compression )
903+ return
904+
898905 if isinstance (compression , str ):
899906 compression = Compression .from_str (compression )
900907
0 commit comments