Skip to content

Commit 868c545

Browse files
authored
feat: add parser for enableTypeWidening table property (#1456)
## 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.enableTypeWidening` table property from Delta table metadata. This property controls whether type widening is allowed for table columns. <!-- 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 tests
1 parent cfb3320 commit 868c545

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

kernel/src/table_properties.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ pub struct TableProperties {
8989
/// true to enable deletion vectors and predictive I/O for updates.
9090
pub enable_deletion_vectors: Option<bool>,
9191

92+
/// Whether widening the type of an existing column or field is allowed, either manually using
93+
/// ALTER TABLE CHANGE COLUMN or automatically if automatic schema evolution is enabled.
94+
pub enable_type_widening: Option<bool>,
95+
9296
/// The degree to which a transaction must be isolated from modifications made by concurrent
9397
/// transactions.
9498
///
@@ -234,6 +238,19 @@ mod tests {
234238
use crate::expressions::column_name;
235239
use std::collections::HashMap;
236240

241+
#[test]
242+
fn test_parse_type_widening() {
243+
let properties =
244+
HashMap::from([("delta.enableTypeWidening".to_string(), "true".to_string())]);
245+
let table_properties = TableProperties::from(properties.iter());
246+
assert_eq!(table_properties.enable_type_widening, Some(true));
247+
248+
let properties =
249+
HashMap::from([("delta.enableTypeWidening".to_string(), "false".to_string())]);
250+
let table_properties = TableProperties::from(properties.iter());
251+
assert_eq!(table_properties.enable_type_widening, Some(false));
252+
}
253+
237254
#[test]
238255
fn known_key_unknown_val() {
239256
let properties = HashMap::from([("delta.appendOnly".to_string(), "wack".to_string())]);
@@ -281,6 +298,7 @@ mod tests {
281298
("delta.deletedFileRetentionDuration", "interval 1 second"),
282299
("delta.enableChangeDataFeed", "true"),
283300
("delta.enableDeletionVectors", "true"),
301+
("delta.enableTypeWidening", "true"),
284302
("delta.isolationLevel", "snapshotIsolation"),
285303
("delta.logRetentionDuration", "interval 2 seconds"),
286304
("delta.enableExpiredLogCleanup", "true"),
@@ -321,6 +339,7 @@ mod tests {
321339
deleted_file_retention_duration: Some(Duration::new(1, 0)),
322340
enable_change_data_feed: Some(true),
323341
enable_deletion_vectors: Some(true),
342+
enable_type_widening: Some(true),
324343
isolation_level: Some(IsolationLevel::SnapshotIsolation),
325344
log_retention_duration: Some(Duration::new(2, 0)),
326345
enable_expired_log_cleanup: Some(true),

kernel/src/table_properties/deserialize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn try_parse(props: &mut TableProperties, k: &str, v: &str) -> Option<()> {
6565
}
6666
"delta.enableChangeDataFeed" => props.enable_change_data_feed = Some(parse_bool(v)?),
6767
"delta.enableDeletionVectors" => props.enable_deletion_vectors = Some(parse_bool(v)?),
68+
"delta.enableTypeWidening" => props.enable_type_widening = Some(parse_bool(v)?),
6869
"delta.isolationLevel" => props.isolation_level = IsolationLevel::try_from(v).ok(),
6970
"delta.logRetentionDuration" => props.log_retention_duration = Some(parse_interval(v)?),
7071
"delta.enableExpiredLogCleanup" => props.enable_expired_log_cleanup = Some(parse_bool(v)?),

0 commit comments

Comments
 (0)