Skip to content

Commit 1cbde24

Browse files
sanujbasuSanuj Basu
authored andcommitted
feat: Introduce TableCreationConfig for table creation property handling
1. Adds the ability to explicitly enable table features via table properties using the delta.feature.<featureName> = supported syntax, matching the Java Kernel's behavior. Only ALLOWED_DELTA_FEATURES can be set during create. Features get added to protocol features. 2. Allows the min reader/ writer versions to be updated in the protocol using signal flags. Only protocol versions (3, 7) are supported. Key Changes: - Add SET_TABLE_FEATURE_SUPPORTED_PREFIX and SET_TABLE_FEATURE_SUPPORTED_VALUE constants to table_features module. Move the feature/ property allow/ deny list to the table property configuration module - Add TableFeature::from_name() to parse feature names from strings - Add TableFeature::is_reader_writer() to check feature type - Add TableCreationConfig struct to encapsulate parsing and validation of user-provided table properties during CREATE TABLE operations. - Extract delta.feature.* signal flags into reader/writer feature lists - Extract delta.minReaderVersion/minWriterVersion into protocol hints - Strip signal flags from properties, pass remaining to metadata - Reject unknown features and invalid feature flag values Usage: create_table("/path/to/table", schema, "MyApp/1.0") .with_table_properties([ ("delta.minReaderVersion", "3"), ("delta.minWriterVersion", "7"), ]) .build(&engine, Box::new(FileSystemCommitter::new()))? .commit(&engine)?; The delta.feature.* properties are consumed during build() and not stored in the final Metadata configuration, matching Java Kernel behavior.
1 parent e64a5b9 commit 1cbde24

File tree

8 files changed

+677
-91
lines changed

8 files changed

+677
-91
lines changed

kernel/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub mod table_changes;
103103
pub mod table_configuration;
104104
pub mod table_features;
105105
pub mod table_properties;
106+
mod table_property_protocol_config;
106107
pub mod transaction;
107108
pub(crate) mod transforms;
108109

kernel/src/table_configuration.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Configuration for reading existing Delta tables.
2+
//!
13
//! This module defines [`TableConfiguration`], a high level api to check feature support and
24
//! feature enablement for a table at a given version. This encapsulates [`Protocol`], [`Metadata`],
35
//! [`Schema`], [`TableProperties`], and [`ColumnMappingMode`]. These structs in isolation should
@@ -7,6 +9,12 @@
79
//! reader/writer features, and ensure that the deletion vector table property is enabled in the
810
//! [`TableProperties`].
911
//!
12+
//! # Related Modules
13+
//!
14+
//! - [`crate::table_property_protocol_config`]: For **creating/modifying** tables. Parses
15+
//! user-provided properties to extract signal flags and create protocols. Use this when building
16+
//! new tables or modifying existing table properties.
17+
//!
1018
//! [`Schema`]: crate::schema::Schema
1119
use std::sync::Arc;
1220

kernel/src/table_features/mod.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::str::FromStr;
2+
13
use serde::{Deserialize, Serialize};
24
use strum::{AsRefStr, Display as StrumDisplay, EnumCount, EnumString};
35

@@ -678,6 +680,20 @@ impl TableFeature {
678680
TableFeature::Unknown(_) => None,
679681
}
680682
}
683+
684+
/// Parse a feature name string into a TableFeature.
685+
///
686+
/// Known feature names are parsed into their corresponding variants.
687+
/// Unknown feature names are wrapped in `TableFeature::Unknown`.
688+
pub(crate) fn from_name(name: &str) -> Self {
689+
TableFeature::from_str(name).unwrap_or_else(|_| TableFeature::Unknown(name.to_string()))
690+
}
691+
692+
/// Returns true if this is a ReaderWriter feature (appears in both reader and writer feature lists).
693+
/// Returns false for Writer-only features and Unknown features.
694+
pub(crate) fn is_reader_writer(&self) -> bool {
695+
matches!(self.feature_type(), FeatureType::ReaderWriter)
696+
}
681697
}
682698

683699
impl ToDataType for TableFeature {
@@ -822,4 +838,49 @@ mod tests {
822838
assert_eq!(from_str, feature);
823839
}
824840
}
841+
842+
#[test]
843+
fn test_from_name() {
844+
// Known features
845+
assert_eq!(
846+
TableFeature::from_name("deletionVectors"),
847+
TableFeature::DeletionVectors
848+
);
849+
assert_eq!(
850+
TableFeature::from_name("changeDataFeed"),
851+
TableFeature::ChangeDataFeed
852+
);
853+
assert_eq!(
854+
TableFeature::from_name("columnMapping"),
855+
TableFeature::ColumnMapping
856+
);
857+
assert_eq!(
858+
TableFeature::from_name("timestampNtz"),
859+
TableFeature::TimestampWithoutTimezone
860+
);
861+
862+
// Unknown features
863+
assert_eq!(
864+
TableFeature::from_name("unknownFeature"),
865+
TableFeature::Unknown("unknownFeature".to_string())
866+
);
867+
}
868+
869+
#[test]
870+
fn test_is_reader_writer() {
871+
// ReaderWriter features
872+
assert!(TableFeature::DeletionVectors.is_reader_writer());
873+
assert!(TableFeature::ColumnMapping.is_reader_writer());
874+
assert!(TableFeature::TimestampWithoutTimezone.is_reader_writer());
875+
assert!(TableFeature::V2Checkpoint.is_reader_writer());
876+
877+
// Writer-only features
878+
assert!(!TableFeature::ChangeDataFeed.is_reader_writer());
879+
assert!(!TableFeature::AppendOnly.is_reader_writer());
880+
assert!(!TableFeature::DomainMetadata.is_reader_writer());
881+
assert!(!TableFeature::RowTracking.is_reader_writer());
882+
883+
// Unknown features
884+
assert!(!TableFeature::unknown("something").is_reader_writer());
885+
}
825886
}

kernel/src/table_properties.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ pub use deserialize::ParseIntervalError;
2626
/// Prefix for delta table properties (e.g., `delta.enableChangeDataFeed`, `delta.appendOnly`).
2727
pub const DELTA_PROPERTY_PREFIX: &str = "delta.";
2828

29+
/// Table property key for specifying the minimum reader protocol version.
30+
/// This is a signal flag property - it affects protocol creation but is not stored in metadata.
31+
pub const MIN_READER_VERSION_PROP: &str = "delta.minReaderVersion";
32+
33+
/// Table property key for specifying the minimum writer protocol version.
34+
/// This is a signal flag property - it affects protocol creation but is not stored in metadata.
35+
pub const MIN_WRITER_VERSION_PROP: &str = "delta.minWriterVersion";
36+
2937
/// Delta table properties. These are parsed from the 'configuration' map in the most recent
3038
/// 'Metadata' action of a table.
3139
///

0 commit comments

Comments
 (0)