diff --git a/parquet-avro/pom.xml b/parquet-avro/pom.xml index 0d511a3a46..e182b4810b 100644 --- a/parquet-avro/pom.xml +++ b/parquet-avro/pom.xml @@ -32,10 +32,6 @@ Apache Parquet Avro (Incubating) https://parquet.incubator.apache.org - - 1.7.6 - - com.twitter diff --git a/parquet-avro/src/main/java/parquet/avro/projection/AvroCustomField.java b/parquet-avro/src/main/java/parquet/avro/projection/AvroCustomField.java new file mode 100644 index 0000000000..3267f4abe8 --- /dev/null +++ b/parquet-avro/src/main/java/parquet/avro/projection/AvroCustomField.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package parquet.avro.projection; + +import org.apache.avro.Schema; + +//remember the original field position +public class AvroCustomField extends Schema.Field { + Schema schema; + Schema.Field field; + + public AvroCustomField(Schema schema, Schema.Field field) { + super(field.name(), schema, field.doc(), field.defaultValue()); + this.schema = schema; + this.field = field; + } + + public int pos() { + return field.pos(); + } + +} \ No newline at end of file diff --git a/parquet-avro/src/main/java/parquet/avro/projection/AvroProjection.java b/parquet-avro/src/main/java/parquet/avro/projection/AvroProjection.java new file mode 100644 index 0000000000..7e2230176b --- /dev/null +++ b/parquet-avro/src/main/java/parquet/avro/projection/AvroProjection.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package parquet.avro.projection; + +import org.apache.avro.Schema; +import org.apache.avro.Schema.Type.*; + +import java.util.*; + +// originally based on https://raw.githubusercontent.com/epishkin/scalding/parquet_avro/scalding-parquet/src/main/scala/com/twitter/scalding/parquet/avro/Projection.scala + +/** + * Helps create projections for Avro schemas. + */ +public class AvroProjection { + /** + * Create a projection for {{schema}} that includes {{fields}}. + */ + public static Schema createProjection(Schema schema, String[] fields) { + return createProjection(schema, fields, null); + } + + + private static Schema createProjection(Schema schema, String[] fields, String parentFieldName) { + switch(schema.getType()) { + case RECORD: + return createRecordProjection(schema, fields, parentFieldName); + case UNION: + return createUnionProjection(schema, fields, parentFieldName); + case ARRAY: + return createArrayProjection(schema, fields, parentFieldName); + default: + String fieldInfo = schema.getType().toString(); + if (parentFieldName != null) { + fieldInfo = parentFieldName + fieldInfo; + } + String children = convertFieldNamesToString(fields); + throw new RuntimeException("Projection doesn't support schema type " + fieldInfo + " with fields: " + children); + } + } + + private static Schema createRecordProjection(Schema schema, String[] fields, String parentFieldName) { + // Take the head of any nested properties, "parent.fieldX" => "parent" + List nestedFields = new LinkedList(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].contains(".")) { + nestedFields.add(fields[i].split("\\.")[0]); + } + } + List directFields = new LinkedList(); + Collections.copy(directFields, nestedFields); + directFields.addAll(Arrays.asList(fields)); + + List schemaFields = schema.getFields(); + validateRequestedFields(schema, schemaFields, directFields); + + List projectedFields = new LinkedList(); + + for (Schema.Field field : schemaFields) { + if (directFields.contains(field.name())) { + Schema thisSchema; + // Create projection for the nested field + if (nestedFields.contains(field.name())) { + String prefix = field.name() + "."; + // Find the nested fields and remove the prefix + List children = new LinkedList(); + for (String requestedField : fields) { + if (requestedField.startsWith(prefix)) { + children.add(requestedField.substring(0, prefix.length())); + } + } + thisSchema = createProjection(field.schema(), (String[])children.toArray(), fullFieldName(parentFieldName, field.name())); + } else { + thisSchema = field.schema(); + } + + projectedFields.add(copyField(thisSchema, field)); + } + } + + Schema projection = Schema.createRecord(schema.getName(), schema.getDoc(), schema.getNamespace(), false); + projection.setFields(projectedFields); + return projection; + } + + private static Schema createUnionProjection(Schema schema, String[] fields, String parentFieldName) { + List projectedSchemas = new LinkedList(); + for (Schema nestedSchema : schema.getTypes()) { + if (nestedSchema.getType() == Schema.Type.NULL) { + projectedSchemas.add(nestedSchema); + } else { + projectedSchemas.add(createProjection(nestedSchema, fields, parentFieldName)); + } + } + return Schema.createUnion(projectedSchemas); + } + + private static Schema createArrayProjection(Schema schema, String[] fields, String parentFieldName) { + return Schema.createArray( + createProjection(schema.getElementType(), fields, parentFieldName)); + } + + private static void validateRequestedFields(Schema schema, List schemaFields, List fieldNames) throws RuntimeException { + Set schemaFieldNames = new HashSet(); + for (Schema.Field field: schemaFields) { + schemaFieldNames.add(field.name()); + } + for (String field: fieldNames) { + if (!field.contains("\\.") && !schemaFieldNames.contains(field)) { + String full_name = schema.getFullName(); + final String supported_fields = Arrays.toString(schemaFieldNames.toArray()); + throw new RuntimeException( + "Field " + field + " not found in schema " + full_name + ". " + + "Supported fields are: " + supported_fields + ); + } + } + } + + private static Schema.Field copyField(Schema schema, Schema.Field field) { + return (new AvroCustomField(schema, field)); + } + + private static String fullFieldName(String parentFieldName, String fieldName) { + if (parentFieldName == null) { + return null; + } else { + return (parentFieldName + "." + fieldName); + } + } + + private static String convertFieldNamesToString(String[] fields) { + StringBuilder sb = new StringBuilder(); + for (String field : fields) { + if (sb.length() > 0) sb.append(", "); + sb.append(field); + } + return sb.toString(); + } + +} diff --git a/parquet-cascading-avro/pom.xml b/parquet-cascading-avro/pom.xml new file mode 100644 index 0000000000..2bf3ed8abb --- /dev/null +++ b/parquet-cascading-avro/pom.xml @@ -0,0 +1,129 @@ + + + + com.twitter + parquet + ../pom.xml + 1.6.0rc8-SNAPSHOT + + + 4.0.0 + + parquet-cascading-avro + jar + + Apache Parquet Cascading Avro (Incubating) + https://parquet.incubator.apache.org + + + + conjars.org + http://conjars.org/repo + + + + + + com.twitter + parquet-column + ${project.version} + + + com.twitter + parquet-hadoop + ${project.version} + + + com.twitter + parquet-avro + ${project.version} + + + org.apache.hadoop + hadoop-client + ${hadoop.version} + provided + + + log4j + log4j + ${log4j.version} + provided + + + com.twitter + parquet-column + ${project.version} + test-jar + test + + + com.twitter + parquet-cascading + ${project.version} + + + com.twitter + parquet-thrift + + + + + org.mockito + mockito-all + 1.9.5 + test + + + cascading + cascading-hadoop + ${cascading.version} + provided + + + + + + + maven-enforcer-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-test-sources + + idl-protocol + + + ${project.basedir}/src/test/avro/ + + + + + + + diff --git a/parquet-cascading-avro/src/main/java/parquet/cascading/ParquetAvroScheme.java b/parquet-cascading-avro/src/main/java/parquet/cascading/ParquetAvroScheme.java new file mode 100644 index 0000000000..80dfa97484 --- /dev/null +++ b/parquet-cascading-avro/src/main/java/parquet/cascading/ParquetAvroScheme.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package parquet.cascading; + +import org.apache.avro.generic.IndexedRecord; +import org.apache.hadoop.mapred.JobConf; +import org.apache.hadoop.mapred.OutputCollector; +import org.apache.hadoop.mapred.RecordReader; + +import cascading.flow.FlowProcess; +import cascading.tap.Tap; +import parquet.avro.AvroReadSupport; +import parquet.avro.AvroWriteSupport; +import parquet.avro.projection.AvroProjection; +import parquet.filter2.predicate.FilterPredicate; +import parquet.hadoop.ParquetInputFormat; +import parquet.hadoop.mapred.DeprecatedParquetInputFormat; +import parquet.hadoop.mapred.DeprecatedParquetOutputFormat; + +public class ParquetAvroScheme extends ParquetValueScheme { + + // In the case of reads, we can read the thrift class from the file metadata + public ParquetAvroScheme() { + this(new parquet.cascading.ParquetValueScheme.Config()); + } + + public ParquetAvroScheme(Class avroClass) { + this(new parquet.cascading.ParquetValueScheme.Config().withRecordClass(avroClass)); + } + + public ParquetAvroScheme(FilterPredicate filterPredicate) { + this(new parquet.cascading.ParquetValueScheme.Config().withFilterPredicate(filterPredicate)); + } + + public ParquetAvroScheme(FilterPredicate filterPredicate, Class avroClass) { + this(new parquet.cascading.ParquetValueScheme.Config().withRecordClass(avroClass).withFilterPredicate(filterPredicate)); + } + + public ParquetAvroScheme(parquet.cascading.ParquetValueScheme.Config config) { + super(config); + } + + @SuppressWarnings("rawtypes") + @Override + public void sourceConfInit(FlowProcess fp, + Tap tap, JobConf jobConf) { + super.sourceConfInit(fp, tap, jobConf); + try { + jobConf.setInputFormat(DeprecatedParquetInputFormat.class); + ParquetInputFormat.setReadSupportClass(jobConf, AvroReadSupport.class); + } catch (Exception e) { + System.err.println(e.toString()); + } + } + + @SuppressWarnings("rawtypes") + @Override + public void sinkConfInit(FlowProcess fp, + Tap tap, JobConf jobConf) { + DeprecatedParquetOutputFormat.setAsOutputFormat(jobConf); + DeprecatedParquetOutputFormat.setWriteSupportClass(jobConf, AvroWriteSupport.class); + IndexedRecord record = createRecordInstance(); + AvroWriteSupport.setSchema(jobConf, record.getSchema()); + } + + @Override + protected void setRecordClass(JobConf jobConf) { + IndexedRecord record = createRecordInstance(); + AvroReadSupport.setAvroReadSchema(jobConf, record.getSchema()); + } + + @Override + protected void setProjectionPushdown(JobConf jobConf) { + if (this.config.getProjectionString() != null) { + IndexedRecord record = createRecordInstance(); + AvroReadSupport.setRequestedProjection( + jobConf, + AvroProjection.createProjection(record.getSchema(), config.getProjectionString().split(";"))); + } + } + + private IndexedRecord createRecordInstance() { + if (config.getClass() == null) { + throw new IllegalArgumentException("Unable to create instance of unknown Avro record class"); + } + try { + IndexedRecord record = config.getKlass().getConstructor(null).newInstance(null); + return record; + } catch (ReflectiveOperationException e) { + throw new RuntimeException("Unable to create Avro Record of class " + config.getKlass().getName(), e); + } + } +} + diff --git a/parquet-cascading-avro/src/test/avro/test.avdl b/parquet-cascading-avro/src/test/avro/test.avdl new file mode 100644 index 0000000000..a20baeb4f8 --- /dev/null +++ b/parquet-cascading-avro/src/test/avro/test.avdl @@ -0,0 +1,8 @@ +@namespace("avrotestclasses") +protocol AvroTest { + record Name { + string first_name; + // optional last name + union { null, string } last_name = null; + } +} diff --git a/parquet-cascading-avro/src/test/java/parquet/cascading/TestParquetAvroScheme.java b/parquet-cascading-avro/src/test/java/parquet/cascading/TestParquetAvroScheme.java new file mode 100644 index 0000000000..ad29ac47ee --- /dev/null +++ b/parquet-cascading-avro/src/test/java/parquet/cascading/TestParquetAvroScheme.java @@ -0,0 +1,201 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package parquet.cascading; + +import cascading.flow.Flow; +import cascading.flow.FlowProcess; +import cascading.flow.hadoop.HadoopFlowConnector; +import cascading.operation.BaseOperation; +import cascading.operation.Function; +import cascading.operation.FunctionCall; +import cascading.pipe.Each; +import cascading.pipe.Pipe; +import cascading.scheme.Scheme; +import cascading.scheme.hadoop.TextLine; +import cascading.tap.Tap; +import cascading.tap.hadoop.Hfs; +import cascading.tuple.Fields; +import cascading.tuple.Tuple; +import cascading.tuple.TupleEntry; +import org.apache.commons.io.FileUtils; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.mapred.JobConf; +import org.junit.Test; +import parquet.avro.AvroParquetWriter; +import parquet.filter2.predicate.FilterPredicate; +import parquet.filter2.predicate.FilterApi; +import parquet.hadoop.metadata.CompressionCodecName; +import parquet.io.api.Binary; + +import java.io.File; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import avrotestclasses.Name; + +/** + * Created by schuman on 23/03/15. + */ +public class TestParquetAvroScheme { + final String txtInputPath = "src/test/resources/names.txt"; + final String parquetInputPath = "target/test/ParquetAvroScheme/names-parquet-in"; + final String parquetOutputPath = "target/test/ParquetAvroScheme/names-parquet-out"; + final String txtOutputPath = "target/test/ParquetAvroScheme/names-txt-out"; + + @Test + public void testWrite() throws Exception { + Path path = new Path(parquetOutputPath); + JobConf jobConf = new JobConf(); + final FileSystem fs = path.getFileSystem(jobConf); + if (fs.exists(path)) fs.delete(path, true); + + Scheme sourceScheme = new TextLine( new Fields( "first_name", "last_name" ) ); + Tap source = new Hfs(sourceScheme, txtInputPath); + + Scheme sinkScheme = new ParquetAvroScheme(Name.class); + Tap sink = new Hfs(sinkScheme, parquetOutputPath); + + Pipe assembly = new Pipe( "namecp" ); + assembly = new Each(assembly, new PackAvroFunction()); + HadoopFlowConnector hadoopFlowConnector = new HadoopFlowConnector(); + Flow flow = hadoopFlowConnector.connect("namecp", source, sink, assembly); + + flow.complete(); + + assertTrue(fs.exists(new Path(parquetOutputPath))); + assertTrue(fs.exists(new Path(parquetOutputPath + "/_SUCCESS"))); + } + + @Test + public void testRead() throws Exception { + doRead(new ParquetAvroScheme(Name.class)); + } + + @Test + public void testReadWithProjection() throws Exception { + ParquetValueScheme.Config config = new ParquetValueScheme.Config() + .withProjectionString("first_name") + .withRecordClass(Name.class); + doReadWithProjection(new ParquetAvroScheme(config)); + } + + @Test + public void testReadWithFilter() throws Exception { + FilterPredicate filter = FilterApi.eq(FilterApi.binaryColumn("first_name"), Binary.fromString("Bob")); + ParquetValueScheme.Config config = new ParquetValueScheme.Config() + .withFilterPredicate(filter) + .withRecordClass(Name.class); + doReadWithFilter(new ParquetAvroScheme(config)); + } + + private void prepareRead(Scheme sourceScheme, String[] fieldNames) throws Exception { + createFileForRead(); + + Path path = new Path(txtOutputPath); + final FileSystem fs = path.getFileSystem(new Configuration()); + if (fs.exists(path)) fs.delete(path, true); + + Tap source = new Hfs(sourceScheme, parquetInputPath); + + Scheme sinkScheme = new TextLine(new Fields(fieldNames)); + Tap sink = new Hfs(sinkScheme, txtOutputPath); + + Pipe assembly = new Pipe("namecp"); + assembly = new Each(assembly, new UnpackAvroFunction()); + Flow flow = new HadoopFlowConnector().connect("namecp", source, sink, assembly); + + flow.complete(); + } + + private void doRead(Scheme sourceScheme) throws Exception { + String[] fields = {"first_name", "last_name"}; + prepareRead(sourceScheme, fields); + String result = FileUtils.readFileToString(new File(txtOutputPath + "/part-00000")); + assertEquals("Alice\tPractice\nBob\tHope\nCharlie\tHorse\n", result); + } + + private void doReadWithProjection(Scheme sourceScheme) throws Exception { + String[] fields = {"first_name"}; + prepareRead(sourceScheme, fields); + String result = FileUtils.readFileToString(new File(txtOutputPath + "/part-00000")); + assertEquals("Alice\tnull\nBob\tnull\nCharlie\tnull\n", result); + } + + private void doReadWithFilter(Scheme sourceScheme) throws Exception { + String[] fields = {"first_name", "last_name"}; + prepareRead(sourceScheme, fields); + String result = FileUtils.readFileToString(new File(txtOutputPath + "/part-00000")); + assertEquals("Bob\tHope\n", result); + } + + private void createFileForRead() throws Exception { + final Path fileToCreate = new Path(parquetInputPath+"/names.parquet"); + + final Configuration conf = new Configuration(); + final FileSystem fs = fileToCreate.getFileSystem(conf); + if (fs.exists(fileToCreate)) fs.delete(fileToCreate, true); + + AvroParquetWriter writer = new AvroParquetWriter(fileToCreate, Name.getClassSchema(), CompressionCodecName.UNCOMPRESSED, 100, 100); + Name n1 = new Name(); + n1.setFirstName("Alice"); + n1.setLastName("Practice"); + Name n2 = new Name(); + n2.setFirstName("Bob"); + n2.setLastName("Hope"); + Name n3 = new Name(); + n3.setFirstName("Charlie"); + n3.setLastName("Horse"); + + writer.write(n1); + writer.write(n2); + writer.write(n3); + writer.close(); + } + + private static class PackAvroFunction extends BaseOperation implements Function { + @Override + public void operate(FlowProcess flowProcess, FunctionCall functionCall) { + TupleEntry arguments = functionCall.getArguments(); + Tuple result = new Tuple(); + + Name name = new Name(); + name.setFirstName(arguments.getString(0)); + name.setLastName(arguments.getString(1)); + + result.add(name); + functionCall.getOutputCollector().add(result); + } + } + + private static class UnpackAvroFunction extends BaseOperation implements Function { + @Override + public void operate(FlowProcess flowProcess, FunctionCall functionCall) { + TupleEntry arguments = functionCall.getArguments(); + Tuple result = new Tuple(); + + Name name = (Name) arguments.get(0); + result.add(name.getFirstName()); + result.add(name.getLastName()); + functionCall.getOutputCollector().add(result); + } + } +} diff --git a/parquet-cascading-avro/src/test/resources/names.txt b/parquet-cascading-avro/src/test/resources/names.txt new file mode 100644 index 0000000000..e2d0408c8f --- /dev/null +++ b/parquet-cascading-avro/src/test/resources/names.txt @@ -0,0 +1,3 @@ +Alice Practive +Bob Hope +Charlie Horse diff --git a/parquet-cascading/src/main/java/parquet/cascading/ParquetTBaseScheme.java b/parquet-cascading/src/main/java/parquet/cascading/ParquetTBaseScheme.java index ab84749907..17096402ca 100644 --- a/parquet-cascading/src/main/java/parquet/cascading/ParquetTBaseScheme.java +++ b/parquet-cascading/src/main/java/parquet/cascading/ParquetTBaseScheme.java @@ -29,6 +29,7 @@ import parquet.hadoop.ParquetInputFormat; import parquet.hadoop.mapred.DeprecatedParquetInputFormat; import parquet.hadoop.mapred.DeprecatedParquetOutputFormat; +import parquet.hadoop.thrift.ParquetThriftInputFormat; import parquet.hadoop.thrift.ThriftReadSupport; import parquet.hadoop.thrift.TBaseWriteSupport; import parquet.thrift.TBaseRecordConverter; @@ -77,4 +78,18 @@ public void sinkConfInit(FlowProcess fp, DeprecatedParquetOutputFormat.setWriteSupportClass(jobConf, TBaseWriteSupport.class); TBaseWriteSupport.setThriftClass(jobConf, this.config.getKlass()); } + + @Override + protected void setRecordClass(JobConf jobConf) { + if (config.getKlass() != null) { + ParquetThriftInputFormat.setThriftClass(jobConf, config.getKlass()); + } + } + + @Override + protected void setProjectionPushdown(JobConf jobConf) { + if (this.config.getProjectionString()!= null) { + ThriftReadSupport.setProjectionPushdown(jobConf, this.config.getProjectionString()); + } + } } diff --git a/parquet-cascading/src/main/java/parquet/cascading/ParquetValueScheme.java b/parquet-cascading/src/main/java/parquet/cascading/ParquetValueScheme.java index 0f75479961..331acc4779 100644 --- a/parquet-cascading/src/main/java/parquet/cascading/ParquetValueScheme.java +++ b/parquet-cascading/src/main/java/parquet/cascading/ParquetValueScheme.java @@ -35,8 +35,6 @@ import parquet.filter2.predicate.FilterPredicate; import parquet.hadoop.ParquetInputFormat; import parquet.hadoop.mapred.Container; -import parquet.hadoop.thrift.ParquetThriftInputFormat; -import parquet.hadoop.thrift.ThriftReadSupport; import static parquet.Preconditions.checkNotNull; @@ -105,13 +103,9 @@ public ParquetValueScheme(Config config) { this.config = config; } - private void setProjectionPushdown(JobConf jobConf) { - if (this.config.projectionString!= null) { - ThriftReadSupport.setProjectionPushdown(jobConf, this.config.projectionString); - } - } + protected abstract void setProjectionPushdown(JobConf jobConf); - private void setPredicatePushdown(JobConf jobConf) { + protected void setPredicatePushdown(JobConf jobConf) { if (this.config.filterPredicate != null) { ParquetInputFormat.setFilterPredicate(jobConf, this.config.filterPredicate); } @@ -123,11 +117,7 @@ public void sourceConfInit(FlowProcess jobConfFlowProcess, Tap extends ParquetValueScheme { @@ -66,4 +67,18 @@ public void sourceConfInit(FlowProcess fp, ParquetInputFormat.setReadSupportClass(jobConf, ScroogeReadSupport.class); ThriftReadSupport.setRecordConverterClass(jobConf, ScroogeRecordConverter.class); } + + @Override + protected void setRecordClass(JobConf jobConf) { + if (config.getKlass() != null) { + ParquetThriftInputFormat.setThriftClass(jobConf, config.getKlass()); + } + } + + @Override + protected void setProjectionPushdown(JobConf jobConf) { + if (this.config.getProjectionString()!= null) { + ThriftReadSupport.setProjectionPushdown(jobConf, this.config.getProjectionString()); + } + } } diff --git a/pom.xml b/pom.xml index 5efbe019e3..258c309381 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,7 @@ 1.2.17 1.6.0rc1 thrift + 1.7.6 2.10.4 2.10 @@ -119,6 +120,7 @@ parquet-avro parquet-cascading + parquet-cascading-avro parquet-column parquet-common parquet-encoding @@ -381,6 +383,7 @@ **/*.parquet **/*.avro + **/*.avdl **/*.json **/names.txt **/*.avsc