polars_io/
options.rs

1use polars_core::schema::SchemaRef;
2use polars_utils::IdxSize;
3use polars_utils::pl_str::PlSmallStr;
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, Eq, PartialEq, Hash)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
10pub struct RowIndex {
11    pub name: PlSmallStr,
12    pub offset: IdxSize,
13}
14
15/// Options for Hive partitioning.
16#[derive(Clone, Debug, Eq, PartialEq, Hash)]
17#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
19pub struct HiveOptions {
20    /// This can be `None` to automatically enable for single directory scans
21    /// and disable otherwise. However it should be initialized if it is inside
22    /// a DSL / IR plan.
23    pub enabled: Option<bool>,
24    pub hive_start_idx: usize,
25    pub schema: Option<SchemaRef>,
26    pub try_parse_dates: bool,
27}
28
29impl HiveOptions {
30    pub fn new_enabled() -> Self {
31        Self {
32            enabled: Some(true),
33            hive_start_idx: 0,
34            schema: None,
35            try_parse_dates: true,
36        }
37    }
38
39    pub fn new_disabled() -> Self {
40        Self {
41            enabled: Some(false),
42            hive_start_idx: 0,
43            schema: None,
44            try_parse_dates: false,
45        }
46    }
47}
48
49impl Default for HiveOptions {
50    fn default() -> Self {
51        Self::new_enabled()
52    }
53}