@Override public ListenableFuture<?> execute(CreateTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters) { return internalExecute(statement, metadata, accessControl, stateMachine.getSession(), parameters); }
@Test public void testCreateTableNotExistsTrue() { CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), "BIGINT", emptyList(), Optional.empty())), true, ImmutableList.of(), Optional.empty()); getFutureValue(new CreateTableTask().internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList())); assertEquals(metadata.getCreateTableCallCount(), 1); }
@Test public void testCreateTableNotExistsFalse() { CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), "BIGINT", emptyList(), Optional.empty())), false, ImmutableList.of(), Optional.empty()); try { getFutureValue(new CreateTableTask().internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList())); fail("expected exception"); } catch (RuntimeException e) { // Expected assertTrue(e instanceof PrestoException); PrestoException prestoException = (PrestoException) e; assertEquals(prestoException.getErrorCode(), ALREADY_EXISTS.toErrorCode()); } assertEquals(metadata.getCreateTableCallCount(), 1); }