Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/file_scan/default_values.rs
6940 views
1
use std::sync::Arc;
2
3
use polars_core::prelude::{Column, PlIndexMap};
4
5
/// Default field values when they are missing from the data file.
6
#[derive(Debug, Clone, Eq, Hash, PartialEq)]
7
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
9
pub enum DefaultFieldValues {
10
/// This is to follow the spec for missing columns:
11
/// * Return the value from partition metadata if an Identity Transform exists for the field
12
///
13
/// Note: This is not the Iceberg V3 `initial-default`.
14
Iceberg(Arc<IcebergIdentityTransformedPartitionFields>),
15
}
16
17
#[derive(Debug, Clone, PartialEq)]
18
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
20
pub struct IcebergIdentityTransformedPartitionFields(pub PlIndexMap<u32, Result<Column, String>>);
21
22
impl Eq for IcebergIdentityTransformedPartitionFields {}
23
24
impl std::hash::Hash for IcebergIdentityTransformedPartitionFields {
25
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
26
for key in self.keys() {
27
key.hash(state);
28
}
29
}
30
}
31
32
impl std::ops::Deref for IcebergIdentityTransformedPartitionFields {
33
type Target = PlIndexMap<u32, Result<Column, String>>;
34
35
fn deref(&self) -> &Self::Target {
36
&self.0
37
}
38
}
39
40
impl std::ops::DerefMut for IcebergIdentityTransformedPartitionFields {
41
fn deref_mut(&mut self) -> &mut Self::Target {
42
&mut self.0
43
}
44
}
45
46