Search in sources :

Example 6 with WarningCode

use of io.trino.spi.WarningCode in project trino by trinodb.

the class TestCompletedEventWarnings method assertWarnings.

private void assertWarnings(@Language("SQL") String sql, Map<String, String> sessionProperties, List<WarningCode> expectedWarnings) throws InterruptedException {
    // Task concurrency must be 1 otherwise these tests fail due to change in the number of EXPECTED_EVENTS
    SessionBuilder sessionBuilder = testSessionBuilder().setSystemProperty("task_concurrency", "1");
    sessionProperties.forEach(sessionBuilder::setSystemProperty);
    queryRunner.execute(sessionBuilder.build(), sql);
    generatedEvents.waitForEvents(10);
    Set<WarningCode> warnings = getOnlyElement(generatedEvents.getQueryCompletedEvents()).getWarnings().stream().map(TrinoWarning::getWarningCode).collect(toImmutableSet());
    for (WarningCode warningCode : expectedWarnings) {
        if (!warnings.contains(warningCode)) {
            fail("Expected warning: " + warningCode);
        }
    }
}
Also used : TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) SessionBuilder(io.trino.Session.SessionBuilder) WarningCode(io.trino.spi.WarningCode)

Aggregations

WarningCode (io.trino.spi.WarningCode)6 TrinoWarning (io.trino.spi.TrinoWarning)4 Test (org.testng.annotations.Test)4 ImmutableList (com.google.common.collect.ImmutableList)2 Session (io.trino.Session)2 DefaultWarningCollector (io.trino.execution.warnings.DefaultWarningCollector)2 WarningCollector (io.trino.execution.warnings.WarningCollector)2 WarningCollectorConfig (io.trino.execution.warnings.WarningCollectorConfig)2 TrinoException (io.trino.spi.TrinoException)2 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)1 SessionBuilder (io.trino.Session.SessionBuilder)1 Captures (io.trino.matching.Captures)1 Pattern (io.trino.matching.Pattern)1 TpchConnectorFactory (io.trino.plugin.tpch.TpchConnectorFactory)1 OPTIMIZED (io.trino.sql.planner.LogicalPlanner.Stage.OPTIMIZED)1