Skip to content

Commit

Permalink
Remove unused ParquetTypeUtils#getPrestoType method
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi authored and nezihyigitbasi committed Mar 28, 2019
1 parent 451b994 commit 5bbc7b3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,8 @@
*/
package com.facebook.presto.parquet;

import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.predicate.Domain;
import com.facebook.presto.spi.predicate.TupleDomain;
import com.facebook.presto.spi.type.BigintType;
import com.facebook.presto.spi.type.BooleanType;
import com.facebook.presto.spi.type.DateType;
import com.facebook.presto.spi.type.DecimalType;
import com.facebook.presto.spi.type.DoubleType;
import com.facebook.presto.spi.type.RealType;
import com.facebook.presto.spi.type.TimestampType;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.spi.type.VarcharType;
import org.apache.parquet.column.ColumnDescriptor;
import org.apache.parquet.column.Encoding;
import org.apache.parquet.io.ColumnIO;
import org.apache.parquet.io.ColumnIOFactory;
Expand All @@ -36,7 +25,6 @@
import org.apache.parquet.io.PrimitiveColumnIO;
import org.apache.parquet.schema.DecimalMetadata;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.schema.OriginalType;

import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -45,8 +33,6 @@
import java.util.Map;
import java.util.Optional;

import static com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED;
import static com.facebook.presto.spi.type.IntegerType.INTEGER;
import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.parquet.schema.OriginalType.DECIMAL;
import static org.apache.parquet.schema.Type.Repetition.REPEATED;
Expand Down Expand Up @@ -159,46 +145,6 @@ private static int getPathIndex(List<PrimitiveColumnIO> columns, List<String> pa
return index;
}

public static Type getPrestoType(TupleDomain<ColumnDescriptor> effectivePredicate, RichColumnDescriptor descriptor)
{
switch (descriptor.getPrimitiveType().getPrimitiveTypeName()) {
case BOOLEAN:
return BooleanType.BOOLEAN;
case BINARY:
return createDecimalType(descriptor).orElse(createVarcharType(effectivePredicate, descriptor));
case FLOAT:
return RealType.REAL;
case DOUBLE:
return DoubleType.DOUBLE;
case INT32:
return getInt32Type(descriptor);
case INT64:
return createDecimalType(descriptor).orElse(BigintType.BIGINT);
case INT96:
return TimestampType.TIMESTAMP;
case FIXED_LEN_BYTE_ARRAY:
return createDecimalType(descriptor).orElseThrow(() -> new PrestoException(NOT_SUPPORTED, "Parquet type FIXED_LEN_BYTE_ARRAY supported as DECIMAL; got " + descriptor.getPrimitiveType().getOriginalType()));
default:
throw new PrestoException(NOT_SUPPORTED, "Unsupported parquet type: " + descriptor.getType());
}
}

private static Type createVarcharType(TupleDomain<ColumnDescriptor> effectivePredicate, RichColumnDescriptor column)
{
// We look at the effectivePredicate domain here, because it matches the Hive column type
// more accurately than the type available in the RichColumnDescriptor.
// For example, a Hive column of type varchar(length) is encoded as a Parquet BINARY, but
// when that is converted to a Presto Type the length information wasn't retained.
Optional<Map<ColumnDescriptor, Domain>> predicateDomains = effectivePredicate.getDomains();
if (predicateDomains.isPresent()) {
Domain domain = predicateDomains.get().get(column);
if (domain != null) {
return domain.getType();
}
}
return VarcharType.VARCHAR;
}

public static int getFieldIndex(MessageType fileSchema, String name)
{
try {
Expand Down Expand Up @@ -315,21 +261,4 @@ public static long getShortDecimalValue(byte[] bytes)

return value;
}

private static Type getInt32Type(RichColumnDescriptor descriptor)
{
OriginalType originalType = descriptor.getPrimitiveType().getOriginalType();
if (originalType == null) {
return INTEGER;
}

switch (originalType) {
case DECIMAL:
return createDecimalType(descriptor.getPrimitiveType().getDecimalMetadata());
case DATE:
return DateType.DATE;
default:
return INTEGER;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.facebook.presto.spi.type.Type;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.airlift.slice.Slice;
import io.airlift.slice.Slices;
import org.apache.parquet.column.ColumnDescriptor;
Expand All @@ -44,7 +43,6 @@
import java.util.Optional;
import java.util.function.Function;

import static com.facebook.presto.parquet.ParquetTypeUtils.getPrestoType;
import static com.facebook.presto.parquet.predicate.PredicateUtils.isStatisticsOverflow;
import static com.facebook.presto.spi.type.BigintType.BIGINT;
import static com.facebook.presto.spi.type.BooleanType.BOOLEAN;
Expand Down

This file was deleted.

0 comments on commit 5bbc7b3

Please sign in to comment.