blackmwk commented on code in PR #2955:
URL: https://github.com/apache/iceberg-rust/pull/2955#discussion_r3711172036
##########
crates/iceberg/src/spec/table_properties.rs:
##########
@@ -328,100 +354,10 @@ impl TableProperties {
}
impl TryFrom<&HashMap<String, String>> for TableProperties {
Review Comment:
We no longer need this, change TableMetadata's code to ser/de into
TableProperties directly.
##########
crates/property-macro/src/lib.rs:
##########
@@ -0,0 +1,321 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Derives for Iceberg's string-keyed property maps.
+
+use proc_macro::TokenStream;
+use proc_macro2::TokenStream as TokenStream2;
+use quote::quote;
+use syn::{
+ Attribute, Data, DeriveInput, Error, Expr, ExprLit, ExprPath, Field,
Fields, Ident, Lit, Meta,
+ Path, Type, parse_macro_input,
+};
+
+/// Derive parsing, defaults, JSON serialization, and getters for a typed
property map.
+///
+/// Each field must declare the table-property key and its default:
+///
+/// ```ignore
+/// #[derive(Properties)]
+/// struct Properties {
+/// #[key = "write.format.default"]
+/// #[default(DataFileFormat::Parquet)]
Review Comment:
I want to be able to add an optional #[doc="xxx"] attribute.
##########
crates/iceberg/src/spec/table_properties.rs:
##########
@@ -128,51 +108,97 @@ pub(crate) fn parse_metadata_file_compression(
}
}
-/// TableProperties that contains the properties of a table.
-#[derive(Debug)]
+fn serialize_compression_codec(codec: &CompressionCodec) -> String {
+ codec.name().to_string()
+}
+
+/// Typed table properties parsed from a table's string property map.
+#[derive(Debug, Properties)]
pub struct TableProperties {
/// The number of times to retry a commit.
- pub commit_num_retries: usize,
+ #[key = "commit.retry.num-retries"]
+ #[default(TableProperties::PROPERTY_COMMIT_NUM_RETRIES_DEFAULT)]
Review Comment:
I don't want to remove these constant, and use literals directly
##########
crates/iceberg/src/spec/table_properties.rs:
##########
@@ -128,51 +108,97 @@ pub(crate) fn parse_metadata_file_compression(
}
}
-/// TableProperties that contains the properties of a table.
-#[derive(Debug)]
+fn serialize_compression_codec(codec: &CompressionCodec) -> String {
+ codec.name().to_string()
+}
+
+/// Typed table properties parsed from a table's string property map.
+#[derive(Debug, Properties)]
pub struct TableProperties {
/// The number of times to retry a commit.
- pub commit_num_retries: usize,
+ #[key = "commit.retry.num-retries"]
+ #[default(TableProperties::PROPERTY_COMMIT_NUM_RETRIES_DEFAULT)]
Review Comment:
It should have a modification function `with_xxx(mut self, u64) ->
TableProperties`
##########
crates/iceberg/src/spec/table_properties.rs:
##########
Review Comment:
Instead of replace eexisting one, we should create a new struct
`ParsedTableProperties`. Apply the comments I added in this file, also I want
you to capture all properties from
https://github.com/apache/iceberg/blob/d8c10a1608170f0ba83be740d6ab0b6a3757cb3e/core/src/main/java/org/apache/iceberg/TableProperties.java#L25.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]