use of io.prestosql.spi.WarningCode in project hetu-core by openlookeng.
the class TestDefaultWarningCollector method testMaxWarnings.
@Test
public void testMaxWarnings() {
WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig().setMaxWarnings(2));
warningCollector.add(new PrestoWarning(new WarningCode(1, "1"), "warning 1"));
warningCollector.add(new PrestoWarning(new WarningCode(2, "2"), "warning 2"));
warningCollector.add(new PrestoWarning(new WarningCode(3, "3"), "warning 3"));
assertEquals(warningCollector.getWarnings().size(), 2);
}
use of io.prestosql.spi.WarningCode in project hetu-core by openlookeng.
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, toPrestoSqlWarning(warnings.get(0)));
assertWarningsEqual(warning.getNextWarning(), toPrestoSqlWarning(warnings.get(1)));
assertWarningsEqual(warning.getNextWarning().getNextWarning(), toPrestoSqlWarning(warnings.get(2)));
}
use of io.prestosql.spi.WarningCode in project hetu-core by openlookeng.
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());
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 io.prestosql.spi.WarningCode in project hetu-core by openlookeng.
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 io.prestosql.spi.WarningCode in project hetu-core by openlookeng.
the class TestDefaultWarningCollector method testNoWarnings.
@Test
public void testNoWarnings() {
WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig().setMaxWarnings(0));
warningCollector.add(new PrestoWarning(new WarningCode(1, "1"), "warning 1"));
assertEquals(warningCollector.getWarnings().size(), 0);
}
Aggregations