Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -78,7 +79,7 @@ final public void start() {

@Override
public void end() {
parent.add(new HashMap<String, Object>(buffer));
parent.add(new LinkedHashMap<String, Object>(buffer));
}

/**
Expand Down
20 changes: 16 additions & 4 deletions parquet-pig/src/test/java/parquet/pig/TestParquetStorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,28 @@ public void testMultipleSchema() throws ExecException, Exception {

final Schema schema = data.getSchema("out");
assertEquals(2, schema.size());
assertEquals("a", schema.getField(0).alias);
assertEquals("b", schema.getField(1).alias);
// union could be in either order
int ai;
int bi;
if ("a".equals(schema.getField(0).alias)) {
ai = 0;
bi = 1;
assertEquals("a", schema.getField(0).alias);
assertEquals("b", schema.getField(1).alias);
} else {
ai = 1;
bi = 0;
assertEquals("b", schema.getField(0).alias);
assertEquals("a", schema.getField(1).alias);
}

assertEquals(rows * 2, result.size());

int a = 0;
int b = 0;
for (Tuple tuple : result) {
String fa = (String) tuple.get(0);
String fb = (String) tuple.get(1);
String fa = (String) tuple.get(ai);
String fb = (String) tuple.get(bi);
if (fa != null) {
assertEquals("a" + a, fa);
++a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

import org.apache.pig.impl.logicalLayer.schema.Schema;
import org.apache.pig.impl.util.Utils;
import org.junit.Ignore;
import org.junit.Test;

import parquet.schema.MessageType;
Expand Down Expand Up @@ -214,8 +217,8 @@ public void testAnnonymousField() throws Exception {

@Test
public void testSchemaEvolution() {
Map<String, Set<String>> map = new HashMap<String, Set<String>>();
map.put("pig.schema", new HashSet<String>(Arrays.asList(
Map<String, Set<String>> map = new LinkedHashMap<String, Set<String>>();
map.put("pig.schema", new LinkedHashSet<String>(Arrays.asList(
"a:int, b:int, c:int, d:int, e:int, f:int",
"aa:int, aaa:int, b:int, c:int, ee:int")));
Schema result = getPigSchemaFromMultipleFiles(new MessageType("empty"), map);
Expand Down
5 changes: 4 additions & 1 deletion parquet-scrooge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.6</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed to add the scala.maven.test.skip property, or is this related to other fixes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed for skip.

<executions>
<execution>
<id>scala-compile-first</id>
Expand All @@ -146,6 +146,9 @@
</goals>
</execution>
</executions>
<configuration>
<skip>${scala.maven.test.skip}</skip>
</configuration>
</plugin>

<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Set;
import java.util.TreeMap;

import org.junit.ComparisonFailure;
import thrift.test.OneOfEach;

import org.apache.pig.data.Tuple;
Expand Down Expand Up @@ -95,12 +96,48 @@ public void testMap() throws Exception {
"endField(names, 1)",
"endMessage()"
};
String[] expectationsAlt = {
"startMessage()",
"startField(name, 0)",
"addBinary(map_name)",
"endField(name, 0)",
"startField(names, 1)",
"startGroup()",
"startField(map, 0)",
"startGroup()",
"startField(key, 0)",
"addBinary(foo2)",
"endField(key, 0)",
"startField(value, 1)",
"addBinary(bar2)",
"endField(value, 1)",
"endGroup()",
"startGroup()",
"startField(key, 0)",
"addBinary(foo)",
"endField(key, 0)",
"startField(value, 1)",
"addBinary(bar)",
"endField(value, 1)",
"endGroup()",
"endField(map, 0)",
"endGroup()",
"endField(names, 1)",
"endMessage()"
};

final Map<String, String> map = new TreeMap<String, String>();
map.put("foo", "bar");
map.put("foo2", "bar2");
TestMap testMap = new TestMap("map_name", map);
validatePig(expectations, testMap);
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);
}

Expand Down
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@
</pluginRepositories>

<properties>
<targetJavaVersion>1.6</targetJavaVersion>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.target>${targetJavaVersion}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<github.global.server>github</github.global.server>
<maven-jar-plugin.version>2.4</maven-jar-plugin.version>
Expand All @@ -93,6 +94,7 @@
<scala.version>2.10.4</scala.version>
<!-- scala.binary.version is used for projects that fetch dependencies that are in scala -->
<scala.binary.version>2.10</scala.binary.version>
<scala.maven.test.skip>false</scala.maven.test.skip>
<pig.version>0.11.1</pig.version>
<pig.classifier></pig.classifier>
</properties>
Expand Down Expand Up @@ -318,7 +320,7 @@
<configuration>
<argLine>-XX:MaxPermSize=256m</argLine>
<source>1.6</source>
<target>1.6</target>
<target>${targetJavaVersion}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Expand Down