Skip to content

MapArray::try_new allows to create nullable keys even though the spec disallow it #10268

Closed

Description

@rluvaton

Describe the bug

According to Arrow spec on Map

Neither the "entries" field nor the "key" field may be nullable.

From Schema.fbs

but there is no validation that disallow creating map with nullable keys

To Reproduce

#[test]
fn create_map_with_null_keys() {
  let keys = Int32Array::from(vec![Some(1), None]);
  let values = StringArray::from(vec![None, Some("hey")]);
  
  let entries = StructArray::new(
    Fields::from(vec![
      Field::new("keys", DataType::Int32, true),
      Field::new("values", DataType::Utf8, true),
    ]), vec![Arc::new(keys), Arc::new(values)], None);
  
  MapArray::try_new(
    Arc::new(Field::new("entries", entries.data_type().clone(), false)),
    OffsetBuffer::from_lengths(vec![2]),
    entries,
    None,
    false
  ).expect_err("should not allow nullable keys");
}

Expected behavior

it should fail to create map array with:

  1. nullable key field
  2. keys with logical nulls that are not masked by map nulls

Additional context

as found out by @Jefffrey in #9486 (comment)

Activity

  1. added
    bug
    on Jul 2, 2026
  2. added theissue type on Jul 2, 2026
  3. added a commit that references this issue on Jul 6, 2026
    d8d980b
  4. added a commit that references this issue on Jul 10, 2026
    8e19113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions