{"record":{"id":"a53d46b8410cd654","repo":"apache/beam","slug":"the-given-pcoll-s-is-not-a-dict-an-iterable-or-a-pcollection","errorCode":null,"errorMessage":"The given pcoll %s is not a dict, an iterable or a PCollection.","messagePattern":"The given pcoll (.+?) is not a dict, an iterable or a PCollection\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/interactive/interactive_beam.py","lineNumber":758,"sourceCode":"      # This is equivalent to `show(square)` because `square` depends on `init`\n      # and `init` is included in the pipeline fragment and computed anyway.\n      show(init, square)\n\n      # Below is similar to running `p.run()`. It computes data for both\n      # PCollection `square` and PCollection `cube`, then visualizes them.\n      show(square, cube)\n  \"\"\"\n  flatten_pcolls = []\n  for pcoll_container in pcolls:\n    if isinstance(pcoll_container, dict):\n      flatten_pcolls.extend(pcoll_container.values())\n    elif isinstance(pcoll_container, (beam.pvalue.PCollection, DeferredBase)):\n      flatten_pcolls.append(pcoll_container)\n    else:\n      try:\n        flatten_pcolls.extend(iter(pcoll_container))\n      except TypeError:\n        raise ValueError(\n            'The given pcoll %s is not a dict, an iterable or a PCollection.' %\n            pcoll_container)\n\n  # Iterate through the given PCollections and convert any deferred DataFrames\n  # or Series into PCollections.\n  pcolls = set()\n\n  # The element type is used to help visualize the given PCollection. For the\n  # deferred DataFrame/Series case it is the proxy of the frame.\n  element_types = {}\n  for pcoll in flatten_pcolls:\n    if isinstance(pcoll, DeferredBase):\n      pcoll, element_type = deferred_df_to_pcollection(pcoll)\n      watch({'anonymous_pcollection_{}'.format(id(pcoll)): pcoll})\n    else:\n      element_type = pcoll.element_type\n\n    element_types[pcoll] = element_type","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/interactive/interactive_beam.py#L740-L776","documentation":"ib.show() flattens whatever you pass into a list of PCollections/deferred DataFrames. Each element must be a dict, an iterable of PCollections, a PCollection, or a DeferredBase (deferred DataFrame/Series). If an element is none of those, iter() raises TypeError and the code converts it to a ValueError telling you the given pcoll is not a dict, an iterable or a PCollection. It fails fast on wrong arguments before any pipeline work starts.","triggerScenarios":"ib.show(42) or ib.show(None) or ib.show(pipeline_result) where the argument has no __iter__ and is not a PCollection/DeferredBase; a list containing a non-PCollection element such as a PipelineResult, a literal value, or a raw pandas DataFrame (not a beam deferred DataFrame).","commonSituations":"Notebooks: passing the output of a non-interactive pipeline run into ib.show; lists mixing PTransform outputs with literal values; passing a pipeline variable name that was later reassigned to a scalar; passing numpy arrays or tensors.","solutions":["Pass actual PCollection objects produced by your beam pipeline, not derived handles or results.","If passing a container, make sure every element is a PCollection or a deferred DataFrame/Series.","Remove literal/constant values — wrap them in a PCollection first (beam.Create([...])) then show that.","Check for None: if the pcoll variable is None because a transform returned nothing upstream, fix the upstream branch first.","For pandas DataFrames, use apache_beam.dataframes to get a deferred beam DataFrame rather than passing the raw pandas object."],"exampleFix":"// before: ib.show(result)  # result is a PipelineResult | // after: pcoll = pipeline | 'Create' >> beam.Create([1, 2, 3]); ib.show(pcoll)","handlingStrategy":"validation","validationCode":"import apache_beam as beam; from apache_beam.dataframes import DeferredBase; def is_pcoll_like(x): return isinstance(x, (beam.pvalue.PCollection, DeferredBase)); assert all(is_pcoll_like(a) for a in show_args)","typeGuard":"def is_pcoll_like(x): import apache_beam as beam; from apache_beam.dataframes import DeferredBase; return isinstance(x, (beam.pvalue.PCollection, DeferredBase))","tryCatchPattern":"try: ib.show(*pcolls) | except ValueError as e: print('show() got a non-PCollection argument:', e); print([type(p) for p in pcolls])  # re-inspect inputs","preventionTips":["Only pass variables that came from pipeline | PTransform expressions.","Keep notebook variables dedicated; don't reuse pcoll names for scalars/results.","Check isinstance(x, beam.pvalue.PCollection) before batch-showing lists.","Don't pass pipeline.run() results or raw pandas DFs to show."],"tags":["python","apache-beam","interactive","value-error","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}