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

  1. Use a standard view (View.asIterable / View.asMap / View.asMultimap) so the materialization is ITERABLE or MULTIMAP
  2. Inject side-input data into DoFnTester via withSideInputs plus a view backed by a supported materialization
  3. 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

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/8224ecd9ead71a94. Report an issue: GitHub.