Search in sources :

Example 31 with QualifiedObjectName

use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.

the class TestCreateViewTask method testCreateViewOnTableIfExists.

@Test
public void testCreateViewOnTableIfExists() {
    QualifiedObjectName tableName = qualifiedObjectName("existing_table");
    metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeCreateView(asQualifiedName(tableName), false))).hasErrorCode(TABLE_ALREADY_EXISTS).hasMessage("Table already exists: '%s'", tableName, tableName);
}
Also used : QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Test(org.testng.annotations.Test)

Example 32 with QualifiedObjectName

use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.

the class TestCreateViewTask method testReplaceViewOnTableIfExists.

@Test
public void testReplaceViewOnTableIfExists() {
    QualifiedObjectName tableName = qualifiedObjectName("existing_table");
    metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeCreateView(asQualifiedName(tableName), true))).hasErrorCode(TABLE_ALREADY_EXISTS).hasMessage("Table already exists: '%s'", tableName, tableName);
}
Also used : QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Test(org.testng.annotations.Test)

Example 33 with QualifiedObjectName

use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.

the class TestDropMaterializedViewTask method testDropMaterializedViewOnTableIfExists.

@Test
public void testDropMaterializedViewOnTableIfExists() {
    QualifiedObjectName tableName = qualifiedObjectName("existing_table");
    metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
    getFutureValue(executeDropMaterializedView(asQualifiedName(tableName), true));
// no exception
}
Also used : QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Test(org.testng.annotations.Test)

Example 34 with QualifiedObjectName

use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.

the class TestDropTableTask method testDropExistingTable.

@Test
public void testDropExistingTable() {
    QualifiedObjectName tableName = qualifiedObjectName("not_existing_table");
    metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
    assertThat(metadata.getTableHandle(testSession, tableName)).isPresent();
    getFutureValue(executeDropTable(asQualifiedName(tableName), false));
    assertThat(metadata.getTableHandle(testSession, tableName)).isEmpty();
}
Also used : QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Test(org.testng.annotations.Test)

Example 35 with QualifiedObjectName

use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.

the class TestDropViewTask method testDropViewOnTable.

@Test
public void testDropViewOnTable() {
    QualifiedObjectName tableName = qualifiedObjectName("existing_table");
    metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeDropView(asQualifiedName(tableName), false))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("View '%s' does not exist, but a table with that name exists. Did you mean DROP TABLE %s?", tableName, tableName);
}
Also used : QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Test(org.testng.annotations.Test)

Aggregations

QualifiedObjectName (io.trino.metadata.QualifiedObjectName)142 ViewExpression (io.trino.spi.security.ViewExpression)51 Test (org.testng.annotations.Test)51 Test (org.junit.jupiter.api.Test)41 Session (io.trino.Session)40 TableHandle (io.trino.metadata.TableHandle)33 MetadataUtil.createQualifiedObjectName (io.trino.metadata.MetadataUtil.createQualifiedObjectName)24 Optional (java.util.Optional)20 Metadata (io.trino.metadata.Metadata)17 Map (java.util.Map)17 Objects.requireNonNull (java.util.Objects.requireNonNull)16 ImmutableList (com.google.common.collect.ImmutableList)15 List (java.util.List)15 ImmutableMap (com.google.common.collect.ImmutableMap)14 TrinoException (io.trino.spi.TrinoException)14 ImmutableSet (com.google.common.collect.ImmutableSet)13 ColumnHandle (io.trino.spi.connector.ColumnHandle)13 Type (io.trino.spi.type.Type)11 Set (java.util.Set)11 CatalogName (io.trino.connector.CatalogName)10