-
Notifications
You must be signed in to change notification settings - Fork 546
fix: table UUID partitions not working #2916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JosephLenton
wants to merge
6
commits into
apache:main
Choose a base branch
from
JosephLenton:fix-uuid-partitions-fail
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1c023ba
chore: add a test that recreates the uuid partition error
JosephLenton 274c1b3
fix: update to turn UUIDs into Strings for Partitions
JosephLenton 4b2fee9
chore: add a unit test for RawLiteralEnum::try_from with uuid
JosephLenton 39007f5
chore: move UUID partition test to use datafusion integration tests
JosephLenton 07ecec7
feat: restrict UUID partitions to only hyphenated UUIDs
JosephLenton a9fbd60
refactor: move from serde solution to avro solution
JosephLenton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,7 +240,7 @@ fn json_timestamptz_ns_rejects_non_utc_offset() { | |
| // Per the spec, timestamptz_ns single-value serialization must use offset "+00:00"; Java's | ||
| // SingleValueParser enforces the same (DateTimeUtil.isUTCTimestamptz). A non-UTC offset is not a | ||
| // valid encoding and must be rejected, not silently re-based to UTC. | ||
| let record = serde_json::Value::String("2017-11-16T22:31:08.123456789+05:00".to_string()); | ||
| let record = JsonValue::String("2017-11-16T22:31:08.123456789+05:00".to_string()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this related? |
||
| let result = Literal::try_from_json(record, &Primitive(PrimitiveType::TimestamptzNs)); | ||
| assert!( | ||
| result.is_err(), | ||
|
|
@@ -252,7 +252,7 @@ fn json_timestamptz_ns_rejects_non_utc_offset() { | |
| fn json_timestamptz_rejects_non_utc_offset() { | ||
| // Micros-precision counterpart, mirroring Java's TestSingleValueParser.testInvalidTimestamptz: | ||
| // the offset must be "+00:00", so a non-UTC offset is rejected. | ||
| let record = serde_json::Value::String("2017-11-16T22:31:08.123456+05:00".to_string()); | ||
| let record = JsonValue::String("2017-11-16T22:31:08.123456+05:00".to_string()); | ||
| let result = Literal::try_from_json(record, &Primitive(PrimitiveType::Timestamptz)); | ||
| assert!( | ||
| result.is_err(), | ||
|
|
@@ -529,20 +529,38 @@ fn check_raw_literal_bytes_serde_via_avro( | |
| expected_literal: Literal, | ||
| expected_type: &Type, | ||
| ) { | ||
| use apache_avro::types::Value; | ||
|
|
||
| // Create an Avro bytes value and deserialize it through the RawLiteral path | ||
| let avro_value = Value::Bytes(input_bytes); | ||
| let raw_literal: RawLiteral = apache_avro::from_value(&avro_value).unwrap(); | ||
| let result = raw_literal.try_into(expected_type).unwrap(); | ||
| assert_eq!(result, Some(expected_literal)); | ||
| check_raw_literal_serde_via_avro(avro_value, expected_literal, expected_type); | ||
| } | ||
|
|
||
| fn check_raw_literal_bytes_error_via_avro(input_bytes: Vec<u8>, expected_type: &Type) { | ||
| use apache_avro::types::Value; | ||
|
|
||
| let avro_value = Value::Bytes(input_bytes); | ||
| let raw_literal: RawLiteral = apache_avro::from_value(&avro_value).unwrap(); | ||
| check_raw_literal_error_via_avro(avro_value, expected_type); | ||
| } | ||
|
|
||
| fn check_raw_literal_string_serde_via_avro( | ||
| input: &str, | ||
| expected_literal: Literal, | ||
| expected_type: &Type, | ||
| ) { | ||
| let avro_value = Value::String(input.to_string()); | ||
| check_raw_literal_serde_via_avro(avro_value, expected_literal, expected_type); | ||
| } | ||
|
|
||
| fn check_raw_literal_string_error_via_avro(input: &str, expected_type: &Type) { | ||
| let avro_value = Value::String(input.to_string()); | ||
| check_raw_literal_error_via_avro(avro_value, expected_type); | ||
| } | ||
|
|
||
| fn check_raw_literal_serde_via_avro(input: Value, expected_literal: Literal, expected_type: &Type) { | ||
| let raw_literal: RawLiteral = apache_avro::from_value(&input).unwrap(); | ||
| let result = raw_literal.try_into(expected_type).unwrap(); | ||
| assert_eq!(result, Some(expected_literal)); | ||
| } | ||
|
|
||
| fn check_raw_literal_error_via_avro(input: Value, expected_type: &Type) { | ||
| let raw_literal: RawLiteral = apache_avro::from_value(&input).unwrap(); | ||
| let result = raw_literal.try_into(expected_type); | ||
| assert!(result.is_err(), "Expected error but got: {result:?}"); | ||
| } | ||
|
|
@@ -616,6 +634,39 @@ fn test_raw_literal_bytes_uuid_wrong_length() { | |
| check_raw_literal_bytes_error_via_avro(bytes, &Primitive(PrimitiveType::Uuid)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_raw_literal_string_should_accept_hyphenated_uuid_as_value() { | ||
| let s = "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8"; | ||
| check_raw_literal_string_serde_via_avro( | ||
| s, | ||
| Literal::uuid(Uuid::parse_str(s).unwrap()), | ||
| &Primitive(PrimitiveType::Uuid), | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_raw_literal_string_should_reject_a_uuid_with_an_invalid_string() { | ||
| check_raw_literal_string_error_via_avro("not-a-uuid", &Primitive(PrimitiveType::Uuid)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_raw_literal_string_should_reject_non_hyphenated_uuids() { | ||
| check_raw_literal_string_error_via_avro( | ||
| "a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8", | ||
| &Primitive(PrimitiveType::Uuid), | ||
| ); | ||
|
|
||
| check_raw_literal_string_error_via_avro( | ||
| "urn:uuid:A1A2A3A4-B1B2-C1C2-D1D2-D3D4D5D6D7D8", | ||
| &Primitive(PrimitiveType::Uuid), | ||
| ); | ||
|
|
||
| check_raw_literal_string_error_via_avro( | ||
| "{a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8}", | ||
| &Primitive(PrimitiveType::Uuid), | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_raw_literal_bytes_decimal_precision_4_scale_2() { | ||
| // Precision 4 requires 2 bytes | ||
|
|
@@ -796,6 +847,25 @@ fn avro_convert_test_string() { | |
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_avro_should_convert_uuid_as_uuid() { | ||
| check_convert_with_avro( | ||
| Literal::uuid(Uuid::parse_str("f79c3e09-677c-4bbd-a479-3f349cb785e7").unwrap()), | ||
| &Primitive(PrimitiveType::Uuid), | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_avro_should_serialize_uuid_as_fixed_16_bytes() { | ||
| let uuid = Uuid::parse_str("f79c3e09-677c-4bbd-a479-3f349cb785e7").unwrap(); | ||
|
|
||
| check_serialize_avro( | ||
| Literal::uuid(uuid), | ||
| &Primitive(PrimitiveType::Uuid), | ||
| Value::Fixed(16, uuid.as_bytes().to_vec()), | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn avro_convert_test_date() { | ||
| check_convert_with_avro( | ||
|
|
||
|
JosephLenton marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,12 +16,14 @@ | |
| // under the License. | ||
|
|
||
| use std::collections::HashMap; | ||
| use std::sync::OnceLock; | ||
| use std::sync::{Arc, OnceLock}; | ||
|
|
||
| use iceberg::CatalogBuilder; | ||
| use iceberg::io::{ | ||
| S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_PATH_STYLE_ACCESS, S3_REGION, S3_SECRET_ACCESS_KEY, | ||
| }; | ||
| use iceberg_catalog_rest::REST_CATALOG_PROP_URI; | ||
| use iceberg_catalog_rest::{REST_CATALOG_PROP_URI, RestCatalog, RestCatalogBuilder}; | ||
| use iceberg_storage_opendal::OpenDalStorageFactory; | ||
| use iceberg_test_utils::{get_minio_endpoint, get_rest_catalog_endpoint, set_up}; | ||
|
|
||
| /// Global test fixture that uses environment-based configuration. | ||
|
|
@@ -52,6 +54,16 @@ impl GlobalTestFixture { | |
|
|
||
| GlobalTestFixture { catalog_config } | ||
| } | ||
|
|
||
| pub async fn rest_catalog(&self) -> RestCatalog { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we need this? |
||
| RestCatalogBuilder::default() | ||
| .with_storage_factory(Arc::new(OpenDalStorageFactory::S3 { | ||
| customized_credential_load: None, | ||
| })) | ||
| .load("rest", self.catalog_config.clone()) | ||
| .await | ||
| .unwrap() | ||
| } | ||
| } | ||
|
|
||
| /// Returns a reference to the global test fixture. | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, how is this different from AvroSchema::Uuid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this pr only changed iceberg schema to avro schema, I think we should also do vice versa?