use of com.facebook.presto.common.type.UserDefinedType in project presto by prestodb.
the class FunctionAndTypeManager method getUserDefinedType.
private Type getUserDefinedType(TypeSignature signature) {
Optional<FunctionNamespaceManager<?>> functionNamespaceManager = getServingFunctionNamespaceManager(signature.getTypeSignatureBase());
checkArgument(functionNamespaceManager.isPresent(), "Cannot find function namespace for type '%s'", signature.getBase());
UserDefinedType userDefinedType = functionNamespaceManager.get().getUserDefinedType(signature.getTypeSignatureBase().getTypeName()).orElseThrow(() -> new IllegalArgumentException("Unknown type " + signature));
checkArgument(userDefinedType.getPhysicalTypeSignature().getTypeSignatureBase().hasStandardType(), "A UserDefinedType must be based on static types.");
return getType(userDefinedType);
}
use of com.facebook.presto.common.type.UserDefinedType in project presto by prestodb.
the class CreateTypeTask method execute.
@Override
public ListenableFuture<?> execute(CreateType statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector) {
TypeSignature signature;
if (statement.getDistinctType().isPresent()) {
signature = new TypeSignature(statement.getDistinctType().get());
} else {
List<TypeSignatureParameter> typeParameters = Streams.zip(statement.getParameterNames().stream(), statement.getParameterTypes().stream(), (name, type) -> TypeSignatureParameter.of(new NamedTypeSignature(Optional.of(new RowFieldName(name, false)), parseTypeSignature(type)))).collect(toImmutableList());
signature = new TypeSignature(ROW, typeParameters);
}
UserDefinedType userDefinedType = new UserDefinedType(QualifiedObjectName.valueOf(statement.getTypeName().toString()), signature);
metadata.getFunctionAndTypeManager().addUserDefinedType(userDefinedType);
return immediateFuture(null);
}
use of com.facebook.presto.common.type.UserDefinedType in project presto by prestodb.
the class UserDefinedTypeRowMapper method map.
@Override
public UserDefinedType map(ResultSet rs, StatementContext ctx) throws SQLException {
QualifiedObjectName typeName = QualifiedObjectName.valueOf(rs.getString("catalog_name"), rs.getString("schema_name"), rs.getString("type_name"));
String physicalType = rs.getString("physical_type");
TypeSignature typeSignature = parseTypeSignature(physicalType);
return new UserDefinedType(typeName, typeSignature);
}
Aggregations