use of com.facebook.presto.spi.PrestoWarning 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());
}
use of com.facebook.presto.spi.PrestoWarning 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.PrestoWarning 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.PrestoWarning in project presto by prestodb.
the class PartialResultQueryTaskTracker method cancelUnfinishedTasks.
public void cancelUnfinishedTasks() {
SetView<TaskId> pendingTaskIds = difference(taskIdMap.keySet(), completedTaskIds);
double partialResultPercentage = getTaskCompletionRatio() * 100;
for (TaskId taskId : pendingTaskIds) {
RemoteTask pendingTask = taskIdMap.get(taskId);
// Cancel pending tasks
pendingTask.cancel();
}
if (!pendingTaskIds.isEmpty()) {
String warningMessage = format("Partial results are returned. Only %.2f percent of the data is read.", partialResultPercentage);
warningCollector.add(new PrestoWarning(PARTIAL_RESULT_WARNING, warningMessage));
}
}
use of com.facebook.presto.spi.PrestoWarning in project presto by prestodb.
the class PlanFragmenter method sanityCheckFragmentedPlan.
private void sanityCheckFragmentedPlan(SubPlan subPlan, WarningCollector warningCollector, ExchangeMaterializationStrategy exchangeMaterializationStrategy, int maxStageCount, int stageCountSoftLimit) {
subPlan.sanityCheck();
int fragmentCount = subPlan.getAllFragments().size();
if (fragmentCount > maxStageCount) {
throw new PrestoException(QUERY_HAS_TOO_MANY_STAGES, format("Number of stages in the query (%s) exceeds the allowed maximum (%s). " + TOO_MANY_STAGES_MESSAGE, fragmentCount, maxStageCount));
}
// (controlled by session property max_concurrent_materializations)
if (exchangeMaterializationStrategy != ExchangeMaterializationStrategy.ALL) {
if (fragmentCount > stageCountSoftLimit) {
warningCollector.add(new PrestoWarning(TOO_MANY_STAGES, format("Number of stages in the query (%s) exceeds the soft limit (%s). " + TOO_MANY_STAGES_MESSAGE, fragmentCount, stageCountSoftLimit)));
}
}
}
Aggregations