Skip to content

feat(avro,parquet): read the full file schema when no projection is set - #1055

Open
ump45nose wants to merge 1 commit into
apache:mainfrom
ump45nose:feat/reader-default-projection
Open

ump45nose wants to merge 1 commit into
apache:mainfrom
ump45nose:feat/reader-default-projection

Conversation

@ump45nose

Copy link
Copy Markdown

Closes #514.

What

ReaderOptions::projection is no longer required for the Avro and Parquet readers. When it is not set, the reader derives the read schema from the file schema and reads all fields.

  • Avro: add FromAvroSchema(), which converts an Avro schema written by Iceberg (with field-id, element-id, key-id/value-id and the map logical type for non-string keys) back into an Iceberg Schema. Sanitized field names are restored from iceberg-field-name.
  • Parquet: add FromParquetSchema(), which builds the schema from the SchemaManifest. Since it runs after ApplyNameMapping, files without field IDs work when a name mapping is provided. Fields that still have no ID (or lists/maps whose element/key/value has no ID) are skipped, because they can't be read by ID anyway. A file with neither field IDs nor a name mapping still fails as before.
  • ParquetReader now builds the SchemaManifest once in Open() and uses it for both the schema derivation and the projection.

Tests

  • FromAvroSchemaTest: primitive types, nested struct/list/map (string and non-string keys), sanitized names, missing field ID and unsupported types.
  • ParquetSchemaConversionTest: round trip through ToParquetSchema for list and large_list, and conversion with a partial name mapping.
  • Reader tests for Avro and Parquet without a projection, Parquet with a name mapping, and Parquet without field IDs or name mapping.

avro_test, parquet_test, schema_test, data_test, scan_test, manifest_test, table_test and arrow_test pass locally.

This PR was written with the help of an AI coding assistant. I reviewed the changes and tests myself.

When ReaderOptions::projection is not set, the Avro and Parquet readers
now derive the read schema from the file schema instead of failing.

Closes apache#514

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow file reader to read without setting ReaderOptions::projection

1 participant