{"record":{"id":"c40f4fdfed4004d4","repo":"apache/beam","slug":"the-given-pcoll-pcoll-container-is-not-a-dict-an-iterable-or","errorCode":null,"errorMessage":"The given pcoll {pcoll_container} 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":1055,"sourceCode":"    options: (optional) any additional pipeline options to use to compute the\n      results.\n    force_compute: (optional) if True, forces recomputation rather than using\n      cached PCollections.\n\n  Returns:\n    An AsyncComputationResult object if blocking is False, otherwise None.\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            f'The given pcoll {pcoll_container} is not a dict, an iterable or '\n            'a PCollection.')\n\n  pcolls_set = set()\n  for pcoll in flatten_pcolls:\n    if isinstance(pcoll, DeferredBase):\n      pcoll, _ = deferred_df_to_pcollection(pcoll)\n      watch({f'anonymous_pcollection_{id(pcoll)}': pcoll})\n    assert isinstance(\n        pcoll, beam.pvalue.PCollection\n    ), f'{pcoll} is not an apache_beam.pvalue.PCollection.'\n    pcolls_set.add(pcoll)\n\n  if not pcolls_set:\n    _LOGGER.info('No PCollections to compute.')\n    return None\n\n  pcoll_pipeline = next(iter(pcolls_set)).pipeline","sourceCodeStart":1037,"sourceCodeEnd":1073,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/interactive/interactive_beam.py#L1037-L1073","documentation":"ib.compute() shares the input-normalization logic of ib.show(): each argument must be a dict, an iterable of PCollections, a PCollection, or a DeferredBase. When iter(pcoll_container) raises TypeError, the code re-raises ValueError with this message. compute() records PCollections for later materialization, so it must receive real (or deferred) PCollections up front.","triggerScenarios":"ib.compute(42) or ib.compute(None); ib.compute({'k': pcoll, 'bad': 5}) where one dict value is a literal; ib.compute(pipeline_result); passing a generator of non-PCollection values; any attribute that isn't a PCollection due to variable shadowing.","commonSituations":"Notebooks migrating from ib.show to ib.compute for explicit recording control; passing the wrong dict level (a dict of dicts); variables overwritten by later non-beam assignments in a long notebook session; passing tf.Tensor or numpy arrays.","solutions":["Pass PCollection objects (or dicts/lists of them) created on the interactive pipeline.","Inspect every element with isinstance(x, apache_beam.pvalue.PCollection) before calling compute.","Replace literal values with beam.Create sources on the same pipeline.","Fix any variable shadowing: re-run the cell defining the pcoll if a later cell reassigned the name.","For deferred DataFrames/Series ensure they come from ib.transform/beam dataframe API, not raw pandas objects."],"exampleFix":"// before: ib.compute({'evens': evens, 'count': 5})  # 5 is not a PCollection | // after: five = pipeline | 'Five' >> beam.Create([5]); ib.compute({'evens': evens, 'count': five})","handlingStrategy":"validation","validationCode":"import apache_beam as beam; from apache_beam.dataframes import DeferredBase; def flatten_and_check(containers): return [c for c in containers if isinstance(c, (beam.pvalue.PCollection, DeferredBase)) or (isinstance(c, (dict, list, tuple)) and flatten_and_check(list(c.values() if isinstance(c, dict) else c)))] ; assert all ok before ib.compute","typeGuard":"def is_compute_input(x): import apache_beam as beam; from apache_beam.dataframes import DeferredBase; return isinstance(x, (beam.pvalue.PCollection, DeferredBase, dict, list, tuple))","tryCatchPattern":"try: recording = ib.compute(*containers) | except ValueError as e: print('compute() invalid input:', e); print([(type(c), c) for c in containers])","preventionTips":["Pass only PCollections (or containers of them) to compute.","Guard against variable shadowing in long notebook sessions.","Replace literals with beam.Create sources.","Validate dict values are PCollections before passing dicts."],"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"}