Skip to content

Commit 352203b

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 2073c9b commit 352203b

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,4 +1,6 @@
11
use itertools::Itertools;
2+
use std::str::FromStr;
3+
24
use serde::{Deserialize, Serialize};
35
use strum::{AsRefStr, Display as StrumDisplay, EnumCount, EnumString};
46

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

684700
impl ToDataType for TableFeature {
@@ -829,4 +845,49 @@ mod tests {
829845
assert_eq!(from_str, feature);
830846
}
831847
}
848+
849+
#[test]
850+
fn test_from_name() {
851+
// Known features
852+
assert_eq!(
853+
TableFeature::from_name("deletionVectors"),
854+
TableFeature::DeletionVectors
855+
);
856+
assert_eq!(
857+
TableFeature::from_name("changeDataFeed"),
858+
TableFeature::ChangeDataFeed
859+
);
860+
assert_eq!(
861+
TableFeature::from_name("columnMapping"),
862+
TableFeature::ColumnMapping
863+
);
864+
assert_eq!(
865+
TableFeature::from_name("timestampNtz"),
866+
TableFeature::TimestampWithoutTimezone
867+
);
868+
869+
// Unknown features
870+
assert_eq!(
871+
TableFeature::from_name("unknownFeature"),
872+
TableFeature::Unknown("unknownFeature".to_string())
873+
);
874+
}
875+
876+
#[test]
877+
fn test_is_reader_writer() {
878+
// ReaderWriter features
879+
assert!(TableFeature::DeletionVectors.is_reader_writer());
880+
assert!(TableFeature::ColumnMapping.is_reader_writer());
881+
assert!(TableFeature::TimestampWithoutTimezone.is_reader_writer());
882+
assert!(TableFeature::V2Checkpoint.is_reader_writer());
883+
884+
// Writer-only features
885+
assert!(!TableFeature::ChangeDataFeed.is_reader_writer());
886+
assert!(!TableFeature::AppendOnly.is_reader_writer());
887+
assert!(!TableFeature::DomainMetadata.is_reader_writer());
888+
assert!(!TableFeature::RowTracking.is_reader_writer());
889+
890+
// Unknown features
891+
assert!(!TableFeature::unknown("something").is_reader_writer());
892+
}
832893
}

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)