Search in sources :

Example 6 with TrinoWarning

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

the class TestDefaultWarningCollector method testMaxWarnings.

@Test
public void testMaxWarnings() {
    WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig().setMaxWarnings(2));
    warningCollector.add(new TrinoWarning(new WarningCode(1, "1"), "warning 1"));
    warningCollector.add(new TrinoWarning(new WarningCode(2, "2"), "warning 2"));
    warningCollector.add(new TrinoWarning(new WarningCode(3, "3"), "warning 3"));
    assertEquals(warningCollector.getWarnings().size(), 2);
}
Also used : TrinoWarning(io.trino.spi.TrinoWarning) WarningCode(io.trino.spi.WarningCode) Test(org.testng.annotations.Test)

Example 7 with TrinoWarning

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

the class TestTestingWarningCollector method testAddWarnings.

@Test
public void testAddWarnings() {
    TestingWarningCollector collector = new TestingWarningCollector(new WarningCollectorConfig(), new TestingWarningCollectorConfig().setAddWarnings(true));
    ImmutableList.Builder<TrinoWarning> expectedWarningsBuilder = ImmutableList.builder();
    expectedWarningsBuilder.add(createTestWarning(1));
    assertEquals(collector.getWarnings(), expectedWarningsBuilder.build());
}
Also used : TestingWarningCollectorConfig(io.trino.testing.TestingWarningCollectorConfig) TestingWarningCollectorConfig(io.trino.testing.TestingWarningCollectorConfig) ImmutableList(com.google.common.collect.ImmutableList) TestingWarningCollector(io.trino.testing.TestingWarningCollector) TrinoWarning(io.trino.spi.TrinoWarning) Test(org.testng.annotations.Test)

Example 8 with TrinoWarning

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

the class TestDefaultWarningCollector method testNoWarnings.

@Test
public void testNoWarnings() {
    WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig().setMaxWarnings(0));
    warningCollector.add(new TrinoWarning(new WarningCode(1, "1"), "warning 1"));
    assertEquals(warningCollector.getWarnings().size(), 0);
}
Also used : TrinoWarning(io.trino.spi.TrinoWarning) WarningCode(io.trino.spi.WarningCode) Test(org.testng.annotations.Test)

Example 9 with TrinoWarning

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

the class TestJdbcWarnings method testSqlWarning.

@Test
public void testSqlWarning() {
    ImmutableList.Builder<TrinoWarning> builder = ImmutableList.builder();
    for (int i = 0; i < 3; i++) {
        builder.add(new TrinoWarning(new WarningCode(i, "CODE_" + i), "warning message " + i));
    }
    List<TrinoWarning> warnings = builder.build();
    SQLWarning warning = fromTrinoWarnings(warnings);
    assertEquals(Iterators.size(warning.iterator()), warnings.size());
    assertWarningsEqual(warning, toTrinoSqlWarning(warnings.get(0)));
    assertWarningsEqual(warning.getNextWarning(), toTrinoSqlWarning(warnings.get(1)));
    assertWarningsEqual(warning.getNextWarning().getNextWarning(), toTrinoSqlWarning(warnings.get(2)));
}
Also used : SQLWarning(java.sql.SQLWarning) ImmutableList(com.google.common.collect.ImmutableList) TrinoWarning(io.trino.spi.TrinoWarning) WarningCode(io.trino.spi.WarningCode) Test(org.testng.annotations.Test)

Example 10 with TrinoWarning

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

the class TestCompletedEventWarnings method testCompletedEventWarnings.

@Test
public void testCompletedEventWarnings() throws InterruptedException {
    TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(TEST_WARNINGS);
    TestingWarningCollector testingWarningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
    assertWarnings("select 1", ImmutableMap.of(), testingWarningCollector.getWarnings().stream().map(TrinoWarning::getWarningCode).collect(toImmutableList()));
}
Also used : WarningCollectorConfig(io.trino.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(io.trino.testing.TestingWarningCollectorConfig) TestingWarningCollectorConfig(io.trino.testing.TestingWarningCollectorConfig) TestingWarningCollector(io.trino.testing.TestingWarningCollector) TrinoWarning(io.trino.spi.TrinoWarning) Test(org.testng.annotations.Test)

Aggregations

TrinoWarning (io.trino.spi.TrinoWarning)10 Test (org.testng.annotations.Test)8 WarningCollectorConfig (io.trino.execution.warnings.WarningCollectorConfig)4 WarningCode (io.trino.spi.WarningCode)4 TestingWarningCollector (io.trino.testing.TestingWarningCollector)4 TestingWarningCollectorConfig (io.trino.testing.TestingWarningCollectorConfig)4 ImmutableList (com.google.common.collect.ImmutableList)3 SQLWarning (java.sql.SQLWarning)3 TrinoException (io.trino.spi.TrinoException)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 Session (io.trino.Session)1 DefaultWarningCollector (io.trino.execution.warnings.DefaultWarningCollector)1 WarningCollector (io.trino.execution.warnings.WarningCollector)1 Captures (io.trino.matching.Captures)1 Pattern (io.trino.matching.Pattern)1 TpchConnectorFactory (io.trino.plugin.tpch.TpchConnectorFactory)1