Search in sources :

Example 26 with QualifiedName

use of io.trino.sql.tree.QualifiedName in project trino by trinodb.

the class TestDropViewTask method testDropViewOnMaterializedViewIfExists.

@Test
public void testDropViewOnMaterializedViewIfExists() {
    QualifiedName viewName = qualifiedName("existing_materialized_view");
    metadata.createMaterializedView(testSession, QualifiedObjectName.valueOf(viewName.toString()), someMaterializedView(), false, false);
    getFutureValue(executeDropView(viewName, true));
// no exception
}
Also used : QualifiedName(io.trino.sql.tree.QualifiedName) Test(org.testng.annotations.Test)

Example 27 with QualifiedName

use of io.trino.sql.tree.QualifiedName in project trino by trinodb.

the class TestRenameMaterializedViewTask method testRenameMaterializedViewOnViewIfExists.

@Test
public void testRenameMaterializedViewOnViewIfExists() {
    QualifiedName viewName = qualifiedName("existing_view");
    metadata.createView(testSession, QualifiedObjectName.valueOf(viewName.toString()), someView(), false);
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameMaterializedView(viewName, qualifiedName("existing_view_new"), true))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("Materialized View '%s' does not exist, but a view with that name exists. Did you mean ALTER VIEW catalog.schema.existing_view RENAME ...?", viewName);
}
Also used : QualifiedName(io.trino.sql.tree.QualifiedName) Test(org.testng.annotations.Test)

Example 28 with QualifiedName

use of io.trino.sql.tree.QualifiedName in project trino by trinodb.

the class TestRenameMaterializedViewTask method testRenameNotExistingMaterializedView.

@Test
public void testRenameNotExistingMaterializedView() {
    QualifiedName materializedViewName = qualifiedName("not_existing_materialized_view");
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameMaterializedView(materializedViewName, qualifiedName("not_existing_materialized_view_new")))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("Materialized View '%s' does not exist", materializedViewName);
}
Also used : QualifiedName(io.trino.sql.tree.QualifiedName) Test(org.testng.annotations.Test)

Example 29 with QualifiedName

use of io.trino.sql.tree.QualifiedName in project trino by trinodb.

the class TestRenameMaterializedViewTask method testRenameMaterializedViewTargetViewExists.

@Test
public void testRenameMaterializedViewTargetViewExists() {
    QualifiedObjectName materializedViewName = qualifiedObjectName("existing_materialized_view");
    metadata.createMaterializedView(testSession, materializedViewName, someMaterializedView(), false, false);
    QualifiedName viewName = qualifiedName("existing_view");
    metadata.createView(testSession, QualifiedObjectName.valueOf(viewName.toString()), someView(), false);
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameMaterializedView(asQualifiedName(materializedViewName), viewName))).hasErrorCode(TABLE_ALREADY_EXISTS).hasMessage("Target materialized view '%s' does not exist, but a view with that name exists.", viewName);
}
Also used : QualifiedName(io.trino.sql.tree.QualifiedName) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Test(org.testng.annotations.Test)

Example 30 with QualifiedName

use of io.trino.sql.tree.QualifiedName in project trino by trinodb.

the class TestRenameTableTask method testRenameNotExistingTable.

@Test
public void testRenameNotExistingTable() {
    QualifiedName tableName = qualifiedName("not_existing_table");
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameTable(tableName, qualifiedName("not_existing_table_new"), false))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("Table '%s' does not exist", tableName);
}
Also used : QualifiedName(io.trino.sql.tree.QualifiedName) Test(org.testng.annotations.Test)

Aggregations

QualifiedName (io.trino.sql.tree.QualifiedName)42 Test (org.testng.annotations.Test)29 ComparisonExpression (io.trino.sql.tree.ComparisonExpression)7 FunctionCall (io.trino.sql.tree.FunctionCall)7 Identifier (io.trino.sql.tree.Identifier)7 ImmutableList (com.google.common.collect.ImmutableList)4 AllColumns (io.trino.sql.tree.AllColumns)4 Test (org.junit.jupiter.api.Test)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 MetadataManager.createTestMetadataManager (io.trino.metadata.MetadataManager.createTestMetadataManager)3 ResolvedFunction (io.trino.metadata.ResolvedFunction)3 ASC_NULLS_LAST (io.trino.spi.connector.SortOrder.ASC_NULLS_LAST)3 BIGINT (io.trino.spi.type.BigintType.BIGINT)3 QueryUtil.quotedIdentifier (io.trino.sql.QueryUtil.quotedIdentifier)3 TypeSignatureProvider.fromTypes (io.trino.sql.analyzer.TypeSignatureProvider.fromTypes)3 OrderingScheme (io.trino.sql.planner.OrderingScheme)3 PlanMatchPattern.functionCall (io.trino.sql.planner.assertions.PlanMatchPattern.functionCall)3 PlanMatchPattern.patternRecognition (io.trino.sql.planner.assertions.PlanMatchPattern.patternRecognition)3 PlanMatchPattern.specification (io.trino.sql.planner.assertions.PlanMatchPattern.specification)3