use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecBasics method testUserExceptionOnSecondNext.
@Test
public void testUserExceptionOnSecondNext() {
MockEarlySchemaReader reader = new MockEarlySchemaReader() {
@Override
public boolean next() {
if (batchCount == 1) {
// Load some data
super.next();
throw UserException.dataReadError().addContext(ERROR_MSG).build(logger);
}
return super.next();
}
};
reader.batchLimit = 2;
ScanFixture scanFixture = simpleFixture(reader);
ScanOperatorExec scan = scanFixture.scanOp;
// Schema
assertTrue(scan.buildSchema());
// First batch
assertTrue(scan.next());
scan.batchAccessor().release();
try {
scan.next();
fail();
} catch (UserException e) {
assertTrue(e.getMessage().contains(ERROR_MSG));
assertNull(e.getCause());
}
scanFixture.close();
assertTrue(reader.closeCalled);
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecBasics method testNoReader.
/**
* Pathological case that a scan operator is provided no readers.
* It will throw a user exception because the downstream operators
* can't handle this case so we choose to stop the show early to
* avoid getting into a strange state.
*/
@Test
public void testNoReader() {
// Create the scan operator
ScanFixture scanFixture = simpleFixture();
ScanOperatorExec scan = scanFixture.scanOp;
try {
scan.buildSchema();
} catch (UserException e) {
// Expected
assertTrue(e.getCause() instanceof ExecutionSetupException);
}
// Must close the DAG (context and scan operator) even on failures
scanFixture.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecBasics method testExceptionOnFirstNext.
@Test
public void testExceptionOnFirstNext() {
MockEarlySchemaReader reader = new MockEarlySchemaReader() {
@Override
public boolean next() {
// Load some data
super.next();
throw new IllegalStateException(ERROR_MSG);
}
};
reader.batchLimit = 2;
ScanFixture scanFixture = simpleFixture(reader);
ScanOperatorExec scan = scanFixture.scanOp;
assertTrue(scan.buildSchema());
try {
scan.next();
fail();
} catch (UserException e) {
assertTrue(e.getMessage().contains(ERROR_MSG));
assertTrue(e.getCause() instanceof IllegalStateException);
}
assertTrue(reader.openCalled);
assertEquals(0, scan.batchAccessor().rowCount());
scanFixture.close();
assertTrue(reader.closeCalled);
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecBasics method testExceptionOnClose.
@Test
public void testExceptionOnClose() {
MockEarlySchemaReader reader1 = new MockEarlySchemaReader() {
@Override
public void close() {
super.close();
throw new IllegalStateException(ERROR_MSG);
}
};
reader1.batchLimit = 2;
MockEarlySchemaReader reader2 = new MockEarlySchemaReader();
reader2.batchLimit = 2;
ScanFixture scanFixture = simpleFixture(reader1, reader2);
ScanOperatorExec scan = scanFixture.scanOp;
assertTrue(scan.buildSchema());
assertTrue(scan.next());
scan.batchAccessor().release();
assertTrue(scan.next());
scan.batchAccessor().release();
try {
scan.next();
fail();
} catch (UserException e) {
assertTrue(e.getMessage().contains(ERROR_MSG));
assertTrue(e.getCause() instanceof IllegalStateException);
}
assertTrue(reader1.closeCalled);
assertFalse(reader2.openCalled);
scanFixture.close();
}
use of org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture in project drill by apache.
the class TestScanOperExecBasics method testUserExceptionOnOpen.
@Test
public void testUserExceptionOnOpen() {
// Reader which fails on open with a known error message
// using a UserException.
MockEarlySchemaReader reader = new MockEarlySchemaReader() {
@Override
public boolean open(SchemaNegotiator schemaNegotiator) {
openCalled = true;
throw UserException.dataReadError().addContext(ERROR_MSG).build(logger);
}
};
reader.batchLimit = 2;
ScanFixture scanFixture = simpleFixture(reader);
ScanOperatorExec scan = scanFixture.scanOp;
try {
scan.buildSchema();
fail();
} catch (UserException e) {
assertTrue(e.getMessage().contains(ERROR_MSG));
assertNull(e.getCause());
}
assertTrue(reader.openCalled);
assertEquals(0, scan.batchAccessor().rowCount());
scanFixture.close();
assertTrue(reader.closeCalled);
}
Aggregations