{"record":{"id":"1a3678e24efe5fc0","repo":"apache/beam","slug":"non-deferred","errorCode":null,"errorMessage":"non-deferred","messagePattern":"non-deferred","errorType":"exception","errorClass":"WontImplementError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/io.py","lineNumber":265,"sourceCode":"  else:\n    return df\n\n\nclass _ReadFromPandas(beam.PTransform):\n  def __init__(\n      self,\n      reader,\n      path,\n      args,\n      kwargs,\n      binary=True,\n      incremental=False,\n      splitter=False,\n      filename_column=None):\n    if 'compression' in kwargs:\n      raise NotImplementedError('compression')\n    if not isinstance(path, str):\n      raise frame_base.WontImplementError('non-deferred')\n    self.reader = reader\n    self.path = path\n    self.args = args\n    self.kwargs = kwargs\n    self.binary = binary\n    self.incremental = incremental\n    self.splitter = splitter\n    self.filename_column = filename_column\n\n  def expand(self, root):\n    paths_pcoll = root | beam.Create([self.path])\n    match = io.filesystems.FileSystems.match([self.path], limits=[1])[0]\n    if not match.metadata_list:\n      # TODO(https://github.com/apache/beam/issues/20858): This should be\n      # allowed for streaming pipelines if user provides an explicit schema.\n      raise FileNotFoundError(f\"Found no files that match {self.path!r}\")\n    first_path = match.metadata_list[0].path\n    with io.filesystems.FileSystems.open(first_path) as handle:","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/io.py#L247-L283","documentation":"_ReadFromPandas (used by read_csv/read_json/etc. in apache_beam.dataframe.io) requires path to be a str so the source can be deferred as a file reference. If path is not a string (e.g. a file-like object, bytes, or pathlib.Path), the constructor raises WontImplementError('non-deferred') because Beam cannot represent a non-string source in its deferred dataframe pipeline.","triggerScenarios":"Calling beam.dataframe.io.read_csv(path) / read_json / read_parquet with a file-like object, BytesIO, bytes, pathlib.Path, or URL object instead of a str path; also if 'compression' is passed a NotImplementedError is raised in the same __init__.","commonSituations":"Developers used to pandas' acceptance of file handles pass an open file object; using pathlib.Path results from os.path operations; downloading logic hands in a stream instead of saving to a file path first.","solutions":["Pass a plain str path (or str-compatible path) to the read_* function.","Convert pathlib.Path with str(path) before calling.","Materialize any file-like object to disk first, then pass its filename string.","Read the data with plain pandas, then wrap it: beam.dataframe.convert.to_pcollection(pd_df)."],"exampleFix":"// before\nwith open('data.csv') as f:\n  df = io.read_csv(f)\n// after\ndf = io.read_csv('data.csv')","handlingStrategy":"validation","validationCode":"if not isinstance(path, str):\n    raise TypeError(f'expected str path, got {type(path).__name__}')","typeGuard":"def is_str_path(path):\n    return isinstance(path, str)","tryCatchPattern":"try:\n    df = beam_df.io.read_csv(path)\nexcept frame_base.WontImplementError:\n    df = beam_df.io.read_csv(str(path))","preventionTips":["Always pass str paths to beam.dataframe.io.read_*","Convert pathlib.Path with str()","Never pass open file handles to Beam deferred readers"],"tags":["apache-beam","pandas","io","deferred"],"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-20T03:17:13.778Z"}