Skip to content

Commit

Permalink
PARQUET-1335: Logical type names in parquet-mr are not consistent wit…
Browse files Browse the repository at this point in the history
…h parquet-format (apache#503)

Add test case for STRING annotation and revert UTF8 annotations removed in PR#496
  • Loading branch information
nandorKollar authored and gszadovszky committed Jul 9, 2018
1 parent 94ae6c8 commit e9e36cd
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.MILLIS;
import static org.apache.parquet.schema.LogicalTypeAnnotation.intType;
import static org.apache.parquet.schema.LogicalTypeAnnotation.stringType;
import static org.apache.parquet.schema.LogicalTypeAnnotation.timeType;
import static org.apache.parquet.schema.LogicalTypeAnnotation.timestampType;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -119,27 +120,44 @@ public void testEachPrimitiveType() {
}

@Test
public void testUTF8Annotation() {
public void testSTRINGAnnotation() {
String message =
"message StringMessage {\n" +
" required binary string (STRING);\n" +
"}\n";

MessageType parsed = parseMessageType(message);
MessageType expected = buildMessage()
.required(BINARY).as(UTF8).named("string")
.required(BINARY).as(stringType()).named("string")
.named("StringMessage");

assertEquals(expected, parsed);
MessageType reparsed = parseMessageType(parsed.toString());
assertEquals(expected, reparsed);
}

@Test
public void testUTF8Annotation() {
String message =
"message StringMessage {\n" +
" required binary string (UTF8);\n" +
"}\n";

MessageType parsed = parseMessageType(message);
MessageType expected = buildMessage()
.required(BINARY).as(UTF8).named("string")
.named("StringMessage");

assertEquals(expected, parsed);
MessageType reparsed = parseMessageType(parsed.toString());
assertEquals(expected, reparsed);
}

@Test
public void testIDs() {
String message =
"message Message {\n" +
" required binary string (STRING) = 6;\n" +
" required binary string (UTF8) = 6;\n" +
" required int32 i=1;\n" +
" required binary s2= 3;\n" +
" required binary s3 =4;\n" +
Expand All @@ -165,7 +183,7 @@ public void testMAPAnnotations() {
"message Message {\n" +
" optional group aMap (MAP) {\n" +
" repeated group map (MAP_KEY_VALUE) {\n" +
" required binary key (STRING);\n" +
" required binary key (UTF8);\n" +
" required int32 value;\n" +
" }\n" +
" }\n" +
Expand All @@ -192,7 +210,7 @@ public void testLISTAnnotation() {
String message =
"message Message {\n" +
" required group aList (LIST) {\n" +
" repeated binary string (STRING);\n" +
" repeated binary string (UTF8);\n" +
" }\n" +
"}\n";

Expand Down

0 comments on commit e9e36cd

Please sign in to comment.