barronw commented on code in PR #740: URL: https://github.com/apache/iceberg-rust/pull/740#discussion_r1862755672
########## crates/iceberg/src/spec/mod.rs: ########## @@ -20,6 +20,7 @@ mod datatypes; mod manifest; mod manifest_list; +mod name_mapping; Review Comment: Please let me know if I should also expose this in `TableMetadata` and `Table` (similarly to pyiceberg). ########## crates/iceberg/src/spec/name_mapping.rs: ########## @@ -0,0 +1,307 @@ +// 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. + +//! Iceberg name mapping. + +use serde::{Deserialize, Serialize}; +use serde_with::{serde_as, DefaultOnNull}; + +/// Iceberg fallback field name to ID mapping. +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] +#[serde(transparent)] +pub struct NameMapping { + pub root: Vec<MappedField>, +} + +/// Maps field names to IDs. +#[serde_as] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] +#[serde(rename_all = "kebab-case")] +pub struct MappedField { + #[serde(skip_serializing_if = "Option::is_none")] + pub field_id: Option<i32>, Review Comment: @Fokko I noticed that pyiceberg has this field as required instead of optional ([reference](https://github.com/apache/iceberg-python/blob/main/pyiceberg/table/name_mapping.py#L40)), but the spec says that tables may omit this field ([reference](https://iceberg.apache.org/spec/#column-projection)). > Fields that exist in imported files but not in the Iceberg schema may omit field-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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org