Make convert-csv work with the input filename which starts with a period or an numeric
- 主要言語
- Java
- スター
- 3.1k
- フォーク
- 1.6k
- 平均マージ
- 3日 12時間
- マージ済み PR(30日)
- 33
説明
I ran parquet-cli's `convert-csv` with an input file which name starts with a numeric character without `--schema` option and got the following error:
```Java
$ java -cp 'target/*:target/dependency/*' org.apache.parquet.cli.Main convert-csv 0sample.csv -o sample.parquet
Unknown error
shaded.parquet.org.apache.avro.SchemaParseException: Illegal initial character: 0sample
at shaded.parquet.org.apache.avro.Schema.validateName(Schema.java:1498)
at shaded.parquet.org.apache.avro.Schema.access$200(Schema.java:86)
at shaded.parquet.org.apache.avro.Schema$Name.(Schema.java:645)
at shaded.parquet.org.apache.avro.Schema.createRecord(Schema.java:182)
at shaded.parquet.org.apache.avro.SchemaBuilder$RecordBuilder.fields(SchemaBuilder.java:1805)
at org.apache.parquet.cli.csv.AvroCSV.inferSchemaInternal(AvroCSV.java:158)
at org.apache.parquet.cli.csv.AvroCSV.inferNullableSchema(AvroCSV.java:78)
at org.apache.parquet.cli.commands.ConvertCSVCommand.run(ConvertCSVCommand.java:160)
at org.apache.parquet.cli.Main.run(Main.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.parquet.cli.Main.main(Main.java:177)
```
This is because that `convert-csv` uses the input file name as the name for the output schema, while Avro requires its schema name to match the regex pattern `[A-Za-z_][A-Za-z0-9_]*`.
So users have to change the input file name or use the `--schema` option explicitly, but it's not so obvious from the error message.
It'd be nice if the message were improved, or the schema name were automatically replaced with valid characters to avoid this problem.
**Reporter**: [Kengo Seki](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=sekikn) / @sekikn
**Assignee**: [Kengo Seki](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=sekikn) / @sekikn
#### PRs and other links:
- [GitHub Pull Request #652](https://github.com/apache/parquet-mr/pull/652)
**Note**: *This issue was originally created as [PARQUET-1598](https://issues.apache.org/jira/browse/PARQUET-1598). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
org.apache.parquet.cli.csv.AvroCSV.inferSchemaInternal から始め、スタックトレースと ConvertCSVCommand.java をエントリーポイントとして使用します。意図された解決策が、より明確なエラーなのか、スキーマ名の自動処理なのかを判断するために、pull request #652 を確認し、そのうえで、convert-csv が仕様どおりにピリオドまたは数字で始まるファイル名を処理することを示すテストカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- cli, data
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100