Is your feature request related to a problem or challenge?
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:
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.
Describe the solution you'd like
An array conversion such as:
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:
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
Is your feature request related to a problem or challenge?
Metadatastruct instead ofHashMap<String, String>for metadata: Ordered; cheap to clone #10075While updating DataFusion to arrow 60 I found that a very common pattern for attaching metadata to a
FieldorSchemano longer compiles. Before,with_metadatatook aHashMap<String, String>, so an array literal converted via type inference:Now that metadata parameters are generic (
impl Into<Metadata>), the.into()target can no longer be inferred and this fails witherror[E0283]: type annotations needed. The same applies toDefault::default()and.collect()in metadata argument position.Describe the solution you'd like
An array conversion such as:
so callers can pass the array directly, with no
.into()and no ownedStringconversions:Describe alternatives you've considered
Spelling out the type at each call site, e.g.
Metadata::new().with("some_key", "some_value")orHashMap::from([...]); this works but required touching every call site.Additional context