Search in sources :

Example 1 with ScanLifecycle

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.

the class TestReaderErrors method testCtorUserError.

@Test
public void testCtorUserError() {
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.errorContext(b -> b.addContext("Scan context"));
    builder.readerFactory(new SingleReaderFactory() {

        @Override
        public ManagedReader next(SchemaNegotiator negotiator) {
            return new FailingReader(negotiator, "ctor-u");
        }
    });
    ScanLifecycle scan = buildScan(builder);
    RowBatchReader reader = scan.nextReader();
    try {
        reader.open();
        fail();
    } catch (UserException e) {
        String msg = e.getMessage();
        assertTrue(msg.contains("Oops ctor"));
        assertTrue(msg.contains("My custom context"));
        assertTrue(msg.contains("Scan context"));
        assertNull(e.getCause());
    }
    scan.close();
}
Also used : RowBatchReader(org.apache.drill.exec.physical.impl.scan.RowBatchReader) ManagedReader(org.apache.drill.exec.physical.impl.scan.v3.ManagedReader) SchemaNegotiator(org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator) UserException(org.apache.drill.common.exceptions.UserException) ScanLifecycleBuilder(org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 2 with ScanLifecycle

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.

the class TestReaderErrors method testNextUserError.

@Test
public void testNextUserError() {
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.errorContext(b -> b.addContext("Scan context"));
    builder.readerFactory(new SingleReaderFactory() {

        @Override
        public ManagedReader next(SchemaNegotiator negotiator) {
            return new FailingReader(negotiator, "next-u");
        }
    });
    ScanLifecycle scan = buildScan(builder);
    RowBatchReader reader = scan.nextReader();
    assertTrue(reader.open());
    try {
        reader.next();
        fail();
    } catch (UserException e) {
        String msg = e.getMessage();
        assertTrue(msg.contains("Oops next"));
        assertTrue(msg.contains("My custom context"));
        assertTrue(msg.contains("Scan context"));
        assertNull(e.getCause());
    }
    scan.close();
}
Also used : RowBatchReader(org.apache.drill.exec.physical.impl.scan.RowBatchReader) ManagedReader(org.apache.drill.exec.physical.impl.scan.v3.ManagedReader) SchemaNegotiator(org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator) UserException(org.apache.drill.common.exceptions.UserException) ScanLifecycleBuilder(org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 3 with ScanLifecycle

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.

the class TestReaderErrors method testNextError.

@Test
public void testNextError() {
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.errorContext(b -> b.addContext("Scan context"));
    builder.readerFactory(new SingleReaderFactory() {

        @Override
        public ManagedReader next(SchemaNegotiator negotiator) {
            return new FailingReader(negotiator, "next");
        }
    });
    ScanLifecycle scan = buildScan(builder);
    RowBatchReader reader = scan.nextReader();
    assertTrue(reader.open());
    try {
        reader.next();
        fail();
    } catch (UserException e) {
        String msg = e.getMessage();
        assertTrue(msg.contains("Oops next"));
        assertTrue(msg.contains("My custom context"));
        assertTrue(msg.contains("Scan context"));
        assertTrue(e.getCause() instanceof IllegalStateException);
    }
    scan.close();
}
Also used : RowBatchReader(org.apache.drill.exec.physical.impl.scan.RowBatchReader) ManagedReader(org.apache.drill.exec.physical.impl.scan.v3.ManagedReader) SchemaNegotiator(org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator) UserException(org.apache.drill.common.exceptions.UserException) ScanLifecycleBuilder(org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 4 with ScanLifecycle

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.

the class TestReaderErrors method testCloseUserError.

@Test
public void testCloseUserError() {
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.errorContext(b -> b.addContext("Scan context"));
    builder.readerFactory(new SingleReaderFactory() {

        @Override
        public ManagedReader next(SchemaNegotiator negotiator) {
            return new FailingReader(negotiator, "close-u");
        }
    });
    ScanLifecycle scan = buildScan(builder);
    RowBatchReader reader = scan.nextReader();
    assertTrue(reader.open());
    assertFalse(reader.next());
    // to update an external system.
    try {
        reader.close();
        fail();
    } catch (UserException e) {
        String msg = e.getMessage();
        assertTrue(msg.contains("Oops close"));
        assertTrue(msg.contains("My custom context"));
        assertTrue(msg.contains("Scan context"));
        assertNull(e.getCause());
    }
    scan.close();
}
Also used : RowBatchReader(org.apache.drill.exec.physical.impl.scan.RowBatchReader) ManagedReader(org.apache.drill.exec.physical.impl.scan.v3.ManagedReader) SchemaNegotiator(org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator) UserException(org.apache.drill.common.exceptions.UserException) ScanLifecycleBuilder(org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 5 with ScanLifecycle

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.

the class TestReaderErrors method testCtorError.

@Test
public void testCtorError() {
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.errorContext(b -> b.addContext("Scan context"));
    builder.readerFactory(new SingleReaderFactory() {

        @Override
        public ManagedReader next(SchemaNegotiator negotiator) {
            return new FailingReader(negotiator, "ctor");
        }
    });
    ScanLifecycle scan = buildScan(builder);
    RowBatchReader reader = scan.nextReader();
    try {
        reader.open();
        fail();
    } catch (UserException e) {
        String msg = e.getMessage();
        assertTrue(msg.contains("Oops ctor"));
        assertTrue(msg.contains("My custom context"));
        assertTrue(msg.contains("Scan context"));
        assertTrue(e.getCause() instanceof IllegalStateException);
    }
    scan.close();
}
Also used : RowBatchReader(org.apache.drill.exec.physical.impl.scan.RowBatchReader) ManagedReader(org.apache.drill.exec.physical.impl.scan.v3.ManagedReader) SchemaNegotiator(org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator) UserException(org.apache.drill.common.exceptions.UserException) ScanLifecycleBuilder(org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Aggregations

EvfTest (org.apache.drill.categories.EvfTest)48 ManagedReader (org.apache.drill.exec.physical.impl.scan.v3.ManagedReader)48 Test (org.junit.Test)48 ScanLifecycleBuilder (org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder)44 RowBatchReader (org.apache.drill.exec.physical.impl.scan.RowBatchReader)43 SchemaNegotiator (org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator)43 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)22 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)13 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)13 UserException (org.apache.drill.common.exceptions.UserException)12 DummyFileWork (org.apache.drill.exec.physical.impl.scan.v3.file.BaseFileScanTest.DummyFileWork)6 BaseTestScanLifecycle (org.apache.drill.exec.physical.impl.scan.v3.lifecycle.BaseTestScanLifecycle)6 ScanLifecycle (org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle)6 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 EarlyEofException (org.apache.drill.exec.physical.impl.scan.v3.ManagedReader.EarlyEofException)1 VectorContainer (org.apache.drill.exec.record.VectorContainer)1 Path (org.apache.hadoop.fs.Path)1