apache/beam · error · IllegalStateException
Only materializations of type %s supported, received %s
Error message
Only materializations of type %s supported, received %s
What it means
When a DoFn declares a side input, DoFnTester maps the view's materialization URN onto a MockSideInputContainer. Only ITERABLE and MULTIMAP materializations are supported; any other URN (e.g. a custom or newer materialization type) triggers this IllegalStateException.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/DoFnTester.java:633
case Materializations.ITERABLE_MATERIALIZATION_URN:
return ((ViewFn<Materializations.IterableView, T>) view.getViewFn())
.apply(() -> Collections.emptyList());
case Materializations.MULTIMAP_MATERIALIZATION_URN:
return ((ViewFn<Materializations.MultimapView, T>) view.getViewFn())
.apply(
new MultimapView() {
@Override
public Iterable get() {
return Collections.emptyList();
}
@Override
public Iterable get(@Nullable Object o) {
return Collections.emptyList();
}
});
default:
throw new IllegalStateException(
String.format(
"Only materializations of type %s supported, received %s",
Arrays.asList(
Materializations.ITERABLE_MATERIALIZATION_URN,
Materializations.MULTIMAP_MATERIALIZATION_URN),
view.getViewFn().getMaterialization().getUrn()));
}
}
@Override
public Instant timestamp() {
return element.getTimestamp();
}
@Override
public PaneInfo pane() {
return element.getPaneInfo();
}View on GitHub (pinned to 12126d8942)
Solutions
- Use a standard view (View.asIterable / View.asMap / View.asMultimap) so the materialization is ITERABLE or MULTIMAP
- Inject side-input data into DoFnTester via withSideInputs plus a view backed by a supported materialization
- Test the DoFn in a full TestPipeline run if custom side-input materializations are required
Example fix
// before PCollectionView<Map<K,V>> view = customExperimentalView(); // after PCollectionView<Map<K,V>> view = input.apply(View.asMap());
Defensive patterns
Strategy: validation
Validate before calling
String urn = view.getViewFn().getMaterialization().getUrn();
boolean ok = urn.equals(Materializations.ITERABLE_MATERIALIZATION_URN)
|| urn.equals(Materializations.MULTIMAP_MATERIALIZATION_URN);
if (!ok) throw new IllegalStateException("DoFnTester cannot test this view: " + urn); Type guard
boolean isTestableView(PCollectionView<?> v) {
String urn = v.getViewFn().getMaterialization().getUrn();
return urn.equals(Materializations.ITERABLE_MATERIALIZATION_URN)
|| urn.equals(Materializations.MULTIMAP_MATERIALIZATION_URN);
} Try / catch
try { tester.withSideInputs(view); }
catch (IllegalStateException e) { /* fall back to TestPipeline run */ } Prevention
- Use standard View.asIterable/asMap/asMultimap for side inputs in tests
- Check the materialization URN before wiring side inputs into DoFnTester
- Prefer TestPipeline when using custom view implementations
When it happens
Trigger: Calling DoFnTester.withSideInputs(...) with a PCollectionView whose ViewFn reports a materialization URN other than Materializations.ITERABLE_MATERIALIZATION_URN or MULTIMAP_MATERIALIZATION_URN.
Common situations: Testing a DoFn with side inputs whose view comes from a custom CombineFn or a runner-specific view implementation producing an exotic materialization; Beam upgrades adding new materialization types DoFnTester doesn't know.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- The pipeline has not been run.
- The pipeline contains abandoned PAssert(s).
- The pipeline contains abandoned PTransform(s).
- Not expected to access DoFn.StartBundleContext from @Process
- Not expected to access DoFn.FinishBundleContext from @Proces
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8224ecd9ead71a94.
Report an issue: GitHub.