Search in sources :

Example 1 with QualifiedName

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

the class ExpressionAnalyzer method isPatternRecognitionFunction.

public static boolean isPatternRecognitionFunction(FunctionCall node) {
    QualifiedName qualifiedName = node.getName();
    if (qualifiedName.getParts().size() > 1) {
        return false;
    }
    Identifier identifier = qualifiedName.getOriginalParts().get(0);
    if (identifier.isDelimited()) {
        return false;
    }
    String name = identifier.getValue().toUpperCase(ENGLISH);
    return name.equals("FIRST") || name.equals("LAST") || name.equals("PREV") || name.equals("NEXT") || name.equals("CLASSIFIER") || name.equals("MATCH_NUMBER");
}
Also used : Identifier(io.trino.sql.tree.Identifier) QualifiedName(io.trino.sql.tree.QualifiedName)

Example 2 with QualifiedName

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

the class TestRenameViewTask method testRenameNotExistingView.

@Test
public void testRenameNotExistingView() {
    QualifiedName viewName = qualifiedName("not_existing_view");
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameView(viewName, qualifiedName("not_existing_view_new")))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("View '%s' does not exist", viewName);
}
Also used : QualifiedName(io.trino.sql.tree.QualifiedName) Test(org.testng.annotations.Test)

Example 3 with QualifiedName

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

the class TestRenameMaterializedViewTask method testRenameMaterializedViewOnView.

@Test
public void testRenameMaterializedViewOnView() {
    QualifiedName viewName = qualifiedName("existing_view");
    metadata.createView(testSession, QualifiedObjectName.valueOf(viewName.toString()), someView(), false);
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameMaterializedView(viewName, qualifiedName("existing_view_new")))).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 4 with QualifiedName

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

the class TestRenameMaterializedViewTask method testRenameNotExistingMaterializedViewIfExists.

@Test
public void testRenameNotExistingMaterializedViewIfExists() {
    QualifiedName materializedViewName = qualifiedName("not_existing_materialized_view");
    getFutureValue(executeRenameMaterializedView(materializedViewName, qualifiedName("not_existing_materialized_view_new"), true));
// no exception
}
Also used : QualifiedName(io.trino.sql.tree.QualifiedName) Test(org.testng.annotations.Test)

Example 5 with QualifiedName

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

the class TestRenameTableTask method testRenameTableOnMaterializedView.

@Test
public void testRenameTableOnMaterializedView() {
    QualifiedName viewName = qualifiedName("existing_materialized_view");
    metadata.createMaterializedView(testSession, QualifiedObjectName.valueOf(viewName.toString()), someMaterializedView(), false, false);
    assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameTable(viewName, qualifiedName("existing_materialized_view_new"), false))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("Table '%s' does not exist, but a materialized view with that name exists. Did you mean ALTER MATERIALIZED VIEW catalog.schema.existing_materialized_view RENAME ...?", viewName);
}
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