{"record":{"id":"c9e697aae5371676","repo":"apache/beam","slug":"unsupported-access-pattern-for-r-r","errorCode":null,"errorMessage":"Unsupported access pattern for %r: %r","messagePattern":"Unsupported access pattern for %r: %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/dataflow/dataflow_runner.py","lineNumber":285,"sourceCode":"            access_pattern = side_input._side_input_data().access_pattern\n            if access_pattern == common_urns.side_inputs.ITERABLE.urn:\n              # TODO(https://github.com/apache/beam/issues/20043): Stop\n              # patching up the access pattern to appease Dataflow when\n              # using the UW and hardcode the output type to be Any since\n              # the Dataflow JSON and pipeline proto can differ in coders\n              # which leads to encoding/decoding issues within the runner.\n              side_input.pvalue.element_type = typehints.Any\n              new_side_input = _DataflowIterableSideInput(side_input)\n            elif access_pattern == common_urns.side_inputs.MULTIMAP.urn:\n              # Ensure the input coder is a KV coder and patch up the\n              # access pattern to appease Dataflow.\n              side_input.pvalue.element_type = typehints.coerce_to_kv_type(\n                  side_input.pvalue.element_type, transform_node.full_label)\n              side_input.pvalue.requires_deterministic_key_coder = (\n                  deterministic_key_coders and transform_node.full_label)\n              new_side_input = _DataflowMultimapSideInput(side_input)\n            else:\n              raise ValueError(\n                  'Unsupported access pattern for %r: %r' %\n                  (transform_node.full_label, access_pattern))\n            new_side_inputs.append(new_side_input)\n          transform_node.side_inputs = new_side_inputs\n          transform_node.transform.side_inputs = new_side_inputs\n\n    return SideInputVisitor()\n\n  @staticmethod\n  def flatten_input_visitor():\n    # Imported here to avoid circular dependencies.\n    from apache_beam.pipeline import PipelineVisitor\n\n    class FlattenInputVisitor(PipelineVisitor):\n      \"\"\"A visitor that replaces the element type for input ``PCollections``s of\n       a ``Flatten`` transform with that of the output ``PCollection``.\n      \"\"\"\n      def visit_transform(self, transform_node):","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/dataflow/dataflow_runner.py#L267-L303","documentation":"During pipeline translation, the DataflowRunner converts each side input into a representation Dataflow supports. If a ParDo accesses a side input with an access pattern (iteration order / windowing view) that Dataflow's non-portable path cannot represent, this ValueError is thrown naming the transform label and the unsupported pattern.","triggerScenarios":"Calling pvalue.AsIter/AsList/AsMultimap (or beam.SideInput access) with a windowing/view combination the runner rejects during DataflowRunner.visit_transform — specifically an access_pattern that is neither MATERIALIZE_ITERABLE nor the multimap form.","commonSituations":"Using AsMultimap with windowed side inputs, using unsupported side-input views on non-global windows, or piping code written for a newer Beam version to an older Dataflow runner.","solutions":["Use a standard side-input view: pvalue.AsDict(x) or pvalue.AsList(x) instead of the unsupported pattern.","Simplify side-input windowing (e.g. re-window to the global window or use beam.pvalue.AsSingleton with a default).","Upgrade apache-beam — newer versions support more side-input access patterns on Dataflow.","Restructure the pipeline to join via CoGroupByKey instead of an exotic side-input view."],"exampleFix":"// before\nfiltered = numbers | 'Filter' >> beam.ParDo(FilterFn(), min_v=beam.pvalue.AsIter(small))\n// after\nfiltered = numbers | 'Filter' >> beam.ParDo(FilterFn(), min_v=beam.pvalue.AsSingleton(small, default=0))","handlingStrategy":"validation","validationCode":"def uses_supported_side_inputs(pipeline):\n    # avoid AsIter/AsMultimap on windowed side inputs; prefer AsDict/AsSingleton\n    for t in pipeline.applied_transforms:\n        if 'AsMultimap' in str(t.transform): return False\n    return True","typeGuard":null,"tryCatchPattern":"try:\n    with beam.Pipeline(runner='DataflowRunner', options=opts) as p:\n        build(p)\nexcept ValueError as e:\n    if 'Unsupported access pattern' in str(e):\n        # fall back to CoGroupByKey-based join\n        build_with_cogroupbykey()","preventionTips":["Use AsSingleton/AsDict/AsList views for Dataflow side inputs","Avoid multimap-style side inputs on windowed PCollections","Test pipeline construction with DirectRunner plus Dataflow translation in CI"],"tags":["python","apache-beam","dataflow","side-input","pipeline-translation"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}