Skip to content

Commit

Permalink
Fix out of order Pig partition fields (apache#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcweeks authored and rdblue committed Jul 30, 2019
1 parent f4fc8ff commit 08e0873
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,16 @@ private boolean advance() throws IOException {
if (hasJoinedPartitionColumns) {

Schema readSchema = TypeUtil.selectNot(projectedSchema, idColumns);
Schema partitionSchema = TypeUtil.select(tableSchema, idColumns);
Schema projectedPartitionSchema = TypeUtil.select(projectedSchema, idColumns);

Map<String, Integer> partitionSpecFieldIndexMap = Maps.newHashMap();
for(int i=0; i<spec.fields().size(); i++) {
partitionSpecFieldIndexMap.put(spec.fields().get(i).name(), i);
}

for (Types.NestedField field : projectedPartitionSchema.columns()) {
int tupleIndex = projectedSchema.columns().indexOf(field);
int partitionIndex = partitionSchema.columns().indexOf(field);
int partitionIndex = partitionSpecFieldIndexMap.get(field.name());

Object partitionValue = file.partition().get(partitionIndex, Object.class);
partitionValueMap.put(tupleIndex, convertPartitionValue(field.type(), partitionValue));
Expand Down

0 comments on commit 08e0873

Please sign in to comment.