You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/08/14 15:38:17 UTC

[I] Add `impl From<[(K, V); N]> for Metadata` so array literals work with `with_metadata` [arrow-rs]

alamb opened a new issue, #10686:
URL: https://github.com/apache/arrow-rs/issues/10686

   **Is your feature request related to a problem or challenge?**
   - Found while testing upgrade of arrow in DataFusion: https://github.com/apache/datafusion/pull/24366
   - Related to https://github.com/apache/arrow-rs/pull/10075
   
   While updating DataFusion to arrow 60 I found that a very common pattern for attaching metadata to a `Field` or `Schema` no longer compiles. Before, `with_metadata` took a `HashMap<String, String>`, so an array literal converted via type inference:
   
   ```rust
   Field::new("name", DataType::Utf8, false)
       .with_metadata([("some_key".to_string(), "some_value".to_string())].into())
   ```
   
   Now that metadata parameters are generic (`impl Into<Metadata>`), the `.into()` target can no longer be inferred and this fails with `error[E0283]: type annotations needed`. The same applies to `Default::default()` and `.collect()` in metadata argument position. This was the single largest source of churn in the DataFusion upgrade (~25 call sites).
   
   **Describe the solution you'd like**
   
   An array conversion such as:
   
   ```rust
   impl<K: Into<String>, V: Into<String>, const N: usize> From<[(K, V); N]> for Metadata
   ```
   
   so callers can pass the array directly, with no `.into()` and no owned `String` conversions:
   
   ```rust
   Field::new("name", DataType::Utf8, false).with_metadata([("some_key", "some_value")])
   ```
   
   **Describe alternatives you've considered**
   
   Spelling out the type at each call site, e.g. `Metadata::new().with("some_key", "some_value")` or `HashMap::from([...])`; this works but required touching every call site.
   
   **Additional context**
   


-- 
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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add `impl From<[(K, V); N]> for Metadata` so array literals work with `with_metadata` [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on issue #10686:
URL: https://github.com/apache/arrow-rs/issues/10686#issuecomment-5300284888

   I think this functionality already exist
   https://github.com/apache/arrow-rs/blob/b5794fbda02c45675e6ce83c916dae70c5df477a/arrow-schema/src/metadata.rs#L196
   
   ```rust
   fn create_field_with_metadata() {
           let field = Field::new("test", datatype::DataType::Utf8, false)
               .with_metadata([("key 1", "value 1")]);
           println!("field : {:?}", field)
       }
   ```
   
   compiles fine


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add `impl From<[(K, V); N]> for Metadata` so array literals work with `with_metadata` [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #10686:
URL: https://github.com/apache/arrow-rs/issues/10686#issuecomment-5318987486

   Thanks for checking @Rich-T-kid 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add `impl From<[(K, V); N]> for Metadata` so array literals work with `with_metadata` [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #10686: Add `impl From<[(K, V); N]> for Metadata` so array literals work with `with_metadata`
URL: https://github.com/apache/arrow-rs/issues/10686


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org