From d23742196ce52e78699ad6ad197570f4341ad721 Mon Sep 17 00:00:00 2001 From: DrakeLin Date: Sat, 22 Nov 2025 01:04:06 +0000 Subject: [PATCH] fix --- kernel/src/checkpoint/mod.rs | 3 +- kernel/src/table_configuration.rs | 117 +++--------------------------- kernel/src/transaction/mod.rs | 3 +- 3 files changed, 14 insertions(+), 109 deletions(-) diff --git a/kernel/src/checkpoint/mod.rs b/kernel/src/checkpoint/mod.rs index 790749dd0..0cf647034 100644 --- a/kernel/src/checkpoint/mod.rs +++ b/kernel/src/checkpoint/mod.rs @@ -101,6 +101,7 @@ use crate::log_replay::LogReplayProcessor; use crate::path::ParsedLogPath; use crate::schema::{DataType, SchemaRef, StructField, StructType, ToSchema as _}; use crate::snapshot::SnapshotRef; +use crate::table_features::TableFeature; use crate::table_properties::TableProperties; use crate::{DeltaResult, Engine, EngineData, Error, EvaluationHandlerExtension, FileMeta}; @@ -232,7 +233,7 @@ impl CheckpointWriter { let is_v2_checkpoints_supported = self .snapshot .table_configuration() - .is_v2_checkpoint_write_supported(); + .is_feature_supported(&TableFeature::V2Checkpoint); let actions = self.snapshot.log_segment().read_actions( engine, diff --git a/kernel/src/table_configuration.rs b/kernel/src/table_configuration.rs index e63b7d7fa..aa4e1e6f4 100644 --- a/kernel/src/table_configuration.rs +++ b/kernel/src/table_configuration.rs @@ -452,67 +452,6 @@ impl TableConfiguration { .unwrap_or(false) } - /// Returns `true` if the table supports the appendOnly table feature. To support this feature: - /// - The table must have a writer version between 2 and 7 (inclusive) - /// - If the table is on writer version 7, it must have the [`TableFeature::AppendOnly`] - /// writer feature. - pub(crate) fn is_append_only_supported(&self) -> bool { - let protocol = &self.protocol; - match protocol.min_writer_version() { - 7 if protocol.has_table_feature(&TableFeature::AppendOnly) => true, - version => (2..=6).contains(&version), - } - } - - #[allow(unused)] - pub(crate) fn is_append_only_enabled(&self) -> bool { - self.is_append_only_supported() && self.table_properties.append_only.unwrap_or(false) - } - - /// Returns `true` if the table supports the column invariant table feature. - #[allow(unused)] - pub(crate) fn is_invariants_supported(&self) -> bool { - let protocol = &self.protocol; - match protocol.min_writer_version() { - 7 if protocol.has_table_feature(&TableFeature::Invariants) => true, - version => (2..=6).contains(&version), - } - } - - /// Returns `true` if V2 checkpoint is supported on this table. To support V2 checkpoint, - /// a table must support reader version 3, writer version 7, and the v2Checkpoint feature in - /// both the protocol's readerFeatures and writerFeatures. - /// - /// See: - pub(crate) fn is_v2_checkpoint_write_supported(&self) -> bool { - self.protocol() - .has_table_feature(&TableFeature::V2Checkpoint) - } - - /// Returns `true` if the table supports writing in-commit timestamps. - /// - /// To support this feature the table must: - /// - Have a min_writer_version of 7 - /// - Have the [`TableFeature::InCommitTimestamp`] writer feature. - #[allow(unused)] - pub(crate) fn is_in_commit_timestamps_supported(&self) -> bool { - self.protocol().min_writer_version() == 7 - && self - .protocol() - .has_table_feature(&TableFeature::InCommitTimestamp) - } - - /// Returns `true` if in-commit timestamps is supported and it is enabled. In-commit timestamps - /// is enabled when the `delta.enableInCommitTimestamps` configuration is set to `true`. - #[allow(unused)] - pub(crate) fn is_in_commit_timestamps_enabled(&self) -> bool { - self.is_in_commit_timestamps_supported() - && self - .table_properties() - .enable_in_commit_timestamps - .unwrap_or(false) - } - /// Returns information about in-commit timestamp enablement state. /// /// Returns an error if only one of the enablement properties is present, as this indicates @@ -521,7 +460,7 @@ impl TableConfiguration { pub(crate) fn in_commit_timestamp_enablement( &self, ) -> DeltaResult { - if !self.is_in_commit_timestamps_enabled() { + if !self.is_feature_enabled(&TableFeature::InCommitTimestamp) { return Ok(InCommitTimestampEnablement::NotEnabled); } @@ -548,42 +487,6 @@ impl TableConfiguration { } } - /// Returns `true` if the table supports writing domain metadata. - /// - /// To support this feature the table must: - /// - Have a min_writer_version of 7. - /// - Have the [`TableFeature::DomainMetadata`] writer feature. - #[allow(unused)] - pub(crate) fn is_domain_metadata_supported(&self) -> bool { - self.protocol().min_writer_version() == 7 - && self - .protocol() - .has_table_feature(&TableFeature::DomainMetadata) - } - - /// Returns `true` if the table supports writing row tracking metadata. - /// - /// To support this feature the table must: - /// - Have a min_writer_version of 7. - /// - Have the [`TableFeature::RowTracking`] writer feature. - pub(crate) fn is_row_tracking_supported(&self) -> bool { - self.protocol().min_writer_version() == 7 - && self - .protocol() - .has_table_feature(&TableFeature::RowTracking) - } - - /// Returns `true` if row tracking is enabled for this table. - /// - /// In order to enable row tracking the table must: - /// - Support row tracking (see [`Self::is_row_tracking_supported`]). - /// - Have the `delta.enableRowTracking` table property set to `true`. - #[allow(unused)] - pub(crate) fn is_row_tracking_enabled(&self) -> bool { - self.is_row_tracking_supported() - && self.table_properties().enable_row_tracking.unwrap_or(false) - } - /// Returns `true` if row tracking is suspended for this table. /// /// Row tracking is suspended when the `delta.rowTrackingSuspended` table property is set to `true`. @@ -605,7 +508,7 @@ impl TableConfiguration { /// Note: We ignore [`is_row_tracking_enabled`] at this point because Kernel does not /// preserve row IDs and row commit versions yet. pub(crate) fn should_write_row_tracking(&self) -> bool { - self.is_row_tracking_supported() && !self.is_row_tracking_suspended() + self.is_feature_supported(&TableFeature::RowTracking) && !self.is_row_tracking_suspended() } /// Returns true if the protocol uses legacy reader version (< 3) @@ -949,8 +852,8 @@ mod test { .unwrap(); let table_root = Url::try_from("file:///").unwrap(); let table_config = TableConfiguration::try_new(metadata, protocol, table_root, 0).unwrap(); - assert!(table_config.is_in_commit_timestamps_supported()); - assert!(table_config.is_in_commit_timestamps_enabled()); + assert!(table_config.is_feature_supported(&TableFeature::InCommitTimestamp)); + assert!(table_config.is_feature_enabled(&TableFeature::InCommitTimestamp)); // When ICT is enabled from table creation (version 0), it's perfectly normal // for enablement properties to be missing let info = table_config.in_commit_timestamp_enablement().unwrap(); @@ -993,8 +896,8 @@ mod test { .unwrap(); let table_root = Url::try_from("file:///").unwrap(); let table_config = TableConfiguration::try_new(metadata, protocol, table_root, 0).unwrap(); - assert!(table_config.is_in_commit_timestamps_supported()); - assert!(table_config.is_in_commit_timestamps_enabled()); + assert!(table_config.is_feature_supported(&TableFeature::InCommitTimestamp)); + assert!(table_config.is_feature_enabled(&TableFeature::InCommitTimestamp)); let info = table_config.in_commit_timestamp_enablement().unwrap(); assert_eq!( info, @@ -1034,8 +937,8 @@ mod test { .unwrap(); let table_root = Url::try_from("file:///").unwrap(); let table_config = TableConfiguration::try_new(metadata, protocol, table_root, 0).unwrap(); - assert!(table_config.is_in_commit_timestamps_supported()); - assert!(table_config.is_in_commit_timestamps_enabled()); + assert!(table_config.is_feature_supported(&TableFeature::InCommitTimestamp)); + assert!(table_config.is_feature_enabled(&TableFeature::InCommitTimestamp)); assert!(matches!( table_config.in_commit_timestamp_enablement(), Err(Error::Generic(msg)) if msg.contains("In-commit timestamp enabled, but enablement timestamp is missing") @@ -1054,8 +957,8 @@ mod test { .unwrap(); let table_root = Url::try_from("file:///").unwrap(); let table_config = TableConfiguration::try_new(metadata, protocol, table_root, 0).unwrap(); - assert!(table_config.is_in_commit_timestamps_supported()); - assert!(!table_config.is_in_commit_timestamps_enabled()); + assert!(table_config.is_feature_supported(&TableFeature::InCommitTimestamp)); + assert!(!table_config.is_feature_enabled(&TableFeature::InCommitTimestamp)); let info = table_config.in_commit_timestamp_enablement().unwrap(); assert_eq!(info, InCommitTimestampEnablement::NotEnabled); } diff --git a/kernel/src/transaction/mod.rs b/kernel/src/transaction/mod.rs index 51c9154d3..080cfff08 100644 --- a/kernel/src/transaction/mod.rs +++ b/kernel/src/transaction/mod.rs @@ -26,6 +26,7 @@ use crate::scan::log_replay::{ use crate::scan::scan_row_schema; use crate::schema::{ArrayType, MapType, SchemaRef, StructField, StructType}; use crate::snapshot::SnapshotRef; +use crate::table_features::TableFeature; use crate::utils::{current_time_ms, require}; use crate::{ DataType, DeltaResult, Engine, EngineData, Expression, ExpressionRef, IntoEngineData, @@ -463,7 +464,7 @@ impl Transaction { && !self .read_snapshot .table_configuration() - .is_domain_metadata_supported() + .is_feature_supported(&TableFeature::DomainMetadata) { return Err(Error::unsupported("Domain metadata operations require writer version 7 and the 'domainMetadata' writer feature")); }