use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class TestScanFilterAndProjectOperator method testRecordCursorSource.
@Test
public void testRecordCursorSource() throws Exception {
final Page input = SequencePageBuilder.createSequencePage(ImmutableList.of(VARCHAR), 10_000, 0);
DriverContext driverContext = newDriverContext();
ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory factory = new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), new PlanNodeId("0"), new PageSourceProvider() {
@Override
public ConnectorPageSource createPageSource(Session session, Split split, List<ColumnHandle> columns) {
return new RecordPageSource(new PageRecordSet(ImmutableList.of(VARCHAR), input));
}
}, () -> new GenericCursorProcessor(FilterFunctions.TRUE_FUNCTION, ImmutableList.of(singleColumn(VARCHAR, 0))), () -> new GenericPageProcessor(FilterFunctions.TRUE_FUNCTION, ImmutableList.of(singleColumn(VARCHAR, 0))), ImmutableList.of(), ImmutableList.of(VARCHAR));
SourceOperator operator = factory.createOperator(driverContext);
operator.addSplit(new Split(new ConnectorId("test"), TestingTransactionHandle.create(), TestingSplit.createLocalSplit()));
operator.noMoreSplits();
MaterializedResult expected = toMaterializedResult(driverContext.getSession(), ImmutableList.of(VARCHAR), ImmutableList.of(input));
MaterializedResult actual = toMaterializedResult(driverContext.getSession(), ImmutableList.of(VARCHAR), toPages(operator));
assertEquals(actual.getRowCount(), expected.getRowCount());
assertEquals(actual, expected);
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class TestScanFilterAndProjectOperator method testPageSource.
@Test
public void testPageSource() throws Exception {
final Page input = SequencePageBuilder.createSequencePage(ImmutableList.of(VARCHAR), 10_000, 0);
DriverContext driverContext = newDriverContext();
ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory factory = new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), new PlanNodeId("0"), new PageSourceProvider() {
@Override
public ConnectorPageSource createPageSource(Session session, Split split, List<ColumnHandle> columns) {
return new FixedPageSource(ImmutableList.of(input));
}
}, () -> new GenericCursorProcessor(FilterFunctions.TRUE_FUNCTION, ImmutableList.of(singleColumn(VARCHAR, 0))), () -> new GenericPageProcessor(FilterFunctions.TRUE_FUNCTION, ImmutableList.of(singleColumn(VARCHAR, 0))), ImmutableList.of(), ImmutableList.of(VARCHAR));
SourceOperator operator = factory.createOperator(driverContext);
operator.addSplit(new Split(new ConnectorId("test"), TestingTransactionHandle.create(), TestingSplit.createLocalSplit()));
operator.noMoreSplits();
MaterializedResult expected = toMaterializedResult(driverContext.getSession(), ImmutableList.of(VARCHAR), ImmutableList.of(input));
MaterializedResult actual = toMaterializedResult(driverContext.getSession(), ImmutableList.of(VARCHAR), toPages(operator));
assertEquals(actual.getRowCount(), expected.getRowCount());
assertEquals(actual, expected);
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class TestTopNOperator method testPartialMemoryFull.
@Test
public void testPartialMemoryFull() throws Exception {
List<Page> input = rowPagesBuilder(BIGINT).row(1L).pageBreak().row(2L).build();
DriverContext smallDiverContext = createTaskContext(executor, TEST_SESSION, new DataSize(1, BYTE)).addPipelineContext(0, true, true).addDriverContext();
TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), true, new DataSize(0, MEGABYTE));
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(1L).row(2L).build();
assertOperatorEquals(operatorFactory, smallDiverContext, input, expected);
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class TestTopNOperator method testLimitZero.
@Test
public void testLimitZero() throws Exception {
List<Page> input = rowPagesBuilder(BIGINT).row(1L).build();
TopNOperatorFactory factory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 0, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST), false, new DataSize(16, MEGABYTE));
try (Operator operator = factory.createOperator(driverContext)) {
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).build();
// assertOperatorEquals assumes operators do not start in finished state
assertEquals(operator.isFinished(), true);
assertEquals(operator.needsInput(), false);
assertEquals(operator.getOutput(), null);
List<Page> pages = OperatorAssertion.toPages(operator, input.iterator());
MaterializedResult actual = OperatorAssertion.toMaterializedResult(operator.getOperatorContext().getSession(), operator.getTypes(), pages);
assertEquals(actual, expected);
}
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class TestTopNOperator method testSingleFieldKey.
@Test
public void testSingleFieldKey() throws Exception {
List<Page> input = rowPagesBuilder(BIGINT, DOUBLE).row(1L, 0.1).row(2L, 0.2).pageBreak().row(-1L, -0.1).row(4L, 0.4).pageBreak().row(5L, 0.5).row(4L, 0.41).row(6L, 0.6).pageBreak().build();
TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE), 2, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST), false, new DataSize(16, MEGABYTE));
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, DOUBLE).row(6L, 0.6).row(5L, 0.5).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Aggregations