Skip to content

Commit 403e206

Browse files
committed
Update docs and doc tests
1 parent b27552a commit 403e206

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

datafusion/expr/src/expr.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,10 @@ impl Expr {
16061606
/// # Example
16071607
/// ```
16081608
/// # use datafusion_expr::col;
1609-
/// use std::collections::HashMap;
1609+
/// # use std::collections::HashMap;
1610+
/// # use datafusion_expr::expr::FieldMetadata;
16101611
/// let metadata = HashMap::from([("key".to_string(), "value".to_string())]);
1612+
/// let metadata = FieldMetadata::from(metadata);
16111613
/// let expr = col("foo").alias_with_metadata("bar", Some(metadata));
16121614
/// ```
16131615
///
@@ -1636,8 +1638,10 @@ impl Expr {
16361638
/// # Example
16371639
/// ```
16381640
/// # use datafusion_expr::col;
1639-
/// use std::collections::HashMap;
1641+
/// # use std::collections::HashMap;
1642+
/// # use datafusion_expr::expr::FieldMetadata;
16401643
/// let metadata = HashMap::from([("key".to_string(), "value".to_string())]);
1644+
/// let metadata = FieldMetadata::from(metadata);
16411645
/// let expr = col("foo").alias_qualified_with_metadata(Some("tbl"), "bar", Some(metadata));
16421646
/// ```
16431647
///

docs/source/library-user-guide/upgrading.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@
1919

2020
# Upgrade Guides
2121

22+
## DataFusion `49.0.0`
23+
24+
### Metadata is now represented by `FieldMetadata`
25+
26+
Metadata from the Arrow `Field` is now stored using the `FieldMetadata`
27+
structure. In prior versions it was stored as both a `HashMap<String, String>`
28+
and a `BTreeMap<String, String>`. `FieldMetadata` is a easier to work with and
29+
is more efficient.
30+
31+
To create `FieldMetadata` from a `Field`:
32+
33+
```rust
34+
# /* comment to avoid running
35+
let metadata = FieldMetadata::from(&field);
36+
# */
37+
```
38+
39+
To add metadata to a `Field`, use the `add_to_field` method:
40+
41+
```rust
42+
# /* comment to avoid running
43+
let updated_field = metadata.add_to_field(field);
44+
# */
45+
```
46+
47+
See [#16317] for details.
48+
49+
[#16317]: https://github.com/apache/datafusion/pull/16317
50+
2251
## DataFusion `48.0.0`
2352

2453
### The `VARCHAR` SQL type is now represented as `Utf8View` in Arrow.

0 commit comments

Comments
 (0)