apache / apache/beam

[Feature Request]: Support for iceberg dynamic destination with varying schema

Open
#38,055 2 comments 0 reactions 0 assignees View on GitHub
awaiting triage java new feature P2
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

### What would you like to happen?

## Summary
Today, Beam supports dynamic destination routing for Iceberg, but the input PCollection still requires a single Beam schema. This makes it difficult to build generic ingestion pipelines where:
- new event types can appear dynamically
- each event type maps to a different Iceberg table
- each event type has its own schema

## Problem
A common ingestion pattern is:
1. Read generic events from a streaming pipeline like Pub/Sub
2. Determine destination table from an attribute like event_type
3. Fetch the schema for that event type dynamically from a central schema store
4. Write each record to its corresponding Iceberg table

This works conceptually for table routing, but breaks down because PCollection has one schema for the entire collection. In practice, that means:
- dynamic table name is possible
- dynamic schema per destination is not
- newly introduced event types require pipeline changes

## What is needed?
We need per-destination schema, similar to [BigQuery DynamicDestinations](https://beam.apache.org/releases/javadoc/current/org/apache/beam/sdk/io/gcp/bigquery/DynamicDestinations.html).

Example Idea:
```
IcebergIO.write()
.to(new DynamicDestinations() {
@Override
public DestinationT getDestination(ValueInSingleWindow element) { ... }

@Override
public String getTableIdentifier(DestinationT destination) { ... }

@Override
public org.apache.iceberg.Schema getSchema(DestinationT destination) { ... }
})
```

### Issue Priority

Priority: 2 (default / most feature requests should be filed as P2)

### Issue Components

- [ ] Component: Python SDK
- [x] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [ ] 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: Samza 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.