This is an automated email from the ASF dual-hosted git repository.
lesun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-gobblin.git
The following commit(s) were added to refs/heads/master by this push:
new cdd33cd [GOBBLIN-1270] Fix reference to
determineSchemaOrReturnErrorSchema which is backward incompatible
cdd33cd is described below
commit cdd33cd2e60f4617437c20a1fba0c119120f63e7
Author: Lei Sun <[email protected]>
AuthorDate: Tue Sep 22 13:09:36 2020 -0700
[GOBBLIN-1270] Fix reference to determineSchemaOrReturnErrorSchema which is
backward incompatible
Closes #3110 from autumnust/fixOrcWriterAvroUtils
---
.../org/apache/gobblin/writer/GobblinOrcWriter.java | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git
a/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/GobblinOrcWriter.java
b/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/GobblinOrcWriter.java
index 0e07c0e..96f0c8c 100644
---
a/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/GobblinOrcWriter.java
+++
b/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/GobblinOrcWriter.java
@@ -48,6 +48,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.gobblin.configuration.State;
import org.apache.gobblin.state.ConstructState;
+import static org.apache.gobblin.writer.AvroOrcSchemaConverter.getOrcSchema;
+
/**
* A wrapper for ORC-core writer without dependency on Hive SerDe library.
@@ -82,7 +84,7 @@ public class GobblinOrcWriter extends
FsDataWriter<GenericRecord> {
// Create value-writer which is essentially a record-by-record-converter
with buffering in batch.
this.avroSchema = builder.getSchema();
- TypeDescription typeDescription =
AvroOrcSchemaConverter.getOrcSchema(this.avroSchema);
+ TypeDescription typeDescription = getOrcSchema(this.avroSchema);
this.valueWriter = new GenericRecordToOrcValueWriter(typeDescription,
this.avroSchema, properties);
this.batchSize = properties.getPropAsInt(ORC_WRITER_BATCH_SIZE,
DEFAULT_ORC_WRITER_BATCH_SIZE);
this.rowBatch = typeDescription.createRowBatch(this.batchSize);
@@ -118,8 +120,8 @@ public class GobblinOrcWriter extends
FsDataWriter<GenericRecord> {
*/
ConstructState state = new ConstructState(super.getFinalState());
try {
- state.addOverwriteProperties(new
State(getOrcSchemaAttrs(this.avroSchema.toString())));
- } catch (SerDeException | IOException e) {
+ state.addOverwriteProperties(new
State(getPropsWithOrcSchema(this.avroSchema)));
+ } catch (SerDeException e) {
throw new RuntimeException("Failure to set schema metadata in finalState
properly which "
+ "could possible lead to incorrect data registration", e);
}
@@ -250,13 +252,10 @@ public class GobblinOrcWriter extends
FsDataWriter<GenericRecord> {
return this.writerAttemptIdOptional.isPresent() && this.getClass() ==
GobblinOrcWriter.class;
}
- public static Properties getOrcSchemaAttrs(String avroSchemaString)
- throws SerDeException, IOException {
+ public static Properties getPropsWithOrcSchema(Schema avroSchema) throws
SerDeException {
Properties properties = new Properties();
-
properties.setProperty(AvroSerdeUtils.AvroTableProperties.SCHEMA_LITERAL.getPropName(),
avroSchemaString);
-
- AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(
- AvroSerdeUtils.determineSchemaOrThrowException(properties));
+
properties.setProperty(AvroSerdeUtils.AvroTableProperties.SCHEMA_LITERAL.getPropName(),
avroSchema.toString());
+ AvroObjectInspectorGenerator aoig = new
AvroObjectInspectorGenerator(avroSchema);
properties.setProperty("columns", StringUtils.join(aoig.getColumnNames(),
","));
properties.setProperty("columns.types",
StringUtils.join(aoig.getColumnTypes(), ","));