From cd589f96c785a200a847e4f64bee4e805a37930d Mon Sep 17 00:00:00 2001 From: Robert Pack Date: Fri, 10 May 2024 07:55:25 +0200 Subject: [PATCH] fix: remove tests upstreamed to kernel --- Cargo.toml | 2 +- crates/core/src/kernel/models/schema.rs | 184 ------------------------ 2 files changed, 1 insertion(+), 185 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 046dc06292..0c063dd221 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ debug = true debug = "line-tables-only" [workspace.dependencies] -delta_kernel = { git = "https://github.com/roeap/delta-kernel-rs", rev = "524262aa74d2f664bc5cc9b9ce06d7c6274bf7f4" } +delta_kernel = { git = "https://github.com/roeap/delta-kernel-rs", rev = "312044f5759f4e38e634d2dbfb62bc9fcd95c471" } # arrow arrow = { version = "51" } diff --git a/crates/core/src/kernel/models/schema.rs b/crates/core/src/kernel/models/schema.rs index 43c855bfff..7314228689 100644 --- a/crates/core/src/kernel/models/schema.rs +++ b/crates/core/src/kernel/models/schema.rs @@ -137,190 +137,6 @@ mod tests { use serde_json; use serde_json::json; - #[test] - fn test_serde_data_types() { - let data = r#" - { - "name": "a", - "type": "integer", - "nullable": false, - "metadata": {} - } - "#; - let field: StructField = serde_json::from_str(data).unwrap(); - assert!(matches!( - field.data_type, - DataType::Primitive(PrimitiveType::Integer) - )); - - let data = r#" - { - "name": "c", - "type": { - "type": "array", - "elementType": "integer", - "containsNull": false - }, - "nullable": true, - "metadata": {} - } - "#; - let field: StructField = serde_json::from_str(data).unwrap(); - assert!(matches!(field.data_type, DataType::Array(_))); - - let data = r#" - { - "name": "e", - "type": { - "type": "array", - "elementType": { - "type": "struct", - "fields": [ - { - "name": "d", - "type": "integer", - "nullable": false, - "metadata": {} - } - ] - }, - "containsNull": true - }, - "nullable": true, - "metadata": {} - } - "#; - let field: StructField = serde_json::from_str(data).unwrap(); - assert!(matches!(field.data_type, DataType::Array(_))); - match field.data_type { - DataType::Array(array) => assert!(matches!(array.element_type, DataType::Struct(_))), - _ => unreachable!(), - } - - let data = r#" - { - "name": "f", - "type": { - "type": "map", - "keyType": "string", - "valueType": "string", - "valueContainsNull": true - }, - "nullable": true, - "metadata": {} - } - "#; - let field: StructField = serde_json::from_str(data).unwrap(); - assert!(matches!(field.data_type, DataType::Map(_))); - } - - #[test] - fn test_roundtrip_decimal() { - let data = r#" - { - "name": "a", - "type": "decimal(10, 2)", - "nullable": false, - "metadata": {} - } - "#; - let field: StructField = serde_json::from_str(data).unwrap(); - assert!(matches!( - field.data_type, - DataType::Primitive(PrimitiveType::Decimal(10, 2)) - )); - - let json_str = serde_json::to_string(&field).unwrap(); - assert_eq!( - json_str, - r#"{"name":"a","type":"decimal(10,2)","nullable":false,"metadata":{}}"# - ); - } - - #[test] - fn test_invalid_decimal() { - let data = r#" - { - "name": "a", - "type": "decimal(39, 10)", - "nullable": false, - "metadata": {} - } - "#; - assert!(matches!( - serde_json::from_str::(data).unwrap_err(), - _ - )); - - let data = r#" - { - "name": "a", - "type": "decimal(10, 39)", - "nullable": false, - "metadata": {} - } - "#; - assert!(matches!( - serde_json::from_str::(data).unwrap_err(), - _ - )); - } - - #[test] - fn test_field_metadata() { - let data = r#" - { - "name": "e", - "type": { - "type": "array", - "elementType": { - "type": "struct", - "fields": [ - { - "name": "d", - "type": "integer", - "nullable": false, - "metadata": { - "delta.columnMapping.id": 5, - "delta.columnMapping.physicalName": "col-a7f4159c-53be-4cb0-b81a-f7e5240cfc49" - } - } - ] - }, - "containsNull": true - }, - "nullable": true, - "metadata": { - "delta.columnMapping.id": 4, - "delta.columnMapping.physicalName": "col-5f422f40-de70-45b2-88ab-1d5c90e94db1" - } - } - "#; - let field: StructField = serde_json::from_str(data).unwrap(); - - let col_id = field - .get_config_value(&ColumnMetadataKey::ColumnMappingId) - .unwrap(); - assert!(matches!(col_id, MetadataValue::Number(num) if *num == 4)); - let physical_name = field - .get_config_value(&ColumnMetadataKey::ColumnMappingPhysicalName) - .unwrap(); - assert!( - matches!(physical_name, MetadataValue::String(name) if *name == "col-5f422f40-de70-45b2-88ab-1d5c90e94db1") - ); - } - - #[test] - fn test_read_schemas() { - let file = std::fs::File::open("./tests/serde/schema.json").unwrap(); - let schema: Result = serde_json::from_reader(file); - assert!(schema.is_ok()); - - let file = std::fs::File::open("./tests/serde/checkpoint_schema.json").unwrap(); - let schema: Result = serde_json::from_reader(file); - assert!(schema.is_ok()) - } - #[test] fn test_get_invariants() { let schema: StructType = serde_json::from_value(json!({