[Bug]: [Python] DirectRunner Prism fallback to BundleBasedDirectRunner fails with NotImplementedError on batched DoFns (WriteToParquet)

未关闭
#41,078 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python

调研方向

Start in sdks/python/apache_beam/runners/direct/direct_runner.py, especially the SwitchingDirectRunner fallback around lines 141–146 and 204–230; compare its behavior with FnApiRunner for process_batch transforms. Reproduce with the provided WriteToParquet pipeline, then check relevant direct runner tests. Done means the fallback runs batched DoFns successfully without breaking the existing runner paths.

由索引模型根据 Issue 内容生成。

描述

awaiting triage bug P2 python
What happened?

When running a Python or Beam YAML pipeline with the default DirectRunner (SwitchingDirectRunner), if PrismRunner is bypassed (for example when the pipeline contains an external cross-language transform per direct_runner.py:141) or cannot start (offline environment / restricted container where the Prism binary cannot be downloaded or executed), SwitchingDirectRunner falls back to BundleBasedDirectRunner.

If the pipeline includes WriteToParquet (or any transform using DoFn.process_batch), execution then fails with NotImplementedError, even though the in-process FnApiRunner executes the exact same pipeline cleanly.

Minimal reproducer (forcing the non-Prism fallback path):

import tempfile, apache_beam as beam, pyarrow as pa

schema = pa.schema([('id', pa.int64()), ('name', pa.string())])
with tempfile.TemporaryDirectory() as d:
  with beam.Pipeline(runner='BundleBasedDirectRunner') as p:
    (p
     | beam.Create([{'id': 1, 'name': 'Ada'}])
     | beam.io.WriteToParquet(f'{d}/out', schema=schema))

Cause

In sdks/python/apache_beam/runners/direct/direct_runner.py (lines 141–146 and 204–230), SwitchingDirectRunner unconditionally falls back to BundleBasedDirectRunner(), which does not implement process_batch for batched PyArrow DoFns (FnApiRunner does). Checking for process_batch transforms (or routing batch pipelines without TestStream/unbounded state to FnApiRunner when Prism is unavailable) avoids the failure.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components
  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam YAML
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Infrastructure
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Prism Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner
主要语言
Java
星标
8.7k
派生
4.8k
平均合并
2 天 12 小时
30 天内合并 PR
371

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/beam 的其他 Issue

查看 apache/beam 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。