Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub mod table_changes;
pub mod table_configuration;
pub mod table_features;
pub mod table_properties;
mod table_property_protocol_config;
pub mod transaction;
pub(crate) mod transforms;

Expand Down
25 changes: 14 additions & 11 deletions kernel/src/row_tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ pub(crate) struct RowTrackingDomainMetadata {
row_id_high_water_mark: i64,
}

impl RowTrackingDomainMetadata {
const ROW_TRACKING_DOMAIN_NAME: &str = "delta.rowTracking";
/// The domain name for row tracking metadata.
pub(crate) const ROW_TRACKING_DOMAIN_NAME: &str = "delta.rowTracking";

impl RowTrackingDomainMetadata {
pub(crate) fn new(row_id_high_water_mark: i64) -> Self {
RowTrackingDomainMetadata {
row_id_high_water_mark,
Expand All @@ -45,14 +46,16 @@ impl RowTrackingDomainMetadata {
snapshot: &Snapshot,
engine: &dyn Engine,
) -> DeltaResult<Option<i64>> {
Ok(domain_metadata_configuration(
snapshot.log_segment(),
Self::ROW_TRACKING_DOMAIN_NAME,
engine,
)?
.map(|domain_metadata| serde_json::from_str::<Self>(&domain_metadata))
.transpose()?
.map(|metadata| metadata.row_id_high_water_mark))
Ok(
domain_metadata_configuration(
snapshot.log_segment(),
ROW_TRACKING_DOMAIN_NAME,
engine,
)?
.map(|domain_metadata| serde_json::from_str::<Self>(&domain_metadata))
.transpose()?
.map(|metadata| metadata.row_id_high_water_mark),
)
}
}

Expand All @@ -61,7 +64,7 @@ impl TryFrom<RowTrackingDomainMetadata> for DomainMetadata {

fn try_from(metadata: RowTrackingDomainMetadata) -> DeltaResult<Self> {
Ok(DomainMetadata::new(
RowTrackingDomainMetadata::ROW_TRACKING_DOMAIN_NAME.to_string(),
ROW_TRACKING_DOMAIN_NAME.to_string(),
serde_json::to_string(&metadata)?,
))
}
Expand Down
8 changes: 8 additions & 0 deletions kernel/src/table_configuration.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Configuration for reading existing Delta tables.
//!
//! This module defines [`TableConfiguration`], a high level api to check feature support and
//! feature enablement for a table at a given version. This encapsulates [`Protocol`], [`Metadata`],
//! [`Schema`], [`TableProperties`], and [`ColumnMappingMode`]. These structs in isolation should
Expand All @@ -7,6 +9,12 @@
//! reader/writer features, and ensure that the deletion vector table property is enabled in the
//! [`TableProperties`].
//!
//! # Related Modules
//!
//! - [`crate::table_property_protocol_config`]: For **creating/modifying** tables. Parses

Check failure on line 14 in kernel/src/table_configuration.rs

View workflow job for this annotation

GitHub Actions / docs

public documentation for `table_configuration` links to private item `crate::table_property_protocol_config`
//! user-provided properties to extract signal flags and create protocols. Use this when building
//! new tables or modifying existing table properties.
//!
//! [`Schema`]: crate::schema::Schema
use std::sync::Arc;

Expand Down
61 changes: 61 additions & 0 deletions kernel/src/table_features/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use itertools::Itertools;
use std::str::FromStr;

use serde::{Deserialize, Serialize};
use strum::{AsRefStr, Display as StrumDisplay, EnumCount, EnumString};

Expand Down Expand Up @@ -679,6 +681,20 @@ impl TableFeature {
TableFeature::Unknown(_) => None,
}
}

/// Parse a feature name string into a TableFeature.
///
/// Known feature names are parsed into their corresponding variants.
/// Unknown feature names are wrapped in `TableFeature::Unknown`.
pub(crate) fn from_name(name: &str) -> Self {
TableFeature::from_str(name).unwrap_or_else(|_| TableFeature::Unknown(name.to_string()))
}

/// Returns true if this is a ReaderWriter feature (appears in both reader and writer feature lists).
/// Returns false for Writer-only features and Unknown features.
pub(crate) fn is_reader_writer(&self) -> bool {
matches!(self.feature_type(), FeatureType::ReaderWriter)
}
}

impl ToDataType for TableFeature {
Expand Down Expand Up @@ -829,4 +845,49 @@ mod tests {
assert_eq!(from_str, feature);
}
}

#[test]
fn test_from_name() {
// Known features
assert_eq!(
TableFeature::from_name("deletionVectors"),
TableFeature::DeletionVectors
);
assert_eq!(
TableFeature::from_name("changeDataFeed"),
TableFeature::ChangeDataFeed
);
assert_eq!(
TableFeature::from_name("columnMapping"),
TableFeature::ColumnMapping
);
assert_eq!(
TableFeature::from_name("timestampNtz"),
TableFeature::TimestampWithoutTimezone
);

// Unknown features
assert_eq!(
TableFeature::from_name("unknownFeature"),
TableFeature::Unknown("unknownFeature".to_string())
);
}

#[test]
fn test_is_reader_writer() {
// ReaderWriter features
assert!(TableFeature::DeletionVectors.is_reader_writer());
assert!(TableFeature::ColumnMapping.is_reader_writer());
assert!(TableFeature::TimestampWithoutTimezone.is_reader_writer());
assert!(TableFeature::V2Checkpoint.is_reader_writer());

// Writer-only features
assert!(!TableFeature::ChangeDataFeed.is_reader_writer());
assert!(!TableFeature::AppendOnly.is_reader_writer());
assert!(!TableFeature::DomainMetadata.is_reader_writer());
assert!(!TableFeature::RowTracking.is_reader_writer());

// Unknown features
assert!(!TableFeature::unknown("something").is_reader_writer());
}
}
8 changes: 8 additions & 0 deletions kernel/src/table_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ pub use deserialize::ParseIntervalError;
/// Prefix for delta table properties (e.g., `delta.enableChangeDataFeed`, `delta.appendOnly`).
pub const DELTA_PROPERTY_PREFIX: &str = "delta.";

/// Table property key for specifying the minimum reader protocol version.
/// This is a signal flag property - it affects protocol creation but is not stored in metadata.
pub const MIN_READER_VERSION_PROP: &str = "delta.minReaderVersion";

/// Table property key for specifying the minimum writer protocol version.
/// This is a signal flag property - it affects protocol creation but is not stored in metadata.
pub const MIN_WRITER_VERSION_PROP: &str = "delta.minWriterVersion";

/// Delta table properties. These are parsed from the 'configuration' map in the most recent
/// 'Metadata' action of a table.
///
Expand Down
Loading
Loading