Avro's isElementType() change breaks the reading of some parquet(1.8.1) files
- 主要言語
- Java
- スター
- 3.1k
- フォーク
- 1.6k
- 平均マージ
- 3日 12時間
- マージ済み PR(30日)
- 33
説明
When using the Avro schema below to write a parquet(1.8.1) file and then read back by using parquet 1.10.1 without passing any schema, the reading throws an exception "XXX is not a group" . Reading through parquet 1.8.1 is fine.
{
"name": "phones",
"type": [
"null",
{
"type": "array",
"items": {
"type": "record",
"name": "phones_items",
"fields": [
{ "name": "phone_number", "type": [ "null", "string" ], "default": null }
]
}
}
],
"default": null
}
The code to read is as below
val reader = AvroParquetReader._builder_[SomeRecordType](parquetPath).withConf(**new** Configuration).build()
reader.read()
PARQUET-651 changed the method isElementType() by relying on Avro's checkReaderWriterCompatibility() to check the compatibility. However, checkReaderWriterCompatibility() consider the ParquetSchema and the AvroSchema(converted from File schema) as not compatible(the name in avro schema is ‘phones_items’, but the name is ‘array’ in Parquet schema, hence not compatible) . Hence return false and caused the “phone_number” field in the above schema to be considered as group type which is not true. Then the exception throws as .asGroupType().
I didn’t try writing via parquet 1.10.1 would reproduce the same problem or not. But it could because the translation of Avro schema to Parquet schema is not changed(didn’t verify yet).
I hesitate to revert PARQUET-651 because it solved several problems. I would like to hear the community's thoughts on it.
**Reporter**: [Xinli Shang](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=shangx@uber.com) / @shangxinli
**Assignee**: [Xinli Shang](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=shangx@uber.com) / @shangxinli
#### Related issues:
- [Parquet-avro fails to decode array of record with a single field name "element" correctly](https://github.com/apache/parquet-java/issues/1976) (causes)
**Note**: *This issue was originally created as [PARQUET-1681](https://issues.apache.org/jira/browse/PARQUET-1681). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
提供された Avro スキーマ、parquet 1.8.1 の出力、parquet 1.10.1、および AvroParquetReader を使って失敗を再現し、その後、PARQUET-651 で変更された isElementType() のロジックと互換性チェックを調査します。この配列形式のレコードスキーマを持つ古いファイルを “not a group” 例外なしで読み取れるようになり、リポジトリに回帰テストがある場合はその動作が回帰テストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- data-engineering
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100