You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems to be related to the partition_cols - if you comment this line from write_to_dataset the error is suppressed. I cannot find an example of writing metadata for a partitioned dataset?
I have the same problem, for datasets in which the schema of the parquet files are identical expect the ordering of the columns.
That means for me, currently, I have to rewrite all parquet files with one unique schema (same column ordering). I wonder, if it is necessary, that the ordering of the columns is identical.
@legout Can you show the error you meet and the code you're using when using dataset writer? Seems that when writing same file the schema should be same, but I don't fully understand how you meet this when using dataset api.
Sorry for my confusing comment. Here are some more details.
The parquet files of the dataset are exports from an oracle database written with another software(knime). Unfortunately, this leads to the parquet files having different column ordering, although the data types of the columns are identical.
This still reproduces on main. write_to_dataset() with partition_cols doesn't write the partition columns into the files, so the collected metadata doesn't match the table.schema passed to write_metadata().
Workaround is to drop the partition columns from the schema when writing _metadata:
The docs only show the unpartitioned case; #28950 was meant to fix that but was closed without a docs update, so let's use this issue to add a partitioned example.
Opened a PR for this: #55726 — it adds the partitioned example to the "Writing _metadata and _common_metadata files" section (as suggested in the thread), with the partition columns removed from the schema for the _metadata file. The example was verified by running it with pyarrow 24.0.0.
Activity
david-waterworth commentedon May 10, 2023
This seems to be related to the
partition_cols- if you comment this line fromwrite_to_datasetthe error is suppressed. I cannot find an example of writing metadata for a partitioned dataset?legout commentedon Aug 22, 2023
I have the same problem, for datasets in which the schema of the parquet files are identical expect the ordering of the columns.
That means for me, currently, I have to rewrite all parquet files with one unique schema (same column ordering). I wonder, if it is necessary, that the ordering of the columns is identical.
mapleFU commentedon Aug 22, 2023
@legout Can you show the error you meet and the code you're using when using dataset writer? Seems that when writing same file the schema should be same, but I don't fully understand how you meet this when using dataset api.
legout commentedon Aug 22, 2023
Sorry for my confusing comment. Here are some more details.
The parquet files of the dataset are exports from an oracle database written with another software(knime). Unfortunately, this leads to the parquet files having different column ordering, although the data types of the columns are identical.
This means, I am able to read the dataset (parquet files) using pyarrow.dataset or pyarrow.read_table.
However, when trying to create metadata and common metadata files according to https://arrow.apache.org/docs/python/parquet.html#writing-metadata-and-common-medata-files, I get the this error
RuntimeError: AppendRowGroups requires equal schemas.
I do understand, that data types have to be identical, but I wonder why the column ordering is important here.
I am currently on my mobile. I'll provide some sample code later.
legout commentedon Aug 22, 2023
Create toy dataset with parquet files having identical column types, but different column ordering.
Collect metadata of the individual files and create the (global) metadata file.
mapleFU commentedon Aug 23, 2023
Oh I got this. This is not allowed. Though it looks like it should be allowed.
Because Parquet schema is at "FileMetadata" ( see https://github.com/apache/parquet-format/blob/master/src/main/thrift/parquet.thrift#L1024 ), so different row-group should have same schema.
legout commentedon Aug 23, 2023
This means, there is no other solution than rewriting the data with a unique column ordering?
KernelA commentedon Mar 14, 2024
I have a similar issue.
pyarrow 14.0.2
All partitions have equal schemas. Example are taken from https://arrow.apache.org/docs/14.0/python/parquet.html#writing-metadata-and-common-metadata-files
KernelA commentedon Mar 24, 2024
When all fields are nullable in the schema this error does not occur. I think it relates with #31957
[-]PyArrow: RuntimeError: AppendRowGroups requires equal schemas when writing _metadata file[/-][+][Python] PyArrow: RuntimeError: AppendRowGroups requires equal schemas when writing _metadata file[/+][-][Python] PyArrow: RuntimeError: AppendRowGroups requires equal schemas when writing _metadata file[/-][+][Documentation][Python] PyArrow: RuntimeError: AppendRowGroups requires equal schemas when writing _metadata file[/+]thisisnic commentedon Nov 17, 2026
This still reproduces on main.
write_to_dataset()withpartition_colsdoesn't write the partition columns into the files, so the collected metadata doesn't match thetable.schemapassed towrite_metadata().Workaround is to drop the partition columns from the schema when writing
_metadata:The docs only show the unpartitioned case; #28950 was meant to fix that but was closed without a docs update, so let's use this issue to add a partitioned example.
sameer727 commentedon Nov 22, 2026
Opened a PR for this: #55726 — it adds the partitioned example to the "Writing
_metadataand_common_metadatafiles" section (as suggested in the thread), with the partition columns removed from the schema for the_metadatafile. The example was verified by running it with pyarrow 24.0.0.