[
https://issues.apache.org/jira/browse/BEAM-8344?focusedWorklogId=325132&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-325132
]
ASF GitHub Bot logged work on BEAM-8344:
----------------------------------------
Author: ASF GitHub Bot
Created on: 08/Oct/19 15:40
Start Date: 08/Oct/19 15:40
Worklog Time Spent: 10m
Work Description: bmv126 commented on pull request #9721: [BEAM-8344] Add
inferSchema support in ParquetIO and refactor ParquetTableProvider
URL: https://github.com/apache/beam/pull/9721#discussion_r332587458
##########
File path:
sdks/java/io/parquet/src/main/java/org/apache/beam/sdk/io/parquet/ParquetIO.java
##########
@@ -122,15 +122,34 @@
* pattern).
*/
public static Read read(Schema schema) {
- return new AutoValue_ParquetIO_Read.Builder().setSchema(schema).build();
+ return new AutoValue_ParquetIO_Read.Builder()
+ .setSchema(schema)
+ .setInferBeamSchema(false)
+ .build();
}
/**
* Like {@link #read(Schema)}, but reads each file in a {@link PCollection}
of {@link
* org.apache.beam.sdk.io.FileIO.ReadableFile}, which allows more flexible
usage.
*/
public static ReadFiles readFiles(Schema schema) {
- return new
AutoValue_ParquetIO_ReadFiles.Builder().setSchema(schema).build();
+ return new AutoValue_ParquetIO_ReadFiles.Builder()
+ .setSchema(schema)
+ .setInferBeamSchema(false)
+ .build();
+ }
+
+ private static <T> PCollection<T> setBeamSchema(
+ PCollection<T> pc, Class<T> clazz, @Nullable Schema schema) {
+ org.apache.beam.sdk.schemas.Schema beamSchema =
+ org.apache.beam.sdk.schemas.utils.AvroUtils.getSchema(clazz, schema);
+ if (beamSchema != null) {
Review comment:
Thanks for reviewing the code.
The idea here was to align it the same way as AvroIO
(https://github.com/apache/beam/blob/ad5d3836a47fe2cbd552fe3908e15ffc7f777f11/sdks/java/core/src/main/java/org/apache/beam/sdk/io/AvroIO.java#L339)
Currently AvroUtils.getSchema() returns null if it is anything other than
GenericRecord type.
Currently In parquetIO we are handling only generic record so this method
will always return schema.
I think with your suggestion of making infer schema as non optional and as
we handle only GenericRecord in ParquetIO, I will modify the code to set the
beamSchema always without the boolean flag as we do in AvroIO.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 325132)
Time Spent: 0.5h (was: 20m)
> Add infer schema support in ParquetIO and refactor ParquetTableProvider
> -----------------------------------------------------------------------
>
> Key: BEAM-8344
> URL: https://issues.apache.org/jira/browse/BEAM-8344
> Project: Beam
> Issue Type: Improvement
> Components: dsl-sql, io-java-parquet
> Reporter: Vishwas
> Assignee: Vishwas
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Add support for inferring Beam Schema in ParquetIO.
> Refactor ParquetTable code to use Convert.rows().
> Remove unnecessary java class GenericRecordReadConverter.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)