use of com.facebook.presto.sql.tree.CreateType 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);
}
Aggregations