use of com.facebook.presto.spi.WarningCode in project presto by prestodb.
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(PrestoWarning::getWarningCode).collect(toImmutableSet());
for (WarningCode warningCode : expectedWarnings) {
if (!warnings.contains(warningCode)) {
fail("Expected warning: " + warningCode);
}
}
}
use of com.facebook.presto.spi.WarningCode in project presto by prestodb.
the class TestDefaultWarningCollector method testWarningAsErrorThrowsException.
@Test(expectedExceptions = { PrestoException.class })
public void testWarningAsErrorThrowsException() {
WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig(), WarningHandlingLevel.AS_ERROR);
warningCollector.add(new PrestoWarning(new WarningCode(1, "1"), "warning 1"));
}
use of com.facebook.presto.spi.WarningCode in project presto by prestodb.
the class TestPlannerWarnings method assertPlannerWarnings.
public static void assertPlannerWarnings(LocalQueryRunner queryRunner, @Language("SQL") String sql, Map<String, String> sessionProperties, List<WarningCode> expectedWarnings, Optional<List<Rule<?>>> rules) {
Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog(queryRunner.getDefaultSession().getCatalog().get()).setSchema(queryRunner.getDefaultSession().getSchema().get());
sessionProperties.forEach(sessionBuilder::setSystemProperty);
WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig(), WarningHandlingLevel.NORMAL);
try {
queryRunner.inTransaction(sessionBuilder.build(), transactionSession -> {
if (rules.isPresent()) {
createPlan(queryRunner, transactionSession, sql, warningCollector, rules.get());
} else {
queryRunner.createPlan(transactionSession, sql, LogicalPlanner.Stage.CREATED, false, warningCollector);
}
return null;
});
} catch (SemanticException e) {
// ignore
}
Set<WarningCode> warnings = warningCollector.getWarnings().stream().map(PrestoWarning::getWarningCode).collect(toImmutableSet());
for (WarningCode expectedWarning : expectedWarnings) {
if (!warnings.contains(expectedWarning)) {
fail("Expected warning: " + expectedWarning);
}
}
}
use of com.facebook.presto.spi.WarningCode in project presto by prestodb.
the class TestPlannerWarnings method createTestWarnings.
public static List<PrestoWarning> createTestWarnings(int numberOfWarnings) {
checkArgument(numberOfWarnings > 0, "numberOfWarnings must be > 0");
ImmutableList.Builder<PrestoWarning> builder = ImmutableList.builder();
range(1, numberOfWarnings).mapToObj(code -> new PrestoWarning(new WarningCode(code, "testWarning"), "Test warning " + code)).forEach(builder::add);
return builder.build();
}
use of com.facebook.presto.spi.WarningCode in project presto by prestodb.
the class TestJdbcWarnings method testSqlWarning.
@Test
public void testSqlWarning() {
ImmutableList.Builder<PrestoWarning> builder = ImmutableList.builder();
for (int i = 0; i < 3; i++) {
builder.add(new PrestoWarning(new WarningCode(i, "CODE_" + i), "warning message " + i));
}
List<PrestoWarning> warnings = builder.build();
SQLWarning warning = fromPrestoWarnings(warnings);
assertEquals(Iterators.size(warning.iterator()), warnings.size());
assertWarningsEqual(warning, new PrestoSqlWarning(warnings.get(0)));
assertWarningsEqual(warning.getNextWarning(), new PrestoSqlWarning(warnings.get(1)));
assertWarningsEqual(warning.getNextWarning().getNextWarning(), new PrestoSqlWarning(warnings.get(2)));
}
Aggregations