use of com.facebook.presto.spi.WarningCollector in project presto by prestodb.
the class TestPartialResultQueryTaskTracker method testPartialResultQueryTaskTracker.
@Test
public void testPartialResultQueryTaskTracker() throws Exception {
PartialResultQueryTaskTracker tracker = new PartialResultQueryTaskTracker(partialResultQueryManager, 0.50, 2.0, warningCollector);
InternalNode node1 = new InternalNode(UUID.randomUUID().toString(), URI.create("https://192.0.2.8"), new NodeVersion("1"), false, false);
InternalNode node2 = new InternalNode(UUID.randomUUID().toString(), URI.create("https://192.0.2.9"), new NodeVersion("1"), false, false);
TaskId taskId1 = new TaskId("test1", 1, 0, 1);
TaskId taskId2 = new TaskId("test2", 2, 0, 1);
RemoteTask task1 = taskFactory.createTableScanTask(taskId1, node1, ImmutableList.of(), new NodeTaskMap.NodeStatsTracker(delta -> {
}, delta -> {
}, (age, delta) -> {
}));
RemoteTask task2 = taskFactory.createTableScanTask(taskId2, node2, ImmutableList.of(), new NodeTaskMap.NodeStatsTracker(delta -> {
}, delta -> {
}, (age, delta) -> {
}));
tracker.trackTask(task1);
tracker.trackTask(task2);
// Assert that completion ratio is 0.0 since the tasks did not complete yet
assertEquals(0.0, tracker.getTaskCompletionRatio());
tracker.completeTaskScheduling();
tracker.recordTaskFinish(task1.getTaskInfo());
// Assert that completion ratio is 0.5 since we have set that task1 finished in above line
assertEquals(0.5, tracker.getTaskCompletionRatio());
// Assert that the query is added to query manager, queue size = 1 since the query reached minCompletion ratio of 0.5 and is eligible for partial results
assertEquals(1, partialResultQueryManager.getQueueSize());
// Sleep for 2 seconds so that we give enough time for query manager to cancel tasks and complete the query with partial results
Thread.sleep(2000);
assertEquals(0, partialResultQueryManager.getQueueSize());
// Assert that partial result warning is set correctly
assertEquals(1, warningCollector.getWarnings().size());
PrestoWarning prestoWarning = warningCollector.getWarnings().get(0);
// Assert that warning code is set to PARTIAL_RESULT_WARNING
assertEquals(PARTIAL_RESULT_WARNING.toWarningCode(), prestoWarning.getWarningCode());
// Assert that completion percent of 50.00 is specified correctly in the warning message
assertEquals("Partial results are returned. Only 50.00 percent of the data is read.", prestoWarning.getMessage());
}
use of com.facebook.presto.spi.WarningCollector 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.WarningCollector in project presto by prestodb.
the class TestAnalyzer method testUnionDistinctPerformanceWarning.
@Test
public void testUnionDistinctPerformanceWarning() {
WarningCollector warningCollector = analyzeWithWarnings("SELECT a,b,c,d FROM t8 UNION DISTINCT SELECT a,b,c,d FROM t9");
List<PrestoWarning> warnings = warningCollector.getWarnings();
assertEquals(warnings.size(), 1);
// Ensure warning is the performance warning we expect
PrestoWarning warning = warnings.get(0);
assertEquals(warning.getWarningCode(), PERFORMANCE_WARNING.toWarningCode());
assertTrue(warning.getMessage().startsWith("UNION DISTINCT"));
}
use of com.facebook.presto.spi.WarningCollector in project presto by prestodb.
the class TestAnalyzer method testCountDistinctPerformanceWarning.
@Test
public void testCountDistinctPerformanceWarning() {
WarningCollector warningCollector = analyzeWithWarnings("SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b");
List<PrestoWarning> warnings = warningCollector.getWarnings();
assertEquals(warnings.size(), 1);
// Ensure warning is the performance warning we expect
PrestoWarning warning = warnings.get(0);
assertEquals(warning.getWarningCode(), PERFORMANCE_WARNING.toWarningCode());
assertTrue(warning.getMessage().contains("COUNT(DISTINCT xxx)"));
}
use of com.facebook.presto.spi.WarningCollector in project presto by prestodb.
the class TestAnalyzer method testUnionNoPerformanceWarning.
@Test
public void testUnionNoPerformanceWarning() {
// <= 3 fields
WarningCollector warningCollector = analyzeWithWarnings("SELECT a,b,c FROM t8 UNION DISTINCT SELECT a,b,c FROM t9");
assertTrue(warningCollector.getWarnings().isEmpty());
// > 3 fields, no expensive types
// warningCollector = analyzeWithWarnings("SELECT a,b,c,d FROM t1 UNION DISTINCT SELECT a,b,c,d FROM t1");
assertTrue(warningCollector.getWarnings().isEmpty());
// > 3 fields, expensive types, not distinct
warningCollector = analyzeWithWarnings("SELECT a,b,c,d FROM t8 UNION ALL SELECT a,b,c,d FROM t9");
assertTrue(warningCollector.getWarnings().isEmpty());
}
Aggregations