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

Add builder style methods to Field #1934

Closed
alamb opened this issue Jun 23, 2022 · 0 comments · Fixed by #2024
Closed

Add builder style methods to Field #1934

alamb opened this issue Jun 23, 2022 · 0 comments · Fixed by #2024
Assignees
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog good first issue Good for newcomers

Comments

@alamb
Copy link
Contributor

alamb commented Jun 23, 2022

Is your feature request related to a problem or challenge? Please describe what you are trying to do.:
I want to make a field Nullable as part of outer joins creation in DataFusion

I would like a builder style API so I can write code like

let field = old_field.clone()
  .with_nullable(force_nullable)

but instead I have to write

    if force_nullable {
        Field::new(
            old_field.name(),
            old_field.data_type().clone(),
            true
        )
    } else {
        old_field.clone()
    }

Describe the solution you'd like
Ideally we could add functions to https://docs.rs/arrow/16.0.0/arrow/datatypes/struct.Field.html

impl Field {
  pub fn with_nullable(mut self, nullable: bool) -> Self {
   .. 
  }
  pub fn with_dict_id(mut self, dict_id: i64) -> Self {
   .. 
  }
  pub fn with_data_type(mut self, data_type: DataType) -> Self {
   .. 
  }
  pub fn with_dict_is_ordered(mut self, dict_is_ordered: Option<bool>) -> Self {
   .. 
  }
}

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@alamb alamb added good first issue Good for newcomers arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog labels Jun 23, 2022
@alamb alamb self-assigned this Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant