Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-io/src/options.rs
6939 views
1
use polars_core::schema::SchemaRef;
2
use polars_utils::IdxSize;
3
use polars_utils::pl_str::PlSmallStr;
4
#[cfg(feature = "serde")]
5
use 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))]
10
pub 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))]
19
pub 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
29
impl 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
49
impl Default for HiveOptions {
50
fn default() -> Self {
51
Self::new_enabled()
52
}
53
}
54
55