Search in sources :

Example 1 with PrestoWarning

use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.

the class SqlQueryExecution method createResumeScheduler.

private SqlQueryScheduler createResumeScheduler(PlanRoot plan, OutputBuffers rootOutputBuffers) {
    String resumeMessage = "Query encountered failures. Recovering using the distributed-snapshot feature.";
    warningCollector.add(new PrestoWarning(StandardWarningCode.SNAPSHOT_RECOVERY, resumeMessage));
    // Check if there is a snapshot we can restore to, or restart from beginning,
    // and update marker split sources so they know where to resume from.
    // This MUST be done BEFORE creating the new scheduler, because it resets the snapshotManager internal states.
    OptionalLong snapshotId = snapshotManager.getResumeSnapshotId();
    MarkerAnnouncer announcer = splitManager.getMarkerAnnouncer(stateMachine.getSession());
    announcer.resumeSnapshot(snapshotId.orElse(0));
    // Clear any temporary content that's not part of the snapshot
    resetOutputData(plan, snapshotId);
    // Create a new scheduler, to schedule new stages and tasks
    DistributedExecutionPlanner distributedExecutionPlanner = new DistributedExecutionPlanner(splitManager, metadata);
    StageExecutionPlan executionPlan = distributedExecutionPlanner.plan(plan.getRoot(), stateMachine.getSession(), RESUME, snapshotId.isPresent() ? snapshotId.getAsLong() : null, announcer.currentSnapshotId());
    // build the stage execution objects (this doesn't schedule execution)
    return createSqlQueryScheduler(stateMachine, locationFactory, executionPlan, nodePartitioningManager, nodeScheduler, remoteTaskFactory, stateMachine.getSession(), plan.isSummarizeTaskInfos(), scheduleSplitBatchSize, queryExecutor, schedulerExecutor, failureDetector, rootOutputBuffers, nodeTaskMap, executionPolicy, schedulerStats, dynamicFilterService, heuristicIndexerManager, snapshotManager, // Require same number of tasks to be scheduled, but do not require it if starting from beginning
    snapshotId.isPresent() ? queryScheduler.get().getStageTaskCounts() : null);
}
Also used : MarkerAnnouncer(io.prestosql.snapshot.MarkerAnnouncer) StageExecutionPlan(io.prestosql.sql.planner.StageExecutionPlan) PrestoWarning(io.prestosql.spi.PrestoWarning) OptionalLong(java.util.OptionalLong) DistributedExecutionPlanner(io.prestosql.sql.planner.DistributedExecutionPlanner)

Example 2 with PrestoWarning

use of io.prestosql.spi.PrestoWarning 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);
}
Also used : PrestoWarning(io.prestosql.spi.PrestoWarning) WarningCode(io.prestosql.spi.WarningCode) Test(org.testng.annotations.Test)

Example 3 with PrestoWarning

use of io.prestosql.spi.PrestoWarning 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)));
}
Also used : SQLWarning(java.sql.SQLWarning) ImmutableList(com.google.common.collect.ImmutableList) PrestoWarning(io.prestosql.spi.PrestoWarning) WarningCode(io.prestosql.spi.WarningCode) Test(org.testng.annotations.Test)

Example 4 with PrestoWarning

use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.

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) WarningCollectorConfig(io.prestosql.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(io.prestosql.testing.TestingWarningCollectorConfig) TestingWarningCollectorConfig(io.prestosql.testing.TestingWarningCollectorConfig) PrestoWarning(io.prestosql.spi.PrestoWarning) TestingWarningCollector(io.prestosql.testing.TestingWarningCollector) Test(org.testng.annotations.Test)

Example 5 with PrestoWarning

use of io.prestosql.spi.PrestoWarning in project hetu-core by openlookeng.

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(toPrestoSqlWarning(prestoWarning))));
        }
    }
}
Also used : WarningCollectorConfig(io.prestosql.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(io.prestosql.testing.TestingWarningCollectorConfig) TestingWarningCollectorConfig(io.prestosql.testing.TestingWarningCollectorConfig) ResultSet(java.sql.ResultSet) PrestoWarning(io.prestosql.spi.PrestoWarning) TestingWarningCollector(io.prestosql.testing.TestingWarningCollector) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

PrestoWarning (io.prestosql.spi.PrestoWarning)14 Test (org.testng.annotations.Test)8 WarningCollectorConfig (io.prestosql.execution.warnings.WarningCollectorConfig)4 WarningCode (io.prestosql.spi.WarningCode)4 TestingWarningCollector (io.prestosql.testing.TestingWarningCollector)4 TestingWarningCollectorConfig (io.prestosql.testing.TestingWarningCollectorConfig)4 ImmutableList (com.google.common.collect.ImmutableList)3 SQLWarning (java.sql.SQLWarning)3 CubeMetadata (io.hetu.core.spi.cube.CubeMetadata)2 Session (io.prestosql.Session)2 WarningCollector (io.prestosql.execution.warnings.WarningCollector)2 Captures (io.prestosql.matching.Captures)2 Pattern (io.prestosql.matching.Pattern)2 ProjectNode (io.prestosql.spi.plan.ProjectNode)2 Rule (io.prestosql.sql.planner.iterative.Rule)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 Optional (java.util.Optional)2