apache / apache/beam

[Bug]: IcebergIO write fails with "Null value set on non-nullable field keyMetadata" — @Nullable not detected in SerializableDataFile schema

Open
#38,621 2 comments 0 reactions 1 assignee Claimed by @ahmedabu98 View on GitHub
bug io java P1
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
205

Description

### What happened?

When writing to an Iceberg table via `IcebergIO` on Dataflow, the pipeline fails with `IllegalArgumentException` during encoding of `FileWriteResult`. The root cause is:

```
java.lang.RuntimeException: Null value set on non-nullable field
Field{name=keyMetadata, description=, type=BYTES NOT NULL, options={{}}}
```
The `SerializableDataFile` schema at runtime marks **all fields as NOT NULL**, despite fields 6–13 (`keyMetadata`, `splitOffsets`, `columnSizes`, `valueCounts`, `nullValueCounts`, `nanValueCounts`, `lowerBounds`, `upperBounds`) being declared with `@Nullable` in the source code.

The `@Nullable` annotation used is `org.checkerframework.checker.nullness.qual.Nullable` (a `TYPE_USE` annotation), which `AutoValueSchema` / `FieldValueTypeInformation.hasNullableReturnType()` appears to not detect at runtime.

The error surfaces on `keyMetadata` because it is the first field that is actually `null` (normal for unencrypted Iceberg tables), but the issue affects all nullable fields in `SerializableDataFile`.

### Issue Priority

Priority: 1 (data loss / total loss of function)

### Issue Components

- [ ] Component: Python SDK
- [x] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [x] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Prism Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.