Search in sources :

Example 1 with CreateSchema

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));
}
Also used : CreateSchema(io.trino.sql.tree.CreateSchema) Test(org.testng.annotations.Test)

Example 2 with CreateSchema

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");
}
Also used : CreateSchema(io.trino.sql.tree.CreateSchema) Test(org.testng.annotations.Test)

Example 3 with CreateSchema

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()));
}
Also used : QueryUtil.quotedIdentifier(io.trino.sql.QueryUtil.quotedIdentifier) Identifier(io.trino.sql.tree.Identifier) StringLiteral(io.trino.sql.tree.StringLiteral) LongLiteral(io.trino.sql.tree.LongLiteral) CreateSchema(io.trino.sql.tree.CreateSchema) Property(io.trino.sql.tree.Property) Test(org.junit.jupiter.api.Test)

Aggregations

CreateSchema (io.trino.sql.tree.CreateSchema)3 Test (org.testng.annotations.Test)2 QueryUtil.quotedIdentifier (io.trino.sql.QueryUtil.quotedIdentifier)1 Identifier (io.trino.sql.tree.Identifier)1 LongLiteral (io.trino.sql.tree.LongLiteral)1 Property (io.trino.sql.tree.Property)1 StringLiteral (io.trino.sql.tree.StringLiteral)1 Test (org.junit.jupiter.api.Test)1