use of com.facebook.presto.operator.project.PageProjection in project presto by prestodb.
the class TestPageFunctionCompiler method testGeneratedClassName.
@Test
public void testGeneratedClassName() {
PageFunctionCompiler functionCompiler = new PageFunctionCompiler(createTestMetadataManager(), 0);
String planNodeId = "7";
String stageId = "20170707_223500_67496_zguwn.2";
String classSuffix = stageId + "_" + planNodeId;
Supplier<PageProjection> projectionSupplier = functionCompiler.compileProjection(SESSION.getSqlFunctionProperties(), ADD_10_EXPRESSION, Optional.of(classSuffix));
PageProjection projection = projectionSupplier.get();
Work<List<Block>> work = projection.project(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), createLongBlockPage(1, 0), SelectedPositions.positionsRange(0, 1));
// class name should look like PageProjectionOutput_20170707_223500_67496_zguwn_2_7_XX
assertTrue(work.getClass().getSimpleName().startsWith("PageProjectionWork_" + stageId.replace('.', '_') + "_" + planNodeId));
}
use of com.facebook.presto.operator.project.PageProjection in project presto by prestodb.
the class TestPageFunctionCompiler method testFailureDoesNotCorruptFutureResults.
@Test
public void testFailureDoesNotCorruptFutureResults() {
PageFunctionCompiler functionCompiler = new PageFunctionCompiler(createTestMetadataManager(), 0);
Supplier<PageProjection> projectionSupplier = functionCompiler.compileProjection(SESSION.getSqlFunctionProperties(), ADD_10_EXPRESSION, Optional.empty());
PageProjection projection = projectionSupplier.get();
// process good page and verify we got the expected number of result rows
Page goodPage = createLongBlockPage(1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
Block goodResult = project(projection, goodPage, SelectedPositions.positionsRange(0, goodPage.getPositionCount())).get(0);
assertEquals(goodPage.getPositionCount(), goodResult.getPositionCount());
// addition will throw due to integer overflow
Page badPage = createLongBlockPage(1, 0, 1, 2, 3, 4, Long.MAX_VALUE);
try {
project(projection, badPage, SelectedPositions.positionsRange(0, 100));
fail("expected exception");
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), NUMERIC_VALUE_OUT_OF_RANGE.toErrorCode());
}
// running the good page should still work
// if block builder in generated code was not reset properly, we could get junk results after the failure
goodResult = project(projection, goodPage, SelectedPositions.positionsRange(0, goodPage.getPositionCount())).get(0);
assertEquals(goodPage.getPositionCount(), goodResult.getPositionCount());
}
Aggregations