Skip to content

Core: SingleValueParser cannot round-trip optional null map values #18117

Description

@laserninja

Apache Iceberg version

main (development), commit c4784768b

Query engine

Other: Java API

Please describe the bug

The public single-value serializer writes an optional null map value, but its parser cannot read that output.

Types.MapType type = Types.MapType.ofOptional(
    1, 2, Types.StringType.get(), Types.IntegerType.get());
Map<String, Integer> value = new HashMap<>();
value.put("a", null);
String json = SingleValueParser.toJson(type, value);
SingleValueParser.fromJson(type, json);

The JSON is {"keys":["a"],"values":[null]}. Parsing throws NullPointerException: null value in entry: a=null.

Expected: recover the same map. Iceberg permits optional map values. mapFromJson currently uses ImmutableMap.Builder, which rejects all null values.

Consumer reproduction: a StaticDataTask containing an optional null map value can be serialized with ScanTaskParser.toJson, but restoring it with ScanTaskParser.fromJson fails with the same null-value exception. The regression in #18118 verifies serialization, restoration, and consumption of the resulting rows. It fails before the fix and passes afterward.

Proposed fix: allow optional null values while retaining immutable results and rejecting null/duplicate keys and null required values. This report concerns the single-value parser, not support for non-null map column defaults, which are separately disallowed by the field builder.

Willingness to contribute

  • I can contribute a fix for this bug independently

This report and its reproduction were prepared with AI assistance and verified locally.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions