|
1 | | -/* |
| 1 | +/* |
2 | 2 | * Licensed to the Apache Software Foundation (ASF) under one |
3 | 3 | * or more contributor license agreements. See the NOTICE file |
4 | 4 | * distributed with this work for additional information |
5 | 5 | * regarding copyright ownership. The ASF licenses this file |
6 | 6 | * to you under the Apache License, Version 2.0 (the |
7 | 7 | * "License"); you may not use this file except in compliance |
8 | 8 | * with the License. You may obtain a copy of the License at |
9 | | - * |
| 9 | + * |
10 | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | | - * |
| 11 | + * |
12 | 12 | * Unless required by applicable law or agreed to in writing, |
13 | 13 | * software distributed under the License is distributed on an |
14 | 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
23 | 23 | import org.apache.parquet.thrift.projection.StrictFieldProjectionFilter; |
24 | 24 | import org.apache.parquet.thrift.projection.ThriftProjectionException; |
25 | 25 | import org.apache.parquet.thrift.projection.deprecated.DeprecatedFieldProjectionFilter; |
| 26 | +import org.apache.parquet.thrift.struct.ThriftField; |
26 | 27 | import org.apache.parquet.thrift.struct.ThriftType; |
27 | 28 | import org.apache.parquet.thrift.struct.ThriftType.StructType; |
28 | 29 | import org.apache.parquet.thrift.test.compat.MapStructV2; |
|
34 | 35 | import com.twitter.data.proto.tutorial.thrift.Person; |
35 | 36 | import com.twitter.elephantbird.thrift.test.TestStructInMap; |
36 | 37 |
|
| 38 | +import java.util.Arrays; |
| 39 | + |
37 | 40 | import static org.apache.parquet.schema.MessageTypeParser.parseMessageType; |
| 41 | +import static org.apache.parquet.thrift.struct.ThriftField.Requirement.REQUIRED; |
38 | 42 | import static org.junit.Assert.assertEquals; |
39 | 43 | import static org.junit.Assert.fail; |
40 | 44 |
|
@@ -288,6 +292,26 @@ public void testSetPartialProjection() { |
288 | 292 | } |
289 | 293 | } |
290 | 294 |
|
| 295 | + @Test |
| 296 | + public void testConvertStructCreatedViaDeprecatedConstructor() { |
| 297 | + String expected = "message ParquetSchema {\n" + |
| 298 | + " required binary a (UTF8) = 1;\n" + |
| 299 | + " required binary b (UTF8) = 2;\n" + |
| 300 | + "}\n"; |
| 301 | + |
| 302 | + ThriftSchemaConverter converter = new ThriftSchemaConverter(); |
| 303 | + |
| 304 | + StructType structType = new StructType( |
| 305 | + Arrays.asList( |
| 306 | + new ThriftField("a", (short) 1, REQUIRED, new ThriftType.StringType()), |
| 307 | + new ThriftField("b", (short) 2, REQUIRED, new ThriftType.StringType()) |
| 308 | + ) |
| 309 | + ); |
| 310 | + |
| 311 | + final MessageType converted = converter.convert(structType); |
| 312 | + assertEquals(MessageTypeParser.parseMessageType(expected), converted); |
| 313 | + } |
| 314 | + |
291 | 315 | public static void shouldGetProjectedSchema(String deprecatedFilterDesc, String strictFilterDesc, String expectedSchemaStr, Class<? extends TBase<?,?>> thriftClass) { |
292 | 316 | MessageType depRequestedSchema = getDeprecatedFilteredSchema(deprecatedFilterDesc, thriftClass); |
293 | 317 | MessageType strictRequestedSchema = getStrictFilteredSchema(strictFilterDesc, thriftClass); |
|
0 commit comments