Skip to content

Commit beb2ac1

Browse files
authored
doc: Clarify use of default map field name (#1208)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #1202 . --> - Closes #1202.
1 parent 9c70670 commit beb2ac1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/iceberg/src/spec/values.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,22 @@ impl Datum {
12271227
/// It used in Literal::Map, to make it hashable, the order of key-value pairs is stored in a separate vector
12281228
/// so that we can hash the map in a deterministic way. But it also means that the order of key-value pairs is matter
12291229
/// for the hash value.
1230+
///
1231+
/// When converting to Arrow (e.g., for Iceberg), the map should be represented using
1232+
/// the default field name "key_value".
1233+
///
1234+
/// Example:
1235+
///
1236+
/// ```text
1237+
/// let key_value_field = Field::new(
1238+
/// DEFAULT_MAP_FIELD_NAME,
1239+
/// arrow_schema::DataType::Struct(vec![
1240+
/// Arc::new(key_field.clone()),
1241+
/// Arc::new(value_field.clone()),
1242+
/// ].into()),
1243+
/// false
1244+
/// );
1245+
/// '''
12301246
#[derive(Clone, Debug, PartialEq, Eq)]
12311247
pub struct Map {
12321248
index: HashMap<Literal, usize>,

0 commit comments

Comments
 (0)