apache / apache/arrow

python - read multiple parquets that have different schema?

Open
#35,569 6 comments 0 reactions 0 assignees View on GitHub
Component: Parquet Component: Python Type: usage
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 18h
Merged PRs (30d)
91

Description

### Describe the usage question you have. Please include as many useful details as possible.

because of schema evolution some parquet files have more columns than others.
i try to read them all in one go (there are over 20000 small files under different partition folders) because i want to write out their data into a single big file

```
original_files = pq.ParquetDataset("bucket/folder", filesystem=s3_src, partitioning="hive")
```

i get error:
```
ValueError: Schema in partition[year=0, month=0, day=14, hour=9] bucket/folder/year=2023/month=02/day=22/hour=14/redact.snappy.parquet was different.
```

how can i achieve this in pyarrow?
pyspark has an automatic mergeSchema option - https://spark.apache.org/docs/latest/sql-data-sources-parquet.html#schema-merging

### Component(s)

Parquet, Python

Contributor guide

Open the contributing guide

Research direction

Start at the pyarrow ParquetDataset entry point described in the issue and reproduce the schema mismatch with partitioned files. Compare the requested behavior with Spark's mergeSchema documentation; done means a supported way to read the dataset with differing schemas and write one combined file, covering the reported partition layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, spark
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.