Skip to content

Commit

Permalink
Fix handling of missing columns in Parquet Reader
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenxiao authored and dain committed Feb 16, 2016
1 parent 251f3ef commit 40b024a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static com.facebook.presto.hive.HiveUtil.bigintPartitionKey;
import static com.facebook.presto.hive.HiveUtil.booleanPartitionKey;
import static com.facebook.presto.hive.HiveUtil.doublePartitionKey;
import static com.facebook.presto.hive.parquet.ParquetTypeUtils.getParquetType;
import static com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
Expand Down Expand Up @@ -84,14 +85,16 @@ class ParquetPageSource

public ParquetPageSource(
ParquetReader parquetReader,
MessageType fileSchema,
MessageType requestedSchema,
Path path,
long totalBytes,
Properties splitSchema,
List<HiveColumnHandle> columns,
List<HivePartitionKey> partitionKeys,
TupleDomain<HiveColumnHandle> effectivePredicate,
TypeManager typeManager)
TypeManager typeManager,
boolean useParquetColumnNames)
{
requireNonNull(path, "path is null");
checkArgument(totalBytes >= 0, "totalBytes is negative");
Expand Down Expand Up @@ -173,6 +176,13 @@ else if (type.equals(VarcharType.VARCHAR)) {

constantBlocks[columnIndex] = blockBuilder.build();
}
else if (getParquetType(column, fileSchema, useParquetColumnNames) == null) {
BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), MAX_VECTOR_LENGTH);
for (int i = 0; i < MAX_VECTOR_LENGTH; i++) {
blockBuilder.appendNull();
}
constantBlocks[columnIndex] = blockBuilder.build();
}
}
types = typesBuilder.build();
columnNames = namesBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,16 @@ public static ParquetPageSource createParquetPageSource(
dataSource);

return new ParquetPageSource(parquetReader,
fileSchema,
requestedSchema,
path,
length,
schema,
columns,
partitionKeys,
effectivePredicate,
typeManager);
typeManager,
useParquetColumnNames);
}
catch (Exception e) {
try {
Expand Down

0 comments on commit 40b024a

Please sign in to comment.