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 @@ -58,7 +58,6 @@ public final class StandardTypes
public static final String VARCHAR_ENUM = "VarcharEnum";
public static final String DISTINCT_TYPE = "DistinctType";
public static final String UUID = "uuid";
public static final String UNKNOWN = "unknown";

private StandardTypes() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package com.facebook.presto.common.type;

import java.util.Collection;
import java.util.List;

public interface TypeManager
Expand All @@ -29,19 +28,4 @@ public interface TypeManager
Type getParameterizedType(String baseTypeName, List<TypeSignatureParameter> typeParameters);

boolean canCoerce(Type actualType, Type expectedType);

default Type instantiateParametricType(TypeSignature typeSignature)
{
throw new UnsupportedOperationException();
}

List<Type> getTypes();

/**
* Gets all registered parametric types.
*/
default Collection<ParametricType> getParametricTypes()
{
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public boolean canCoerce(Type actualType, Type expectedType)
throw new UnsupportedOperationException();
}

@Override
public List<Type> getTypes()
private List<Type> getTypes()
{
return ImmutableList.of(BOOLEAN, INTEGER, BIGINT, DOUBLE, VARCHAR, VARBINARY, TIMESTAMP, DATE, ID, HYPER_LOG_LOG);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public boolean canCoerce(Type actualType, Type expectedType)
throw new UnsupportedOperationException();
}

@Override
public List<Type> getTypes()
private List<Type> getTypes()
{
return ImmutableList.of(BOOLEAN, INTEGER, BIGINT, DOUBLE, VARCHAR, VARBINARY, TIMESTAMP, DATE, HYPER_LOG_LOG);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ public boolean canCoerce(Type actualType, Type expectedType)
throw new UnsupportedOperationException();
}

@Override
public List<Type> getTypes()
private List<Type> getTypes()
{
return ImmutableList.of(BooleanType.BOOLEAN, INTEGER, BIGINT, DoubleType.DOUBLE, VARCHAR, VARBINARY, TIMESTAMP, DATE, HYPER_LOG_LOG);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.facebook.presto.execution;

import com.facebook.presto.Session;
import com.facebook.presto.UnknownTypeException;
import com.facebook.presto.common.QualifiedObjectName;
import com.facebook.presto.common.type.Type;
import com.facebook.presto.metadata.Metadata;
Expand Down Expand Up @@ -89,7 +88,7 @@ public ListenableFuture<?> execute(AddColumn statement, TransactionManager trans
try {
type = metadata.getType(parseTypeSignature(element.getType()));
}
catch (UnknownTypeException e) {
catch (IllegalArgumentException e) {
throw new SemanticException(TYPE_MISMATCH, element, "Unknown type '%s' for column '%s'", element.getType(), element.getName());
}
if (type.equals(UNKNOWN)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.facebook.presto.execution;

import com.facebook.presto.Session;
import com.facebook.presto.UnknownTypeException;
import com.facebook.presto.common.QualifiedObjectName;
import com.facebook.presto.common.type.Type;
import com.facebook.presto.metadata.Metadata;
Expand Down Expand Up @@ -126,7 +125,7 @@ public ListenableFuture<?> internalExecute(CreateTable statement, Metadata metad
try {
type = metadata.getType(parseTypeSignature(column.getType()));
}
catch (UnknownTypeException e) {
catch (IllegalArgumentException e) {
throw new SemanticException(TYPE_MISMATCH, element, "Unknown type '%s' for column '%s'", column.getType(), column.getName());
}
if (type.equals(UNKNOWN)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package com.facebook.presto.metadata;

import com.facebook.presto.UnknownTypeException;
import com.facebook.presto.common.CatalogSchemaName;
import com.facebook.presto.common.Page;
import com.facebook.presto.common.QualifiedObjectName;
Expand Down Expand Up @@ -532,7 +531,7 @@

@ThreadSafe
public class BuiltInTypeAndFunctionNamespaceManager
implements FunctionNamespaceManager<SqlFunction>, TypeManager
implements FunctionNamespaceManager<SqlFunction>
{
public static final CatalogSchemaName JAVA_BUILTIN_NAMESPACE = new CatalogSchemaName("presto", "default");
public static final String ID = "builtin";
Expand Down Expand Up @@ -1262,34 +1261,21 @@ public ScalarFunctionImplementation getScalarFunctionImplementation(Signature si
}
}

@Override
public Type getType(TypeSignature typeSignature)
public Optional<Type> getType(TypeSignature typeSignature)
{
Type type = types.get(typeSignature);
if (type != null) {
return type;
return Optional.of(type);
}
try {
return parametricTypeCache.getUnchecked(new ExactTypeSignature(typeSignature));
return Optional.ofNullable(parametricTypeCache.getUnchecked(new ExactTypeSignature(typeSignature)));
}
catch (UncheckedExecutionException e) {
throwIfUnchecked(e.getCause());
throw new RuntimeException(e.getCause());
}
}

@Override
public Type getParameterizedType(String baseTypeName, List<TypeSignatureParameter> typeParameters)
{
throw new UnsupportedOperationException();
}

@Override
public boolean canCoerce(Type actualType, Type expectedType)
{
throw new UnsupportedOperationException();
}

public List<Type> getTypes()
{
return ImmutableList.copyOf(types.values());
Expand All @@ -1309,22 +1295,14 @@ public void addParametricType(ParametricType parametricType)
parametricTypes.putIfAbsent(name, parametricType);
}

@Override
public Collection<ParametricType> getParametricTypes()
{
return parametricTypes.values();
}

private Type instantiateParametricType(ExactTypeSignature exactTypeSignature)
{
return instantiateParametricType(exactTypeSignature.getTypeSignature(), functionAndTypeManager, parametricTypes);
}

public Type instantiateParametricType(
TypeSignature signature,
FunctionAndTypeManager functionAndTypeManager,
Map<String, ParametricType> parametricTypes)
private Type instantiateParametricType(ExactTypeSignature exactSignature)
{
TypeSignature signature = exactSignature.getTypeSignature();
List<TypeParameter> parameters = new ArrayList<>();

for (TypeSignatureParameter parameter : signature.getParameters()) {
Expand All @@ -1334,7 +1312,7 @@ public Type instantiateParametricType(

ParametricType parametricType = parametricTypes.get(signature.getBase().toLowerCase(Locale.ENGLISH));
if (parametricType == null) {
throw new UnknownTypeException(signature);
throw new IllegalArgumentException("Unknown type " + signature);
}

if (parametricType instanceof MapParametricType) {
Expand Down
Loading
Loading