Search in sources :

Example 21 with UserException

use of org.apache.drill.common.exceptions.UserException in project drill by apache.

the class FragmentExecutor method sendFinalState.

private void sendFinalState() {
    final FragmentState outcome = fragmentState.get();
    if (outcome == FragmentState.FAILED) {
        final FragmentHandle handle = getContext().getHandle();
        final UserException uex = UserException.systemError(deferredException.getAndClear()).addIdentity(getContext().getEndpoint()).addContext("Fragment", handle.getMajorFragmentId() + ":" + handle.getMinorFragmentId()).build(logger);
        statusReporter.fail(uex);
    } else {
        statusReporter.stateChanged(outcome);
    }
    statusReporter.close();
}
Also used : FragmentState(org.apache.drill.exec.proto.UserBitShared.FragmentState) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) UserException(org.apache.drill.common.exceptions.UserException)

Example 22 with UserException

use of org.apache.drill.common.exceptions.UserException in project drill by apache.

the class TestReaderLevelProjection method testArrayMismatch.

/**
 * Project of a non-array as an array
 */
@Test
public void testArrayMismatch() {
    // Simulate SELECT a[0] ...
    final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a[0]"), ScanTestUtils.parsers());
    // Simulate a data source, with early schema, of (a)
    // where a is not an array.
    final TupleMetadata tableSchema = new SchemaBuilder().add("a", MinorType.VARCHAR).buildSchema();
    final NullColumnBuilder builder = new NullBuilderBuilder().build();
    final ResolvedRow rootTuple = new ResolvedRow(builder);
    try {
        new ExplicitSchemaProjection(scanProj, tableSchema, rootTuple, ScanTestUtils.resolvers());
        fail();
    } catch (final UserException e) {
    // Expected
    }
}
Also used : ResolvedRow(org.apache.drill.exec.physical.impl.scan.project.ResolvedTuple.ResolvedRow) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) NullBuilderBuilder(org.apache.drill.exec.physical.impl.scan.project.NullColumnBuilder.NullBuilderBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 23 with UserException

use of org.apache.drill.common.exceptions.UserException in project drill by apache.

the class TestReaderLevelProjection method testMapMismatch.

/**
 * Project of a non-map as a map
 */
@Test
public void testMapMismatch() {
    // Simulate SELECT a.b ...
    final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a.b"), ScanTestUtils.parsers());
    // Simulate a data source, with early schema, of (a)
    // where a is not a map.
    final TupleMetadata tableSchema = new SchemaBuilder().add("a", MinorType.VARCHAR).buildSchema();
    final NullColumnBuilder builder = new NullBuilderBuilder().build();
    final ResolvedRow rootTuple = new ResolvedRow(builder);
    try {
        new ExplicitSchemaProjection(scanProj, tableSchema, rootTuple, ScanTestUtils.resolvers());
        fail();
    } catch (final UserException e) {
    // Expected
    }
}
Also used : ResolvedRow(org.apache.drill.exec.physical.impl.scan.project.ResolvedTuple.ResolvedRow) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) NullBuilderBuilder(org.apache.drill.exec.physical.impl.scan.project.NullColumnBuilder.NullBuilderBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 24 with UserException

use of org.apache.drill.common.exceptions.UserException in project drill by apache.

the class TestScanLevelProjection method testProvidedSchemaTypeMismatch.

@Test
public void testProvidedSchemaTypeMismatch() {
    TupleMetadata providedSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.BIGINT).buildSchema();
    final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectAll(), ScanTestUtils.parsers(), providedSchema);
    // Make up a reader schema and test the projection set.
    // Schema deliberately conflicts with the provided schema.
    TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.INT).add("c", MinorType.INT).buildSchema();
    ProjectionFilter projSet = scanProj.readerProjection();
    assertTrue(projSet.isProjected("b"));
    try {
        projSet.projection(readerSchema.metadata("b"));
        fail();
    } catch (UserException e) {
    // Expected
    }
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 25 with UserException

use of org.apache.drill.common.exceptions.UserException in project drill by apache.

the class TestScanLevelProjection method testProvidedSchemaModeMismatch.

@Test
public void testProvidedSchemaModeMismatch() {
    TupleMetadata providedSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.BIGINT).buildSchema();
    providedSchema.setProperty(TupleMetadata.IS_STRICT_SCHEMA_PROP, Boolean.TRUE.toString());
    final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectAll(), ScanTestUtils.parsers(), providedSchema);
    // Make up a reader schema and test the projection set.
    // Mode deliberately conflicts with the provided schema
    TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.INT).addNullable("b", MinorType.INT).add("c", MinorType.INT).buildSchema();
    ProjectionFilter projSet = scanProj.readerProjection();
    assertTrue(projSet.isProjected("b"));
    try {
        isProjected(projSet, readerSchema.metadata("b"));
        fail();
    } catch (UserException e) {
    // Expected
    }
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Aggregations

UserException (org.apache.drill.common.exceptions.UserException)102 Test (org.junit.Test)76 EvfTest (org.apache.drill.categories.EvfTest)39 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)30 SubOperatorTest (org.apache.drill.test.SubOperatorTest)30 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)28 RowBatchReader (org.apache.drill.exec.physical.impl.scan.RowBatchReader)12 ManagedReader (org.apache.drill.exec.physical.impl.scan.v3.ManagedReader)12 ScanLifecycleBuilder (org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder)11 SchemaNegotiator (org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator)11 ScanOperatorExec (org.apache.drill.exec.physical.impl.scan.ScanOperatorExec)9 ScanFixture (org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture)9 SchemaPath (org.apache.drill.common.expression.SchemaPath)8 ResultSetOptions (org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions)8 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)8 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)6 ArrayList (java.util.ArrayList)5 OperatorTest (org.apache.drill.categories.OperatorTest)5 DrillException (org.apache.drill.common.exceptions.DrillException)5 BaseTest (org.apache.drill.test.BaseTest)5