You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "marvinlanhenke (via GitHub)" <gi...@apache.org> on 2024/03/15 19:06:59 UTC
[PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
marvinlanhenke opened a new pull request, #272:
URL: https://github.com/apache/iceberg-rust/pull/272
### Which issue does this PR close?
Closes #271
### Rationale for this change
Serialization of metadata.json has missing fields (properties and snapshots) when being empty this causes downstream errors when reading the metadata file. Also current default values for `partition_specs` and `sort_orders` (set with TableMetadataBuilder) are causing downstream errors.
### What changes are included in this PR?
Changed: Not return `None` for properties and snapshots, when empty.
Changed: Set default values for `partition_specs` and `sort_orders`.
### Are these changes tested?
Yes
### Are there any user-facing changes?
No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#discussion_r1528887679
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -727,14 +746,10 @@ pub(super) mod _serde {
.collect(),
default_spec_id: v.default_spec_id,
last_partition_id: v.last_partition_id,
- properties: if v.properties.is_empty() {
- None
- } else {
- Some(v.properties)
- },
+ properties: Some(v.properties),
current_snapshot_id: v.current_snapshot_id.or(Some(-1)),
snapshots: if v.snapshots.is_empty() {
- None
+ Some(vec![])
Review Comment:
We should not let `properties` and `snapshot` be `Option` if they must be serialized.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#discussion_r1528887679
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -727,14 +746,10 @@ pub(super) mod _serde {
.collect(),
default_spec_id: v.default_spec_id,
last_partition_id: v.last_partition_id,
- properties: if v.properties.is_empty() {
- None
- } else {
- Some(v.properties)
- },
+ properties: Some(v.properties),
current_snapshot_id: v.current_snapshot_id.or(Some(-1)),
snapshots: if v.snapshots.is_empty() {
- None
+ Some(vec![])
Review Comment:
Sorry, I just thought of something: We should not let `properties` and `snapshot` be `Option` if they must be serialized.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "marvinlanhenke (via GitHub)" <gi...@apache.org>.
marvinlanhenke commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2005809328
@liurenjie1024
Thanks for the review, I will apply those changes / suggestions.
I was testing / using Trino as a client.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2006052205
> @liurenjie1024 Thanks for the review, I applied those changes / suggestions.
>
> I was testing / using Trino as a client.
Interesting, trino is supposed to use java library, but [this test](https://github.com/apache/iceberg/blob/489ec2972e352a701745f0a15bdfaa722ad07f3a/core/src/test/java/org/apache/iceberg/TestTableMetadata.java#L1360) says it's valid. Anyway, let's move on and test it later.
cc @Fokko Any ideas?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "marvinlanhenke (via GitHub)" <gi...@apache.org>.
marvinlanhenke commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2002565662
cc @liurenjie1024 @Xuanwo @ZENOTME
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#discussion_r1529576423
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -297,19 +298,37 @@ impl TableMetadataBuilder {
properties,
} = table_creation;
- if partition_spec.is_some() {
- return Err(Error::new(
- ErrorKind::FeatureUnsupported,
- "Can't create table with partition spec now",
- ));
- }
+ let partition_specs = match partition_spec {
+ Some(_) => {
+ return Err(Error::new(
+ ErrorKind::FeatureUnsupported,
+ "Can't create table with partition spec now",
+ ))
+ }
+ None => HashMap::from([(
+ 0,
+ Arc::new(PartitionSpec {
+ spec_id: 0,
+ fields: vec![],
+ }),
+ )]),
+ };
- if sort_order.is_some() {
- return Err(Error::new(
- ErrorKind::FeatureUnsupported,
- "Can't create table with sort order now",
- ));
- }
+ let sort_orders = match sort_order {
+ Some(_) => {
+ return Err(Error::new(
+ ErrorKind::FeatureUnsupported,
+ "Can't create table with sort order now",
+ ))
+ }
+ None => HashMap::from([(
+ 0,
+ Arc::new(SortOrder {
+ order_id: 0,
Review Comment:
Could we replace this with `DEFAULT_SORT_ORDER_ID`?
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -727,14 +746,10 @@ pub(super) mod _serde {
.collect(),
default_spec_id: v.default_spec_id,
last_partition_id: v.last_partition_id,
- properties: if v.properties.is_empty() {
- None
- } else {
- Some(v.properties)
- },
+ properties: Some(v.properties),
current_snapshot_id: v.current_snapshot_id.or(Some(-1)),
snapshots: if v.snapshots.is_empty() {
- None
+ Some(vec![])
Review Comment:
This is interesting, the spec says `properties` and `snapshot` are both optional, and [this example](https://github.com/apache/iceberg/blob/3d929d459ab21efe313f42754b58b4392d547aee/core/src/test/resources/TableMetadataV2ValidMinimal.json) says it doesn't require these fields.
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -297,19 +298,37 @@ impl TableMetadataBuilder {
properties,
} = table_creation;
- if partition_spec.is_some() {
- return Err(Error::new(
- ErrorKind::FeatureUnsupported,
- "Can't create table with partition spec now",
- ));
- }
+ let partition_specs = match partition_spec {
+ Some(_) => {
+ return Err(Error::new(
+ ErrorKind::FeatureUnsupported,
+ "Can't create table with partition spec now",
+ ))
+ }
+ None => HashMap::from([(
+ 0,
Review Comment:
Could we replace these with `DEFAULT_SPEC_ID`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2006184189
> Doesn't the test assume that e.g. the key properties is present in the serialized JSON?
IIUC, The test reads [this file](https://github.com/apache/iceberg/blob/3d929d459ab21efe313f42754b58b4392d547aee/core/src/test/resources/TableMetadataV2ValidMinimal.json), and `properties`, `snapshots` are missed. There is a distinction between empty value and missing value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2006638318
> yes you're correct - but I think the difference is when we checked `properties.is_emtpy()` and returned `None` the serialization (due to serde config) was completely skipped. As far as I understand the java implementation when the json is missing e.g. `properties` an empty map is created? https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/TableMetadataParser.java#L441-L447
Yes, that means when `properties` is missed, it should not report error. What kind of error did you see?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "marvinlanhenke (via GitHub)" <gi...@apache.org>.
marvinlanhenke commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2006089207
> > @liurenjie1024 Thanks for the review, I applied those changes / suggestions.
> > I was testing / using Trino as a client.
>
> Interesting, trino is supposed to use java library, but [this test](https://github.com/apache/iceberg/blob/489ec2972e352a701745f0a15bdfaa722ad07f3a/core/src/test/java/org/apache/iceberg/TestTableMetadata.java#L1360) says it's valid. Anyway, let's move on and test it later.
>
> cc @Fokko Any ideas?
Doesn't the test assume that e.g. the key `properties` is present in the serialized JSON? During my tests I got the error-message that Trino could not parse missing properties, thus the PR.
Thanks again for merging and the review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "marvinlanhenke (via GitHub)" <gi...@apache.org>.
marvinlanhenke commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2006672626
> > yes you're correct - but I think the difference is when we checked `properties.is_emtpy()` and returned `None` the serialization (due to serde config) was completely skipped. As far as I understand the java implementation when the json is missing e.g. `properties` an empty map is created? https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/TableMetadataParser.java#L441-L447
>
> Yes, that means when `properties` is missed, it should not report error. What kind of error did you see?
Now, I get your point - the error I was getting "...Could not parse missing `properties" by the trino-client
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "marvinlanhenke (via GitHub)" <gi...@apache.org>.
marvinlanhenke commented on PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272#issuecomment-2006453883
yes you're correct - but I think the difference is when we checked `properties.is_emtpy()` and returned `None` the serialization (due to serde config) was completely skipped. As far as I understand the java implementation when the json is missing e.g. `properties` an empty map is created? https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/TableMetadataParser.java#L441-L447
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Metadata Serde + default partition_specs and sort_orders [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 merged PR #272:
URL: https://github.com/apache/iceberg-rust/pull/272
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org