[Bug]: [Python] ReadFromAvro(as_rows=True) fails on Avro logical types (timestamp, date, decimal, uuid)
Les mainteneurs répondent en général sous 2 jours
Évaluation
Cette issue n'a pas encore été évaluée.
Description
What happened?
ReadFromAvro(..., as_rows=True) fails on any Avro field that has a logical type. BigQuery Avro exports hit this: every TIMESTAMP column is written as {"type": "long", "logicalType": "timestamp-micros"}.
This was reported in #31656 (timestamp-millis), which the stale bot closed. It still fails on master (38eed1e5da0) and 2.78.0, and it affects every logical type, not only timestamps:
| Avro logical type | Error with as_rows=True |
|---|---|
| timestamp-millis, timestamp-micros, date, time-millis, local-timestamp-millis | TypeError: an integer is required |
| uuid | AttributeError: 'UUID' object has no attribute 'encode' |
| decimal | TypeError: Expected bytes, got decimal.Decimal |
Reading the same file without as_rows works. Beam YAML's ReadFromAvro sets as_rows: True by default (standard_io.yaml), so a YAML pipeline can't read any Avro file with such a column.
Cause: avro_type_to_beam_type ignores logicalType and maps the field to its primitive (INT64, INT32, BYTES, STRING), but fastavro decodes logical types to Python objects (datetime, date, Decimal, UUID), so the RowCoder gets a value that doesn't match the schema.
Repro:
import datetime, tempfile, os, fastavro
import apache_beam as beam
schema = {"type": "record", "name": "T", "fields": [
{"name": "ts", "type": {"type": "long", "logicalType": "timestamp-micros"}}]}
path = os.path.join(tempfile.mkdtemp(), "t.avro")
with open(path, "wb") as f:
fastavro.writer(f, fastavro.parse_schema(schema),
[{"ts": datetime.datetime.now(datetime.timezone.utc)}])
with beam.Pipeline() as p:
p | beam.io.ReadFromAvro(path, as_rows=True) | beam.Map(print)
# TypeError: an integer is required [while running 'ReadFromAvro/Map(<lambda at avroio.py:676>)']
Proposed fix (I have it ready with a test): map logical types to the Beam types the Java SDK's AvroUtils uses, through the existing Python logical types: timestamp-millis/micros → Timestamp (micros_instant), date → datetime.date, decimal → decimal.Decimal, uuid → str. Logical types with no Beam equivalent in Python (time-, local-timestamp-) fall back to Any, as unions already do in this file.
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components
- Component: Python SDK
- Component: IO connector
Found, reproduced and drafted with Claude Code (Claude Opus 5.5).
- Langage dominant
- Java
- Étoiles
- 8.7k
- Forks
- 4.8k
- Merge moyen
- 3 j 16 h
- PR mergées (30 j)
- 445
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de apache/beam
-
awaiting triage java new feature P2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
[Bug]: [Python] BigTableEnrichmentHandler coerces None lookup keys to literal b'None' and formats blank key name on KeyErrorPeut-être pris @shikhabhadoria l’a pris il y a 6 jours. Ouverteio P2 python
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
apache/beam#41346 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 2 jours
-
Release notes links wrongPeut-être pris @schizophrenicmaniac l’a pris il y a 20 jours. Ouvertebug P3
Difficulté 1/5 Moins d'une heure Accessibilité débutants 67/100
apache/beam#41197 · 3 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
apache/beam#39624 · 2 réactions ·
Les mainteneurs répondent en général sous 2 jours
-
[Bug]: PubsubIO used in batch incorrect batch cutoff sizePeut-être pris @1fanwang l’a pris il y a 98 jours. Ouvertebug io P3 pinned pubsub
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/beam#28011 · 4 commentaires ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de apache/beam
Issues similaires
-
effort/l priority/p1 risk/high triage/core
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
iflytek/skillhub#1188 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
testng-team/testng#3675 ·
Les mainteneurs répondent en général sous 1 jour
-
Improve readability of build file paths in the Run/Debug configuration "Build file" dropdownOuvertedesign
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
OpenLiberty/liberty-tools-intellij#1869 ·
Les mainteneurs répondent en général sous 1 jour
-
`ovsx verify` fails for a version older than the 100 newest of an extensionPeut-être pris @trivikr l’a pris aujourd’hui. Ouvertecli
Difficulté 2/5 1-3 heures Accessibilité débutants 81/100
eclipse-openvsx/openvsx#2482 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
Les mainteneurs répondent en général sous 1 jour