本文整理汇总了Java中com.facebook.presto.sql.tree.CreateTable.isNotExists方法的典型用法代码示例。如果您正苦于以下问题:Java CreateTable.isNotExists方法的具体用法?Java CreateTable.isNotExists怎么用?Java CreateTable.isNotExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.presto.sql.tree.CreateTable
的用法示例。
在下文中一共展示了CreateTable.isNotExists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitCreateTable
import com.facebook.presto.sql.tree.CreateTable; //导入方法依赖的package包/类
@Override
protected Void visitCreateTable(CreateTable node, Integer indent)
{
builder.append("CREATE TABLE ");
if (node.isNotExists()) {
builder.append("IF NOT EXISTS ");
}
builder.append(node.getName())
.append(" (");
Joiner.on(", ").appendTo(builder, transform(node.getElements(),
element -> element.getName() + " " + element.getType()));
builder.append(")");
if (!node.getProperties().isEmpty()) {
builder.append(" WITH (");
Joiner.on(", ").appendTo(builder, transform(node.getProperties().entrySet(),
entry -> entry.getKey() + " = " + formatExpression(entry.getValue())));
builder.append(")");
}
return null;
}
示例2: execute
import com.facebook.presto.sql.tree.CreateTable; //导入方法依赖的package包/类
@Override
public CompletableFuture<?> execute(CreateTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
{
checkArgument(!statement.getElements().isEmpty(), "no columns for table");
Session session = stateMachine.getSession();
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getName());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
if (tableHandle.isPresent()) {
if (!statement.isNotExists()) {
throw new SemanticException(TABLE_ALREADY_EXISTS, statement, "Table '%s' already exists", tableName);
}
return completedFuture(null);
}
List<ColumnMetadata> columns = new ArrayList<>();
for (TableElement element : statement.getElements()) {
Type type = metadata.getType(parseTypeSignature(element.getType()));
if ((type == null) || type.equals(UNKNOWN)) {
throw new SemanticException(TYPE_MISMATCH, element, "Unknown type for column '%s' ", element.getName());
}
columns.add(new ColumnMetadata(element.getName(), type, false));
}
accessControl.checkCanCreateTable(session.getRequiredTransactionId(), session.getIdentity(), tableName);
Map<String, Object> properties = metadata.getTablePropertyManager().getTableProperties(
tableName.getCatalogName(),
statement.getProperties(),
session,
metadata);
TableMetadata tableMetadata = new TableMetadata(
tableName.getCatalogName(),
new ConnectorTableMetadata(tableName.asSchemaTableName(), columns, properties, session.getUser(), false));
metadata.createTable(session, tableName.getCatalogName(), tableMetadata);
return completedFuture(null);
}