blackmwk commented on code in PR #3044:
URL: https://github.com/apache/iceberg-rust/pull/3044#discussion_r3877716724
##########
crates/property-macro/README.md:
##########
@@ -271,3 +275,68 @@ converted into their field type with `Into`.
`from_properties` and both custom parser hooks use `iceberg::Result`. Generated
`FromStr` failures use `ErrorKind::DataInvalid`. The macro preserves errors
from
custom parsers and adds the primary property key as error context.
+
+## `properties_view!` function-like macro
+
+`properties_view!` independently defines a lightweight borrowed view over a
+flat property map. Its struct-shaped fields are declarations used to generate
+getters rather than stored fields. Constructing the view does not parse
+anything; each generated getter parses and returns only its declared property.
+Missing properties use their annotated defaults, while invalid configured
+values return an error from the corresponding getter.
+
+```rust
+use std::collections::HashMap;
+
+use iceberg_property_macro::properties_view;
+
+properties_view! {
+ #[derive(Debug)]
+ pub struct WriteProperties {
+ // `getter` makes a generated getter public. Without it, the getter is
+ // private, regardless of the declaration's visibility modifier.
+
+ /// Number of times to retry a commit.
+ #[property(key = "commit.retry.num-retries", default = 4, getter)]
+ commit_num_retries: usize,
+
+ /// Optional configured base directory for metadata files.
+ #[property(key = "write.metadata.path", default = None)]
+ raw_write_metadata_path: Option<String>,
+ }
+}
+
+impl WriteProperties<'_> {
+ /// Returns the configured metadata path or the table's metadata directory.
+ pub fn write_metadata_path(&self, table_path: &str) ->
iceberg::Result<String> {
+ Ok(self.raw_write_metadata_path()?.unwrap_or_else(|| {
+ format!("{}/metadata", table_path.trim_end_matches('/'))
+ }))
+ }
+}
+
+fn read(properties: &HashMap<String, String>) -> iceberg::Result<()> {
+ let view = WriteProperties::new(properties);
+ let _retries = view.commit_num_retries()?;
+ let _metadata_path = view.write_metadata_path("s3://bucket/table")?;
+ Ok(())
+}
+```
+
+The generated type has one lifetime parameter and contains only a reference to
Review Comment:
Done. The example now documents the generated constructor signature and
lifetime, explains that its visibility matches the view declaration, and
clarifies that construction only stores the map reference without parsing.
--
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]