[Bug]: [Python] ReadFromParquet(as_rows=True) fails on timestamp and date columns ("Unrecognized arrow type")

オープン
#41,762 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@Viranshul-P がすでに取り組んでいます。

2026年11月30日 から。

  • #41763 @Viranshul-P による — オープン

評価

この issue はまだ評価されていません。

説明

io P2 python
What happened?

ReadFromParquet(..., as_rows=True) fails at pipeline construction on any Parquet file that has a timestamp or date column:

ValueError: Unrecognized arrow type: TimestampType(timestamp[us])
ValueError: Unrecognized arrow type: DataType(date32[day])

Timestamp and date columns are in most real Parquet files. Every file written by pandas DataFrame.to_parquet with a datetime column has one (timestamp[ns]), so as_rows=True can't read them at all. The write side has the same gap: WriteToParquet on a schema'd PCollection with a Timestamp or datetime.date field raises NotImplementedError: Beam logical types are not currently supported in arrow_type_compatibility (the TODO for #23817).

Reproducer (master 8d4c010c727, also 2.78.0):

import datetime
import pyarrow as pa, pyarrow.parquet as pq
import apache_beam as beam

pq.write_table(pa.table({
    't': pa.array([datetime.datetime(2024, 3, 1, 10)], pa.timestamp('us')),
    'd': pa.array([datetime.date(2024, 3, 1)], pa.date32()),
}), 'ts.parquet')

with beam.Pipeline() as p:
  p | beam.io.ReadFromParquet('ts.parquet', as_rows=True) | beam.Map(print)
# ValueError: Unrecognized arrow type: TimestampType(timestamp[us])

Cause: arrow_type_compatibility._beam_fieldtype_from_arrow_type only knows the primitive types, lists, maps and structs. _arrow_type_from_beam_fieldtype raises for every logical type.

Proposed fix, following Java's ArrowConversion, which reads ms/us timestamps as DATETIME:

  • Arrow timestamp (any unit, with or without a time zone) maps to Beam Timestamp (MicrosInstant). A timestamp with no time zone is taken as UTC. Nanosecond values are cast safely: whole microseconds convert, anything finer raises instead of being dropped silently.
  • Arrow date32/date64 maps to Beam Date (datetime.date).
  • For writing, Timestamp (MicrosInstant/MillisInstant) maps to timestamp('us', tz='UTC') and Date to date32.

Decimal, time and the other logical types are left as they are. Arrow decimals have a fixed precision and scale that Beam's Decimal doesn't carry, which is the same reason Java skips them.

Issue Priority

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

Issue Components
  • Component: Python SDK
  • Component: IO connector
主要言語
Java
スター
8.7k
フォーク
4.8k
平均マージ
3日 16時間
マージ済み PR(30日)
445

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/beam のほかの issue

apache/beam の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。