Source:
<code>public void testPageSourceLazyLoad() throws Exception { Block inputBlock = BlockAssertions.createLongsBlock(0, 10_000); <START> Page input = new Page(inputBlock, new LazyBlock(100, lazyBlock -> { <END> throw new AssertionError("Lazy block should not be loaded"); })); DriverContext driverContext = newDriverContext(); List<RowExpression> projections = ImmutableList.of(field(0, VARCHAR)); Supplier<CursorProcessor> cursorProcessor = expressionCompiler.compileCursorProcessor(Optional.empty(), projections, "key"); PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectAllFilter()), ImmutableList.of(new LazyPagePageProjection())); ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory factory = new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory( 0, new PlanNodeId("test"), new PlanNodeId("0"), (session, split, columns) -> new SinglePagePageSource(input), cursorProcessor, () -> pageProcessor, ImmutableList.of(), ImmutableList.of(BIGINT)); 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(BIGINT), ImmutableList.of(new Page(inputBlock))); MaterializedResult actual = toMaterializedResult(driverContext.getSession(), ImmutableList.of(BIGINT), toPages(operator)); assertEquals(actual.getRowCount(), expected.getRowCount()); assertEquals(actual, expected); }</code><technical_language>This creates a page mismatched block position counts. this pass in 2 inputBlock.getPositionCount() here</technical_language>

Target:
public void testPageSourceLazyLoad() throws Exception { Block inputBlock = BlockAssertions.createLongSequenceBlock(0, 100); Page input = new Page(100, inputBlock, new LazyBlock(100, lazyBlock -> { throw new AssertionError("Lazy block should not be loaded"); })); DriverContext driverContext = newDriverContext(); List<RowExpression> projections = ImmutableList.of(field(0, VARCHAR)); Supplier<CursorProcessor> cursorProcessor = expressionCompiler.compileCursorProcessor(Optional.empty(), projections, "key"); PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectAllFilter()), ImmutableList.of(new LazyPagePageProjection())); ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory factory = new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory( 0, new PlanNodeId("test"), new PlanNodeId("0"), (session, split, columns) -> new SinglePagePageSource(input), cursorProcessor, () -> pageProcessor, ImmutableList.of(), ImmutableList.of(BIGINT)); 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(BIGINT), ImmutableList.of(new Page(inputBlock))); MaterializedResult actual = toMaterializedResult(driverContext.getSession(), ImmutableList.of(BIGINT), toPages(operator)); assertEquals(actual.getRowCount(), expected.getRowCount()); assertEquals(actual, expected); }