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 committed Feb 5, 2019
1 parent 7d2f5a9 commit 972fdec
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 130 deletions.
Expand Up @@ -13,19 +13,8 @@
*/
package io.prestosql.parquet;

import io.prestosql.spi.PrestoException;
import io.prestosql.spi.predicate.Domain;
import io.prestosql.spi.predicate.TupleDomain;
import io.prestosql.spi.type.BigintType;
import io.prestosql.spi.type.BooleanType;
import io.prestosql.spi.type.DateType;
import io.prestosql.spi.type.DecimalType;
import io.prestosql.spi.type.DoubleType;
import io.prestosql.spi.type.RealType;
import io.prestosql.spi.type.TimestampType;
import io.prestosql.spi.type.Type;
import io.prestosql.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 @@ -46,8 +34,6 @@
import java.util.Optional;

import static com.google.common.base.Preconditions.checkArgument;
import static io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED;
import static io.prestosql.spi.type.IntegerType.INTEGER;
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.getType()) {
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 @@ -316,21 +262,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;
}
}
}

This file was deleted.

0 comments on commit 972fdec

Please sign in to comment.