use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecLateSchema method testLateSchemaLifecycleNoSchemaBatch.
@Test
public void testLateSchemaLifecycleNoSchemaBatch() {
// Create a mock reader, return two batches: one schema-only, another with data.
MockLateSchemaReader reader = new MockLateSchemaReader();
reader.batchLimit = 2;
reader.returnDataOnFirst = true;
// Create the scan operator
BaseScanFixtureBuilder builder = simpleBuilder(reader);
builder.enableSchemaBatch = false;
ScanFixture scanFixture = builder.build();
ScanOperatorExec scan = scanFixture.scanOp;
// Standard startup
assertFalse(reader.openCalled);
// Create the expected result.
// First batch with data.
assertTrue(scan.next());
RowSetUtilities.verify(makeExpected(0), fixture.wrap(scan.batchAccessor().container()));
// Second batch.
assertTrue(scan.next());
RowSetUtilities.verify(makeExpected(20), fixture.wrap(scan.batchAccessor().container()));
// EOF
assertFalse(scan.next());
assertTrue(reader.closeCalled);
assertEquals(0, scan.batchAccessor().rowCount());
scanFixture.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecLateSchema method testNonEmptyFirstBatch.
/**
* Test the case where the reader does not play the "first batch contains
* only schema" game, and instead returns data. The Scan operator will
* split the first batch into two: one with schema only, another with
* data.
*/
@Test
public void testNonEmptyFirstBatch() {
SingleRowSet expected = makeExpected();
MockLateSchemaReader reader = new MockLateSchemaReader();
reader.batchLimit = 2;
reader.returnDataOnFirst = true;
ScanFixture scanFixture = simpleFixture(reader);
ScanOperatorExec scan = scanFixture.scanOp;
// First batch. The reader returns a non-empty batch. The scan
// operator strips off the schema and returns just that.
assertTrue(scan.buildSchema());
assertEquals(1, reader.batchCount);
assertEquals(expected.batchSchema(), scan.batchAccessor().schema());
assertEquals(0, scan.batchAccessor().rowCount());
scan.batchAccessor().release();
// Second batch. Returns the "look-ahead" batch returned by
// the reader earlier.
assertTrue(scan.next());
assertEquals(1, reader.batchCount);
RowSetUtilities.verify(expected, fixture.wrap(scan.batchAccessor().container()));
// Third batch, normal case.
assertTrue(scan.next());
assertEquals(2, reader.batchCount);
RowSetUtilities.verify(makeExpected(20), fixture.wrap(scan.batchAccessor().container()));
// EOF
assertFalse(scan.next());
assertTrue(reader.closeCalled);
assertEquals(0, scan.batchAccessor().rowCount());
scanFixture.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecLateSchema method testLateSchemaNoData.
@Test
public void testLateSchemaNoData() {
// Create a mock reader, return two batches: one schema-only, another with data.
MockLateSchemaReader reader = new MockLateSchemaReader();
reader.batchLimit = 0;
reader.returnDataOnFirst = false;
// Create the scan operator
ScanFixture scanFixture = simpleFixture(reader);
ScanOperatorExec scan = scanFixture.scanOp;
// Standard startup
assertFalse(reader.openCalled);
// First batch: EOF.
assertFalse(scan.buildSchema());
assertTrue(reader.openCalled);
assertTrue(reader.closeCalled);
scanFixture.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecLateSchema method testLateSchemaEarlyClose.
/**
* Test the case that a late scan operator is closed before
* the first reader is opened.
*/
@Test
public void testLateSchemaEarlyClose() {
// Create a mock reader, return two batches: one schema-only, another with data.
MockLateSchemaReader reader = new MockLateSchemaReader();
reader.batchLimit = 2;
reader.returnDataOnFirst = false;
// Create the scan operator
ScanFixture scanFixture = simpleFixture(reader);
// Reader never opened.
scanFixture.close();
assertFalse(reader.openCalled);
assertEquals(0, reader.batchCount);
assertFalse(reader.closeCalled);
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecEarlySchema method testEarlySchemaLifecycle.
@Test
public void testEarlySchemaLifecycle() {
// Create a mock reader, return two batches: one schema-only, another with data.
MockEarlySchemaReader reader = new MockEarlySchemaReader();
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, reader.batchCount);
assertEquals(expected.batchSchema(), scan.batchAccessor().schema());
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();
}
Aggregations