Skip to main content

polars_io/parquet/read/
options.rs

1use polars_core::schema::SchemaRef;
2#[cfg(feature = "serde")]
3use serde::{Deserialize, Serialize};
4
5use crate::parquet::encryption::ParquetDecryption;
6
7#[derive(Clone, Debug, PartialEq, Eq, Hash)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
10pub struct ParquetOptions {
11    pub schema: Option<SchemaRef>,
12    pub parallel: ParallelStrategy,
13    pub low_memory: bool,
14    pub use_statistics: bool,
15    /// How to decrypt files encrypted with Parquet modular encryption
16    #[cfg_attr(feature = "serde", serde(default))]
17    pub decryption: Option<ParquetDecryption>,
18}
19
20impl Default for ParquetOptions {
21    fn default() -> Self {
22        Self {
23            schema: None,
24            parallel: ParallelStrategy::default(),
25            low_memory: false,
26            use_statistics: true,
27            decryption: None,
28        }
29    }
30}
31
32#[derive(Copy, Clone, Debug, Eq, PartialEq, Default, Hash)]
33#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
34#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
35pub enum ParallelStrategy {
36    /// Don't parallelize
37    None,
38    /// Parallelize over the columns
39    Columns,
40    /// Parallelize over the row groups
41    RowGroups,
42    /// First evaluates the pushed-down predicates in parallel and determines a mask of which rows
43    /// to read. Then, it parallelizes over both the columns and the row groups while filtering out
44    /// rows that do not need to be read. This can provide significant speedups for large files
45    /// (i.e. many row-groups) with a predicate that filters clustered rows or filters heavily. In
46    /// other cases, this may slow down the scan compared other strategies.
47    ///
48    /// If no predicate is given, this falls back to [`ParallelStrategy::Auto`].
49    Prefiltered,
50    /// Automatically determine over which unit to parallelize
51    /// This will choose the most occurring unit.
52    #[default]
53    Auto,
54}