diff --git a/crates/core/src/kernel/models/schema.rs b/crates/core/src/kernel/models/schema.rs index a208c2e8cc..874bade71d 100644 --- a/crates/core/src/kernel/models/schema.rs +++ b/crates/core/src/kernel/models/schema.rs @@ -25,6 +25,8 @@ pub enum MetadataValue { Number(i32), /// A string value String(String), + /// A Boolean value + Boolean(bool), } impl From for MetadataValue { @@ -45,6 +47,12 @@ impl From for MetadataValue { } } +impl From for MetadataValue { + fn from(value: bool) -> Self { + Self::Boolean(value) + } +} + impl From for MetadataValue { fn from(value: Value) -> Self { Self::String(value.to_string()) @@ -184,6 +192,7 @@ impl StructField { let phys_name = self.get_config_value(&ColumnMetadataKey::ColumnMappingPhysicalName); match phys_name { None => Ok(&self.name), + Some(MetadataValue::Boolean(_)) => Ok(&self.name), Some(MetadataValue::String(s)) => Ok(s), Some(MetadataValue::Number(_)) => Err(Error::MetadataError( "Unexpected type for physical name".to_string(), @@ -850,4 +859,11 @@ mod tests { Invariant::new("a_map.value.element.d", "a_map.value.element.d < 4") ); } + + /// + #[test] + fn test_identity_columns() { + let buf = r#"{"type":"struct","fields":[{"name":"ID_D_DATE","type":"long","nullable":true,"metadata":{"delta.identity.start":1,"delta.identity.step":1,"delta.identity.allowExplicitInsert":false}},{"name":"TXT_DateKey","type":"string","nullable":true,"metadata":{}}]}"#; + let schema: StructType = serde_json::from_str(buf).expect("Failed to load"); + } } diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index fa5478e34a..b24faf248e 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -676,4 +676,13 @@ mod tests { DeltaTableError::InvalidTableLocation(_expected_error_msg), )) } + + /// + #[tokio::test] + async fn test_identity_column() { + let path = "../test/tests/data/issue-2152"; + let _ = crate::open_table(path) + .await + .expect("Failed to load the table"); + } } diff --git a/crates/test/tests/data/issue-2152/_delta_log/00000000000000000000.json b/crates/test/tests/data/issue-2152/_delta_log/00000000000000000000.json new file mode 100644 index 0000000000..45256b6236 --- /dev/null +++ b/crates/test/tests/data/issue-2152/_delta_log/00000000000000000000.json @@ -0,0 +1,3 @@ +{"commitInfo":{"timestamp":1706770085847,"operation":"CREATE TABLE","operationParameters":{"partitionBy":"[]","description":null,"isManaged":"true","properties":"{}","statsOnLoad":false},"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{},"tags":{"restoresDeletedRows":"false"},"engineInfo":"Databricks-Runtime/14.1.x-photon-scala2.12","txnId":"5ba2d1f4-09e0-4013-920a-92b057185128"}} +{"metaData":{"id":"7791991a-60e9-4a8f-bff0-ccffec779dc4","format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"ID_D_DATE\",\"type\":\"long\",\"nullable\":true,\"metadata\":{\"delta.identity.start\":1,\"delta.identity.step\":1,\"delta.identity.allowExplicitInsert\":false}},{\"name\":\"TXT_DateKey\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}}]}","partitionColumns":[],"configuration":{},"createdTime":1706770085202}} +{"protocol":{"minReaderVersion":1,"minWriterVersion":6}}