use of io.trino.sql.tree.CreateSchema in project trino by trinodb.
the class TestCreateSchemaTask method testDuplicatedCreateSchemaIfNotExists.
@Test
public void testDuplicatedCreateSchemaIfNotExists() {
CreateSchemaTask task = getCreateSchemaTask();
CreateSchema statement = new CreateSchema(QualifiedName.of(CATALOG_SCHEMA_NAME.getSchemaName()), true, ImmutableList.of());
getFutureValue(task.execute(statement, queryStateMachine, emptyList(), WarningCollector.NOOP));
assertTrue(metadata.schemaExists(testSession, CATALOG_SCHEMA_NAME));
getFutureValue(task.execute(statement, queryStateMachine, emptyList(), WarningCollector.NOOP));
assertTrue(metadata.schemaExists(testSession, CATALOG_SCHEMA_NAME));
}
use of io.trino.sql.tree.CreateSchema in project trino by trinodb.
the class TestCreateSchemaTask method testDuplicatedCreateSchema.
@Test
public void testDuplicatedCreateSchema() {
CreateSchemaTask task = getCreateSchemaTask();
CreateSchema statement = new CreateSchema(QualifiedName.of(CATALOG_SCHEMA_NAME.getSchemaName()), false, ImmutableList.of());
getFutureValue(task.execute(statement, queryStateMachine, emptyList(), WarningCollector.NOOP));
assertTrue(metadata.schemaExists(testSession, CATALOG_SCHEMA_NAME));
assertThatExceptionOfType(TrinoException.class).isThrownBy(() -> getFutureValue(task.execute(statement, queryStateMachine, emptyList(), WarningCollector.NOOP))).withMessage("Schema 'catalog.test_db' already exists");
}
use of io.trino.sql.tree.CreateSchema in project trino by trinodb.
the class TestSqlParser method testCreateSchema.
@Test
public void testCreateSchema() {
assertStatement("CREATE SCHEMA test", new CreateSchema(QualifiedName.of("test"), false, ImmutableList.of()));
assertStatement("CREATE SCHEMA IF NOT EXISTS test", new CreateSchema(QualifiedName.of("test"), true, ImmutableList.of()));
assertStatement("CREATE SCHEMA test WITH (a = 'apple', b = 123)", new CreateSchema(QualifiedName.of("test"), false, ImmutableList.of(new Property(new Identifier("a"), new StringLiteral("apple")), new Property(new Identifier("b"), new LongLiteral("123")))));
assertStatement("CREATE SCHEMA \"some name that contains space\"", new CreateSchema(QualifiedName.of("some name that contains space"), false, ImmutableList.of()));
}
Aggregations