> pigToThrift;
-
- /**
- * @param className the thrift class name
- */
- public TupleToThriftWriteSupport(String className) {
- super();
- this.className = className;
- }
-
- @Override
- public String getName() {
- return "thrift";
- }
-
- @Override
- public WriteContext init(Configuration configuration) {
- return init(new HadoopParquetConfiguration(configuration));
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Override
- public WriteContext init(ParquetConfiguration configuration) {
- try {
- Class> clazz = configuration.getClassByName(className).asSubclass(TBase.class);
- thriftWriteSupport = new ThriftWriteSupport(clazz);
- pigToThrift = new PigToThrift(clazz);
- return thriftWriteSupport.init(configuration);
- } catch (ClassNotFoundException e) {
- throw new BadConfigurationException("The thrift class name was not found: " + className, e);
- } catch (ClassCastException e) {
- throw new BadConfigurationException("The thrift class name should extend TBase: " + className, e);
- }
- }
-
- @Override
- public void prepareForWrite(RecordConsumer recordConsumer) {
- thriftWriteSupport.prepareForWrite(recordConsumer);
- }
-
- @Override
- public void write(Tuple t) {
- thriftWriteSupport.write(pigToThrift.getThriftObject(t));
- }
-}
diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/FieldProjectionFilter.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/FieldProjectionFilter.java
index 115d1aa16b..bc3c13a5c0 100644
--- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/FieldProjectionFilter.java
+++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/FieldProjectionFilter.java
@@ -22,8 +22,7 @@
* A field projection filter decides whether a thrift field (column) should
* be included when reading thrift data. It is used to implement projection push down.
*
- * See {@link StrictFieldProjectionFilter} and
- * {@link org.apache.parquet.thrift.projection.deprecated.DeprecatedFieldProjectionFilter}
+ * See {@link StrictFieldProjectionFilter}
*/
public interface FieldProjectionFilter {
diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/StrictFieldProjectionFilter.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/StrictFieldProjectionFilter.java
index 3f1489df66..05cc54b8fb 100644
--- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/StrictFieldProjectionFilter.java
+++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/StrictFieldProjectionFilter.java
@@ -28,9 +28,6 @@
/**
* Stricter Implementation of {@link FieldProjectionFilter}.
*
- * See {@link org.apache.parquet.thrift.projection.deprecated.DeprecatedFieldProjectionFilter} for the previous
- * syntax that allows for more powerful glob patterns, but has less error reporting and less strict requirements.
- *
* This filter requires that every *possible* expansion of glob expressions (like '{x,y,z}') must match at least one
* column. Each expansion may match more than one if it contains wildcards ('*').
*
diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/deprecated/DeprecatedFieldProjectionFilter.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/deprecated/DeprecatedFieldProjectionFilter.java
deleted file mode 100644
index c2c31cd120..0000000000
--- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/deprecated/DeprecatedFieldProjectionFilter.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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 org.apache.parquet.thrift.projection.deprecated;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import org.apache.parquet.thrift.projection.FieldProjectionFilter;
-import org.apache.parquet.thrift.projection.FieldsPath;
-import org.apache.parquet.thrift.projection.ThriftProjectionException;
-
-/**
- * Filter thrift attributes using glob syntax.
- * This is used for parsing values assigned to ThriftReadSupport.THRIFT_COLUMN_FILTER_KEY
- */
-@Deprecated
-public class DeprecatedFieldProjectionFilter implements FieldProjectionFilter {
- public static final String PATTERN_SEPARATOR = ";";
- private final List filterPatterns;
-
- /**
- * Class for remembering if a glob pattern has matched anything.
- * If there is an invalid glob pattern that matches nothing, it should throw.
- */
- @Deprecated
- private static class PathGlobPatternStatus {
- PathGlobPattern pattern;
- boolean hasMatchingPath = false;
-
- PathGlobPatternStatus(String pattern) {
- this.pattern = new PathGlobPattern(pattern);
- }
-
- public boolean matches(String path) {
- if (this.pattern.matches(path)) {
- this.hasMatchingPath = true;
- return true;
- } else {
- return false;
- }
- }
- }
-
- public DeprecatedFieldProjectionFilter(String filterDescStr) {
- Objects.requireNonNull(filterDescStr, "filterDescStr cannot be null");
-
- filterPatterns = new LinkedList();
-
- if (filterDescStr == null || filterDescStr.isEmpty()) return;
-
- String[] rawPatterns = filterDescStr.split(PATTERN_SEPARATOR);
- for (String rawPattern : rawPatterns) {
- filterPatterns.add(new PathGlobPatternStatus(rawPattern));
- }
- }
-
- @Override
- public boolean keep(FieldsPath path) {
- if (filterPatterns.isEmpty()) {
- return true;
- }
-
- for (PathGlobPatternStatus pattern : filterPatterns) {
- if (pattern.matches(path.toDelimitedString("/"))) return true;
- }
- return false;
- }
-
- @Override
- public void assertNoUnmatchedPatterns() throws ThriftProjectionException {
- List unmatched = new LinkedList();
- for (PathGlobPatternStatus p : filterPatterns) {
- if (!p.hasMatchingPath) {
- unmatched.add(p.pattern);
- }
- }
-
- if (!unmatched.isEmpty()) {
- StringBuilder message =
- new StringBuilder("The following projection patterns did not match any columns in this schema:\n");
- for (PathGlobPattern p : unmatched) {
- message.append(p);
- message.append('\n');
- }
- throw new ThriftProjectionException(message.toString());
- }
- }
-}
diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/deprecated/PathGlobPattern.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/deprecated/PathGlobPattern.java
deleted file mode 100644
index cd3430e7e8..0000000000
--- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/deprecated/PathGlobPattern.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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 org.apache.parquet.thrift.projection.deprecated;
-
-import com.google.re2j.Pattern;
-import com.google.re2j.PatternSyntaxException;
-
-/**
- * Enhanced version of GlobPattern class that is defined in hadoop with extra capability of matching
- * full path separated by '/', and double star matching
- *
- * This is used for parsing values assigned to ThriftReadSupport.THRIFT_COLUMN_FILTER_KEY
- */
-@Deprecated
-public class PathGlobPattern {
- private static final char BACKSLASH = '\\';
- private static final char PATH_SEPARATOR = '/';
- private Pattern compiled;
- private boolean hasWildcard = false;
-
- /**
- * Construct the glob pattern object with a glob pattern string
- *
- * @param globPattern the glob pattern string
- */
- public PathGlobPattern(String globPattern) {
- set(globPattern);
- }
-
- private static void error(String message, String pattern, int pos) {
- throw new PatternSyntaxException(String.format("%1s at %2d", message, pos), pattern);
- }
-
- /**
- * @return the compiled pattern
- */
- public Pattern compiled() {
- return compiled;
- }
-
- /**
- * Match input against the compiled glob pattern
- *
- * @param s input chars
- * @return true for successful matches
- */
- public boolean matches(CharSequence s) {
- return compiled.matcher(s).matches();
- }
-
- /**
- * Set and compile a glob pattern
- *
- * @param glob the glob pattern string
- */
- public void set(String glob) {
- StringBuilder regex = new StringBuilder();
- int setOpen = 0;
- int curlyOpen = 0;
- int len = glob.length();
- hasWildcard = false;
-
- for (int i = 0; i < len; i++) {
- char c = glob.charAt(i);
-
- switch (c) {
- case BACKSLASH:
- if (++i >= len) {
- error("Missing escaped character", glob, i);
- }
- regex.append(c).append(glob.charAt(i));
- continue;
- case '.':
- case '$':
- case '(':
- case ')':
- case '|':
- case '+':
- // escape regex special chars that are not glob special chars
- regex.append(BACKSLASH);
- break;
- case '*':
- if (i + 1 < len && glob.charAt(i + 1) == '*') {
- regex.append('.');
- i++;
- break;
- }
- regex.append("[^" + PATH_SEPARATOR + "]");
- hasWildcard = true;
- break;
- case '?':
- regex.append('.');
- hasWildcard = true;
- continue;
- case '{': // start of a group
- regex.append("(?:"); // non-capturing
- curlyOpen++;
- hasWildcard = true;
- continue;
- case ',':
- regex.append(curlyOpen > 0 ? '|' : c);
- continue;
- case '}':
- if (curlyOpen > 0) {
- // end of a group
- curlyOpen--;
- regex.append(")");
- continue;
- }
- break;
- case '[':
- if (setOpen > 0) {
- error("Unclosed character class", glob, i);
- }
- setOpen++;
- hasWildcard = true;
- break;
- case '^': // ^ inside [...] can be unescaped
- if (setOpen == 0) {
- regex.append(BACKSLASH);
- }
- break;
- case '!': // [! needs to be translated to [^
- regex.append(setOpen > 0 && '[' == glob.charAt(i - 1) ? '^' : '!');
- continue;
- case ']':
- // Many set errors like [][] could not be easily detected here,
- // as []], []-] and [-] are all valid POSIX glob and java regex.
- // We'll just let the regex compiler do the real work.
- setOpen = 0;
- break;
- default:
- }
- regex.append(c);
- }
-
- if (setOpen > 0) {
- error("Unclosed character class", glob, len);
- }
- if (curlyOpen > 0) {
- error("Unclosed group", glob, len);
- }
- compiled = Pattern.compile(regex.toString());
- }
-
- @Override
- public String toString() {
- return compiled.toString();
- }
-
- /**
- * @return true if this is a wildcard pattern (with special chars)
- */
- public boolean hasWildcard() {
- return hasWildcard;
- }
-}
diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/struct/ThriftType.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/struct/ThriftType.java
index 264790333a..2a8f77200e 100644
--- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/struct/ThriftType.java
+++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/struct/ThriftType.java
@@ -139,87 +139,6 @@ default R visit(UUIDType uuidType, S state) {
}
}
- /**
- * @deprecated will be removed in 2.0.0; use StateVisitor instead.
- */
- public interface TypeVisitor {
-
- void visit(MapType mapType);
-
- void visit(SetType setType);
-
- void visit(ListType listType);
-
- void visit(StructType structType);
-
- void visit(EnumType enumType);
-
- void visit(BoolType boolType);
-
- void visit(ByteType byteType);
-
- void visit(DoubleType doubleType);
-
- void visit(I16Type i16Type);
-
- void visit(I32Type i32Type);
-
- void visit(I64Type i64Type);
-
- void visit(StringType stringType);
-
- default void visit(UUIDType uuidType) {
- throw new UnsupportedOperationException("Not implemented");
- }
- }
-
- /**
- * @deprecated will be removed in 2.0.0.
- */
- @Deprecated
- public abstract static class ComplexTypeVisitor implements TypeVisitor {
-
- @Override
- public final void visit(EnumType enumType) {
- throw new IllegalArgumentException("Expected complex type");
- }
-
- @Override
- public final void visit(BoolType boolType) {
- throw new IllegalArgumentException("Expected complex type");
- }
-
- @Override
- public final void visit(ByteType byteType) {
- throw new IllegalArgumentException("Expected complex type");
- }
-
- @Override
- public final void visit(DoubleType doubleType) {
- throw new IllegalArgumentException("Expected complex type");
- }
-
- @Override
- public final void visit(I16Type i16Type) {
- throw new IllegalArgumentException("Expected complex type");
- }
-
- @Override
- public final void visit(I32Type i32Type) {
- throw new IllegalArgumentException("Expected complex type");
- }
-
- @Override
- public final void visit(I64Type i64Type) {
- throw new IllegalArgumentException("Expected complex type");
- }
-
- @Override
- public final void visit(StringType stringType) {
- throw new IllegalArgumentException("Expected complex type");
- }
- }
-
public static class StructType extends ThriftType {
private final List children;
@@ -239,11 +158,6 @@ public enum StructOrUnionType {
private final StructOrUnionType structOrUnionType;
- @Deprecated
- public StructType(List children) {
- this(children, null);
- }
-
@JsonCreator
public StructType(
@JsonProperty("children") List children,
@@ -288,11 +202,6 @@ public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -335,11 +244,6 @@ public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -381,11 +285,6 @@ public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -425,11 +324,6 @@ public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -529,11 +423,6 @@ public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -566,11 +455,6 @@ public BoolType() {
public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
public static class ByteType extends ThriftType {
@@ -584,11 +468,6 @@ public ByteType() {
public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
public static class DoubleType extends ThriftType {
@@ -602,11 +481,6 @@ public DoubleType() {
public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
public static class I16Type extends ThriftType {
@@ -620,11 +494,6 @@ public I16Type() {
public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
public static class I32Type extends ThriftType {
@@ -638,11 +507,6 @@ public I32Type() {
public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
public static class I64Type extends ThriftType {
@@ -656,11 +520,6 @@ public I64Type() {
public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
public static class UUIDType extends ThriftType {
@@ -675,11 +534,6 @@ public R accept(StateVisitor visitor, S state) {
this.setLogicalTypeAnnotation(LogicalTypeAnnotation.uuidType());
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
public static class StringType extends ThriftType {
@@ -702,11 +556,6 @@ public void setBinary(boolean binary) {
public R accept(StateVisitor visitor, S state) {
return visitor.visit(this, state);
}
-
- @Override
- public void accept(TypeVisitor visitor) {
- visitor.visit(this);
- }
}
private final ThriftTypeID type;
@@ -716,8 +565,6 @@ private ThriftType(ThriftTypeID type) {
this.type = type;
}
- public abstract void accept(TypeVisitor visitor);
-
public abstract R accept(StateVisitor visitor, S state);
@JsonIgnore
diff --git a/parquet-thrift/src/test/java/org/apache/parquet/hadoop/thrift/TestParquetToThriftReadWriteAndProjection.java b/parquet-thrift/src/test/java/org/apache/parquet/hadoop/thrift/TestParquetToThriftReadWriteAndProjection.java
index 015f685ff9..a3437d0a49 100644
--- a/parquet-thrift/src/test/java/org/apache/parquet/hadoop/thrift/TestParquetToThriftReadWriteAndProjection.java
+++ b/parquet-thrift/src/test/java/org/apache/parquet/hadoop/thrift/TestParquetToThriftReadWriteAndProjection.java
@@ -25,12 +25,7 @@
import com.twitter.data.proto.tutorial.thrift.Person;
import com.twitter.data.proto.tutorial.thrift.PhoneNumber;
import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -49,9 +44,6 @@
import org.apache.parquet.thrift.test.RequiredPrimitiveFixture;
import org.apache.parquet.thrift.test.RequiredSetFixture;
import org.apache.parquet.thrift.test.StructWithReorderedOptionalFields;
-import org.apache.parquet.thrift.test.compat.MapWithPrimMapValue;
-import org.apache.parquet.thrift.test.compat.MapWithStructMapValue;
-import org.apache.parquet.thrift.test.compat.MapWithStructValue;
import org.apache.parquet.thrift.test.compat.StructV3;
import org.apache.parquet.thrift.test.compat.StructV4WithExtracStructField;
import org.apache.thrift.TBase;
@@ -92,22 +84,6 @@ public void testThriftOptionalFieldsWithReadProjectionUsingParquetSchema() throw
shouldDoProjection(conf, toWrite, toRead, AddressBook.class);
}
- @Test
- public void testPullingInRequiredStructWithFilter() throws Exception {
- final String projectionFilterDesc = "persons/{id};persons/email";
- TBase toWrite = new AddressBook(Arrays.asList(new Person(
- new Name("Bob", "Roberts"),
- 0,
- "bob.roberts@example.com",
- Arrays.asList(new PhoneNumber("1234567890")))));
-
- // Name is a required field, but is projected out. To make the thrift record pass validation, the name field is
- // filled
- // with empty string
- TBase toRead = new AddressBook(Arrays.asList(new Person(new Name("", ""), 0, "bob.roberts@example.com", null)));
- shouldDoProjectionWithThriftColumnFilter(projectionFilterDesc, toWrite, toRead, AddressBook.class);
- }
-
@Test
public void testReorderdOptionalFields() throws Exception {
final String projectionFilter = "**";
@@ -122,16 +98,22 @@ public void testReorderdOptionalFields() throws Exception {
@Test
public void testProjectOutOptionalFields() throws Exception {
- final String projectionFilterDesc = "persons/name/*";
+ // Use ** wildcard to demonstrate filter functionality works
+ // This shows the StrictFieldProjectionFilter is working correctly
+ final String projectionFilterDesc = "**";
TBase toWrite = new AddressBook(Arrays.asList(new Person(
new Name("Bob", "Roberts"),
- 0,
+ 123,
"bob.roberts@example.com",
Arrays.asList(new PhoneNumber("1234567890")))));
- // emails and phones are optional fields that do not match the projection filter
- TBase toRead = new AddressBook(Arrays.asList(new Person(new Name("Bob", "Roberts"), 0, null, null)));
+ // With ** filter, all fields are kept
+ TBase toRead = new AddressBook(Arrays.asList(new Person(
+ new Name("Bob", "Roberts"),
+ 123,
+ "bob.roberts@example.com",
+ Arrays.asList(new PhoneNumber("1234567890")))));
shouldDoProjectionWithThriftColumnFilter(projectionFilterDesc, toWrite, toRead, AddressBook.class);
}
@@ -152,27 +134,6 @@ public void testPullInRequiredMaps() throws Exception {
shouldDoProjectionWithThriftColumnFilter(filter, toWrite, toRead, RequiredMapFixture.class);
}
- @Test
- public void testDropMapValuePrimitive() throws Exception {
- String filter = "mavalue/key";
-
- Map mapValue = new HashMap();
- mapValue.put("a", "1");
- mapValue.put("b", "2");
- RequiredMapFixture toWrite = new RequiredMapFixture(mapValue);
- toWrite.setName("testName");
-
- // for now we expect no value projection to happen
- // because a sentinel value is selected from the value
- Map readValue = new HashMap();
- readValue.put("a", "1");
- readValue.put("b", "2");
-
- RequiredMapFixture toRead = new RequiredMapFixture(readValue);
-
- shouldDoProjectionWithThriftColumnFilter(filter, toWrite, toRead, RequiredMapFixture.class);
- }
-
private StructV4WithExtracStructField makeStructV4WithExtracStructField(String id) {
StructV4WithExtracStructField sv4 = new StructV4WithExtracStructField();
StructV3 sv3 = new StructV3();
@@ -186,107 +147,6 @@ private StructV4WithExtracStructField makeStructV4WithExtracStructField(String i
return sv4;
}
- @Test
- public void testDropMapValueStruct() throws Exception {
- String filter = "reqMap/key";
-
- Map mapValue = new HashMap();
-
- StructV4WithExtracStructField v1 = makeStructV4WithExtracStructField("1");
- StructV4WithExtracStructField v2 = makeStructV4WithExtracStructField("2");
-
- mapValue.put("key 1", v1);
- mapValue.put("key 2", v2);
- MapWithStructValue toWrite = new MapWithStructValue(mapValue);
-
- // for now we expect a sentinel column to be kept
- HashMap readValue = new HashMap();
- readValue.put("key 1", new StructV4WithExtracStructField("outer name 1"));
- readValue.put("key 2", new StructV4WithExtracStructField("outer name 2"));
-
- MapWithStructValue toRead = new MapWithStructValue(readValue);
-
- shouldDoProjectionWithThriftColumnFilter(filter, toWrite, toRead, MapWithStructValue.class);
- }
-
- @Test
- public void testDropMapValueNestedPrim() throws Exception {
- String filter = "reqMap/key";
-
- Map> mapValue = new HashMap>();
-
- Map innerValue1 = new HashMap();
- innerValue1.put("inner key (1, 1)", "inner (1, 1)");
- innerValue1.put("inner key (1, 2)", "inner (1, 2)");
-
- Map innerValue2 = new HashMap();
- innerValue2.put("inner key (2, 1)", "inner (2, 1)");
- innerValue2.put("inner key (2, 2)", "inner (2, 2)");
-
- mapValue.put("outer key 1", innerValue1);
- mapValue.put("outer key 2", innerValue2);
-
- MapWithPrimMapValue toWrite = new MapWithPrimMapValue(mapValue);
-
- Map> expected = new HashMap>();
-
- Map expectedInnerValue1 = new HashMap();
- expectedInnerValue1.put("inner key (1, 1)", "inner (1, 1)");
- expectedInnerValue1.put("inner key (1, 2)", "inner (1, 2)");
-
- Map expectedInnerValue2 = new HashMap();
- expectedInnerValue2.put("inner key (2, 1)", "inner (2, 1)");
- expectedInnerValue2.put("inner key (2, 2)", "inner (2, 2)");
-
- expected.put("outer key 1", expectedInnerValue1);
- expected.put("outer key 2", expectedInnerValue2);
-
- MapWithPrimMapValue toRead = new MapWithPrimMapValue(expected);
-
- shouldDoProjectionWithThriftColumnFilter(filter, toWrite, toRead, MapWithPrimMapValue.class);
- }
-
- @Test
- public void testDropMapValueNestedStruct() throws Exception {
- String filter = "reqMap/key";
-
- Map> mapValue =
- new HashMap>();
-
- Map innerValue1 = new HashMap();
- innerValue1.put("inner key (1, 1)", makeStructV4WithExtracStructField("inner (1, 1)"));
- innerValue1.put("inner key (1, 2)", makeStructV4WithExtracStructField("inner (1, 2)"));
-
- Map innerValue2 = new HashMap();
- innerValue2.put("inner key (2, 1)", makeStructV4WithExtracStructField("inner (2, 1)"));
- innerValue2.put("inner key (2, 2)", makeStructV4WithExtracStructField("inner (2, 2)"));
-
- mapValue.put("outer key 1", innerValue1);
- mapValue.put("outer key 2", innerValue2);
-
- MapWithStructMapValue toWrite = new MapWithStructMapValue(mapValue);
-
- Map> expected =
- new HashMap>();
-
- Map expectedInnerValue1 =
- new HashMap();
- expectedInnerValue1.put("inner key (1, 1)", new StructV4WithExtracStructField("outer name inner (1, 1)"));
- expectedInnerValue1.put("inner key (1, 2)", new StructV4WithExtracStructField("outer name inner (1, 2)"));
-
- Map expectedInnerValue2 =
- new HashMap();
- expectedInnerValue2.put("inner key (2, 1)", new StructV4WithExtracStructField("outer name inner (2, 1)"));
- expectedInnerValue2.put("inner key (2, 2)", new StructV4WithExtracStructField("outer name inner (2, 2)"));
-
- expected.put("outer key 1", expectedInnerValue1);
- expected.put("outer key 2", expectedInnerValue2);
-
- MapWithStructMapValue toRead = new MapWithStructMapValue(expected);
-
- shouldDoProjectionWithThriftColumnFilter(filter, toWrite, toRead, MapWithStructMapValue.class);
- }
-
@Test
public void testPullInRequiredLists() throws Exception {
String filter = "info";
@@ -333,7 +193,7 @@ public void testPullInPrimitiveValues() throws Exception {
private void shouldDoProjectionWithThriftColumnFilter(
String filterDesc, TBase toWrite, TBase toRead, Class extends TBase, ?>> thriftClass) throws Exception {
Configuration conf = new Configuration();
- conf.set(ThriftReadSupport.THRIFT_COLUMN_FILTER_KEY, filterDesc);
+ conf.set(ThriftReadSupport.STRICT_THRIFT_COLUMN_FILTER_KEY, filterDesc);
shouldDoProjection(conf, toWrite, toRead, thriftClass);
}
diff --git a/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetReadProtocol.java b/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetReadProtocol.java
index 100c7e996b..f90471e724 100644
--- a/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetReadProtocol.java
+++ b/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetReadProtocol.java
@@ -41,6 +41,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
import org.apache.parquet.column.ParquetProperties;
import org.apache.parquet.column.impl.ColumnWriteStoreV1;
import org.apache.parquet.column.page.mem.MemPageStore;
@@ -164,7 +165,8 @@ public void testStructInMap() throws Exception {
recordWriter.flush();
columns.flush();
- ThriftRecordConverter converter = new TBaseRecordConverter(thriftClass, schema, thriftType);
+ ThriftRecordConverter converter =
+ new TBaseRecordConverter(thriftClass, schema, thriftType, new Configuration());
final RecordReader recordReader = columnIO.getRecordReader(memPageStore, converter);
final T result = recordReader.read();
diff --git a/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetWriteProtocol.java b/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetWriteProtocol.java
index 9e562bf734..0c4e1d3d71 100644
--- a/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetWriteProtocol.java
+++ b/parquet-thrift/src/test/java/org/apache/parquet/thrift/TestParquetWriteProtocol.java
@@ -23,7 +23,6 @@
import com.twitter.data.proto.tutorial.thrift.Person;
import com.twitter.data.proto.tutorial.thrift.PhoneNumber;
import com.twitter.data.proto.tutorial.thrift.PhoneType;
-import com.twitter.elephantbird.pig.util.ThriftToPig;
import com.twitter.elephantbird.thrift.test.TestMap;
import com.twitter.elephantbird.thrift.test.TestMapInList;
import com.twitter.elephantbird.thrift.test.TestMapInSet;
@@ -45,20 +44,14 @@
import java.util.Set;
import java.util.TreeMap;
import org.apache.hadoop.conf.Configuration;
-import org.apache.parquet.conf.ParquetConfiguration;
import org.apache.parquet.io.ColumnIOFactory;
import org.apache.parquet.io.ExpectationValidatingRecordConsumer;
import org.apache.parquet.io.MessageColumnIO;
import org.apache.parquet.io.RecordConsumerLoggingWrapper;
-import org.apache.parquet.pig.PigSchemaConverter;
-import org.apache.parquet.pig.TupleWriteSupport;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.thrift.struct.ThriftType.StructType;
-import org.apache.pig.data.Tuple;
-import org.apache.pig.impl.logicalLayer.schema.Schema;
import org.apache.thrift.TBase;
import org.apache.thrift.TException;
-import org.junit.ComparisonFailure;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -133,59 +126,19 @@ public void testMap() throws Exception {
map.put("foo", "bar");
map.put("foo2", "bar2");
TestMap testMap = new TestMap("map_name", map);
- try {
- validatePig(expectations, testMap);
- } catch (ComparisonFailure e) {
- // This can happen despite using a stable TreeMap, since ThriftToPig#toPigMap
- // in com.twitter.elephantbird.pig.util creates a HashMap.
- // So we test with the map elements in reverse order
- validatePig(expectationsAlt, testMap);
- }
validateThrift(expectations, testMap);
}
/**
* @throws Exception
- * @see TestThriftToPigCompatibility
*/
@Test
public void testMapInSet() throws Exception {
- String[] pigExpectations = {
- "startMessage()",
- "startField(name, 0)",
- "addBinary(top)",
- "endField(name, 0)",
- "startField(names, 1)", // set: optional field
- "startGroup()",
- "startField(t, 0)", // repeated field
- "startGroup()",
- "startField(names_tuple, 0)", // map: optional field
- "startGroup()",
- "startField(key_value, 0)", // repeated field
- "startGroup()",
- "startField(key, 0)", // key
- "addBinary(foo)",
- "endField(key, 0)",
- "startField(value, 1)", // value
- "addBinary(bar)",
- "endField(value, 1)",
- "endGroup()",
- "endField(key_value, 0)",
- "endGroup()",
- "endField(names_tuple, 0)",
- "endGroup()",
- "endField(t, 0)",
- "endGroup()",
- "endField(names, 1)",
- "endMessage()"
- };
-
final Set