Skip to content
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

feat: Add NameMapping #1072

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jonathanc-n
Copy link
Contributor

Which issue does this PR close?

What changes are included in this PR?

Added NameMapping implementation. Includes updating, creating, and applying to other schema.

Are these changes tested?

Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jonathanc-n for this pr, generally I think this is quite useful to complete features of NameMapping. Here are my suggestions:

  1. Split the pr into several smaller ones.
  2. Add MappedFields like java does.
  3. Add visitor for index by name and index by field id with enough tests
  4. Add visitor for update mappings with tests.

}

/// Returns an index mapping names to `MappedField`` by visiting the schema.
pub fn index_by_name(schema: &Schema) -> HashMap<String, MappedField> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should expose this method to user, the index should be constructed lazily.

/// Iceberg fallback field name to ID mapping.
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
#[serde(transparent)]
pub struct NameMapping {
/// Holds mapped fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we lack a MappedFields field like java one

}

/// Applies the name mapping to the given schema.
pub fn apply_name_mapping(schema: &Schema, mapping: &NameMapping) -> Result<Type> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confusing about this method, is there any case to demonstrate its usage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants