Search in sources :

Example 1 with TestingWarningCollectorConfig

use of com.facebook.presto.testing.TestingWarningCollectorConfig in project presto by prestodb.

the class TestTestingWarningCollector method testAddWarnings.

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

Example 2 with TestingWarningCollectorConfig

use of com.facebook.presto.testing.TestingWarningCollectorConfig in project presto by prestodb.

the class TestJdbcWarnings method testExecuteQueryWarnings.

@Test
public void testExecuteQueryWarnings() throws SQLException {
    try (ResultSet rs = statement.executeQuery("SELECT a FROM (VALUES 1, 2, 3) t(a)")) {
        assertNull(statement.getConnection().getWarnings());
        assertNull(statement.getWarnings());
        assertNull(rs.getWarnings());
        Set<WarningEntry> currentWarnings = new HashSet<>();
        while (rs.next()) {
            assertWarnings(rs.getWarnings(), currentWarnings);
        }
        TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS).setAddWarnings(true);
        TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
        List<PrestoWarning> expectedWarnings = warningCollector.getWarnings();
        for (PrestoWarning prestoWarning : expectedWarnings) {
            assertTrue(currentWarnings.contains(new WarningEntry(new PrestoSqlWarning(prestoWarning))));
        }
    }
}
Also used : TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) WarningCollectorConfig(com.facebook.presto.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) ResultSet(java.sql.ResultSet) PrestoWarning(com.facebook.presto.spi.PrestoWarning) TestingWarningCollector(com.facebook.presto.testing.TestingWarningCollector) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 3 with TestingWarningCollectorConfig

use of com.facebook.presto.testing.TestingWarningCollectorConfig in project presto by prestodb.

the class TestJdbcWarnings method testStatementWarnings.

@Test
public void testStatementWarnings() throws SQLException {
    assertFalse(statement.execute("CREATE SCHEMA blackhole.test_schema"));
    SQLWarning warning = statement.getWarnings();
    assertNotNull(warning);
    TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS);
    TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
    List<PrestoWarning> expectedWarnings = warningCollector.getWarnings();
    assertStartsWithExpectedWarnings(warning, fromPrestoWarnings(expectedWarnings));
    statement.clearWarnings();
    assertNull(statement.getWarnings());
}
Also used : SQLWarning(java.sql.SQLWarning) TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) WarningCollectorConfig(com.facebook.presto.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) PrestoWarning(com.facebook.presto.spi.PrestoWarning) TestingWarningCollector(com.facebook.presto.testing.TestingWarningCollector) Test(org.testng.annotations.Test)

Example 4 with TestingWarningCollectorConfig

use of com.facebook.presto.testing.TestingWarningCollectorConfig in project presto by prestodb.

the class AbstractAnalyzerTest method analyzeWithWarnings.

protected WarningCollector analyzeWithWarnings(@Language("SQL") String query) {
    WarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), new TestingWarningCollectorConfig());
    analyze(CLIENT_SESSION, warningCollector, query);
    return warningCollector;
}
Also used : TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) WarningCollectorConfig(com.facebook.presto.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) TestingWarningCollector(com.facebook.presto.testing.TestingWarningCollector) WarningCollector(com.facebook.presto.spi.WarningCollector) TestingWarningCollector(com.facebook.presto.testing.TestingWarningCollector)

Example 5 with TestingWarningCollectorConfig

use of com.facebook.presto.testing.TestingWarningCollectorConfig in project presto by prestodb.

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(PrestoWarning::getWarningCode).collect(toImmutableList()));
}
Also used : TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) WarningCollectorConfig(com.facebook.presto.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) PrestoWarning(com.facebook.presto.spi.PrestoWarning) TestingWarningCollector(com.facebook.presto.testing.TestingWarningCollector) Test(org.testng.annotations.Test)

Aggregations

TestingWarningCollector (com.facebook.presto.testing.TestingWarningCollector)5 TestingWarningCollectorConfig (com.facebook.presto.testing.TestingWarningCollectorConfig)5 WarningCollectorConfig (com.facebook.presto.execution.warnings.WarningCollectorConfig)4 PrestoWarning (com.facebook.presto.spi.PrestoWarning)4 Test (org.testng.annotations.Test)4 WarningCollector (com.facebook.presto.spi.WarningCollector)1 ImmutableList (com.google.common.collect.ImmutableList)1 ResultSet (java.sql.ResultSet)1 SQLWarning (java.sql.SQLWarning)1 HashSet (java.util.HashSet)1