use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecEarlySchema method testEarlySchemaLifecycleNoSchemaBatch.
@Test
public void testEarlySchemaLifecycleNoSchemaBatch() {
// Create a mock reader, return one batch with data.
MockEarlySchemaReader reader = new MockEarlySchemaReader();
reader.batchLimit = 1;
// Create the scan operator
BaseScanFixtureBuilder builder = simpleBuilder(reader);
builder.enableSchemaBatch = false;
ScanFixture scanFixture = builder.build();
ScanOperatorExec scan = scanFixture.scanOp;
SingleRowSet expected = makeExpected();
RowSetComparison verifier = new RowSetComparison(expected);
// First batch: return with data.
assertTrue(scan.next());
verifier.verifyAndClearAll(fixture.wrap(scan.batchAccessor().container()));
// EOF
assertFalse(scan.next());
assertEquals(0, scan.batchAccessor().rowCount());
// Next again: no-op
assertFalse(scan.next());
scanFixture.close();
// Close again: no-op
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecEarlySchema method testEOFOnFirstBatch.
@Test
public void testEOFOnFirstBatch() {
MockEarlySchemaReader reader = new MockEarlySchemaReader();
reader.batchLimit = 0;
ScanFixture scanFixture = simpleFixture(reader);
ScanOperatorExec scan = scanFixture.scanOp;
assertTrue(scan.buildSchema());
// EOF. Returns a single empty batch with early schema
// in order to provide an empty result set.
assertTrue(scan.next());
assertTrue(reader.closeCalled);
assertEquals(0, scan.batchAccessor().rowCount());
RowSetUtilities.verify(RowSetBuilder.emptyBatch(fixture.allocator(), expectedSchema()), fixture.wrap(scan.batchAccessor().container()));
assertFalse(scan.next());
scanFixture.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecEarlySchema method testEarlySchemaDataWithEof.
@Test
public void testEarlySchemaDataWithEof() {
// Create a mock reader, return two batches: one schema-only, another with data.
MockEarlySchemaReader3 reader = new MockEarlySchemaReader3();
reader.batchLimit = 1;
// Create the scan operator
ScanFixture scanFixture = simpleFixture(reader);
ScanOperatorExec scan = scanFixture.scanOp;
SingleRowSet expected = makeExpected();
RowSetComparison verifier = new RowSetComparison(expected);
// First batch: return schema.
assertTrue(scan.buildSchema());
assertEquals(0, scan.batchAccessor().rowCount());
// Next call, return with data.
assertTrue(scan.next());
verifier.verifyAndClearAll(fixture.wrap(scan.batchAccessor().container()));
// EOF
assertFalse(scan.next());
assertEquals(0, scan.batchAccessor().rowCount());
// Next again: no-op
assertFalse(scan.next());
scanFixture.close();
// Close again: no-op
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecLimit method testLimit0.
/**
* LIMIT 0, to obtain only the schema.
*/
@Test
public void testLimit0() {
Mock50RowReader reader1 = new Mock50RowReader();
Mock50RowReader reader2 = new Mock50RowReader();
BaseScanFixtureBuilder builder = simpleBuilder(reader1, reader2);
builder.builder.limit(0);
ScanFixture scanFixture = builder.build();
ScanOperatorExec scan = scanFixture.scanOp;
assertTrue(scan.buildSchema());
assertTrue(scan.next());
BatchAccessor batch = scan.batchAccessor();
assertEquals(0, batch.rowCount());
assertEquals(1, batch.schema().getFieldCount());
batch.release();
// No second batch or second reader
assertFalse(scan.next());
scanFixture.close();
assertTrue(reader1.openCalled);
assertFalse(reader2.openCalled);
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecLimit method testLimitOnBatchEnd.
/**
* LIMIT 50, same as batch size, to check boundary conditions.
*/
@Test
public void testLimitOnBatchEnd() {
Mock50RowReader reader1 = new Mock50RowReader();
Mock50RowReader reader2 = new Mock50RowReader();
BaseScanFixtureBuilder builder = simpleBuilder(reader1, reader2);
builder.builder.limit(50);
ScanFixture scanFixture = builder.build();
ScanOperatorExec scan = scanFixture.scanOp;
assertTrue(scan.buildSchema());
assertTrue(scan.next());
BatchAccessor batch = scan.batchAccessor();
assertEquals(50, batch.rowCount());
batch.release();
// No second batch or second reader
assertFalse(scan.next());
scanFixture.close();
assertTrue(reader1.openCalled);
assertFalse(reader2.openCalled);
}
Aggregations