Skip to content

Commit 4ea0ef6

Browse files
authored
feat: add parser for iceberg compat properties (#1466)
## What changes are proposed in this pull request? <!-- Please clarify what changes you are proposing and why the changes are needed. The purpose of this section is to outline the changes, why they are needed, and how this PR fixes the issue. If the reason for the change is already explained clearly in an issue, then it does not need to be restated here. 1. If you propose a new API or feature, clarify the use case for a new API or feature. 2. If you fix a bug, you can clarify why it is a bug. --> Adds support for parsing the `delta.enableIcebergCompatV1` and `delta.enableIcebergCompatV2` table property from Delta table metadata. This property controls whether iceberg compat is turned on for tables. <!-- Uncomment this section if there are any changes affecting public APIs: ### This PR affects the following public APIs If there are breaking changes, please ensure the `breaking-changes` label gets added by CI, and describe why the changes are needed. Note that _new_ public APIs are not considered breaking. --> ## How was this change tested? <!-- Please make sure to add test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested, ideally via a reproducible test documented in the PR description. --> new unit tests
1 parent c76d00a commit 4ea0ef6

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

kernel/src/table_properties.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ pub struct TableProperties {
9393
/// ALTER TABLE CHANGE COLUMN or automatically if automatic schema evolution is enabled.
9494
pub enable_type_widening: Option<bool>,
9595

96+
/// Whether Iceberg compatibility V1 is enabled for this table. When enabled, Delta Lake
97+
/// ensures compatibility with Apache Iceberg V1 table format.
98+
pub enable_iceberg_compat_v1: Option<bool>,
99+
100+
/// Whether Iceberg compatibility V2 is enabled for this table. When enabled, Delta Lake
101+
/// ensures compatibility with Apache Iceberg V2 table format.
102+
pub enable_iceberg_compat_v2: Option<bool>,
103+
96104
/// The degree to which a transaction must be isolated from modifications made by concurrent
97105
/// transactions.
98106
///
@@ -251,6 +259,40 @@ mod tests {
251259
assert_eq!(table_properties.enable_type_widening, Some(false));
252260
}
253261

262+
#[test]
263+
fn test_parse_iceberg_compat_v1() {
264+
let properties = HashMap::from([(
265+
"delta.enableIcebergCompatV1".to_string(),
266+
"true".to_string(),
267+
)]);
268+
let table_properties = TableProperties::from(properties.iter());
269+
assert_eq!(table_properties.enable_iceberg_compat_v1, Some(true));
270+
271+
let properties = HashMap::from([(
272+
"delta.enableIcebergCompatV1".to_string(),
273+
"false".to_string(),
274+
)]);
275+
let table_properties = TableProperties::from(properties.iter());
276+
assert_eq!(table_properties.enable_iceberg_compat_v1, Some(false));
277+
}
278+
279+
#[test]
280+
fn test_parse_iceberg_compat_v2() {
281+
let properties = HashMap::from([(
282+
"delta.enableIcebergCompatV2".to_string(),
283+
"true".to_string(),
284+
)]);
285+
let table_properties = TableProperties::from(properties.iter());
286+
assert_eq!(table_properties.enable_iceberg_compat_v2, Some(true));
287+
288+
let properties = HashMap::from([(
289+
"delta.enableIcebergCompatV2".to_string(),
290+
"false".to_string(),
291+
)]);
292+
let table_properties = TableProperties::from(properties.iter());
293+
assert_eq!(table_properties.enable_iceberg_compat_v2, Some(false));
294+
}
295+
254296
#[test]
255297
fn known_key_unknown_val() {
256298
let properties = HashMap::from([("delta.appendOnly".to_string(), "wack".to_string())]);
@@ -299,6 +341,8 @@ mod tests {
299341
("delta.enableChangeDataFeed", "true"),
300342
("delta.enableDeletionVectors", "true"),
301343
("delta.enableTypeWidening", "true"),
344+
("delta.enableIcebergCompatV1", "true"),
345+
("delta.enableIcebergCompatV2", "true"),
302346
("delta.isolationLevel", "snapshotIsolation"),
303347
("delta.logRetentionDuration", "interval 2 seconds"),
304348
("delta.enableExpiredLogCleanup", "true"),
@@ -340,6 +384,8 @@ mod tests {
340384
enable_change_data_feed: Some(true),
341385
enable_deletion_vectors: Some(true),
342386
enable_type_widening: Some(true),
387+
enable_iceberg_compat_v1: Some(true),
388+
enable_iceberg_compat_v2: Some(true),
343389
isolation_level: Some(IsolationLevel::SnapshotIsolation),
344390
log_retention_duration: Some(Duration::new(2, 0)),
345391
enable_expired_log_cleanup: Some(true),

kernel/src/table_properties/deserialize.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ fn try_parse(props: &mut TableProperties, k: &str, v: &str) -> Option<()> {
6666
"delta.enableChangeDataFeed" => props.enable_change_data_feed = Some(parse_bool(v)?),
6767
"delta.enableDeletionVectors" => props.enable_deletion_vectors = Some(parse_bool(v)?),
6868
"delta.enableTypeWidening" => props.enable_type_widening = Some(parse_bool(v)?),
69+
"delta.enableIcebergCompatV1" => props.enable_iceberg_compat_v1 = Some(parse_bool(v)?),
70+
"delta.enableIcebergCompatV2" => props.enable_iceberg_compat_v2 = Some(parse_bool(v)?),
6971
"delta.isolationLevel" => props.isolation_level = IsolationLevel::try_from(v).ok(),
7072
"delta.logRetentionDuration" => props.log_retention_duration = Some(parse_interval(v)?),
7173
"delta.enableExpiredLogCleanup" => props.enable_expired_log_cleanup = Some(parse_bool(v)?),

0 commit comments

Comments
 (0)