Search in sources :

Example 76 with UserException

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

the class TestImplicitColumnResolver method testProvidedImplicitColTypeConflict.

@Test
public void testProvidedImplicitColTypeConflict() {
    TupleMetadata providedSchema = new SchemaBuilder().add("myFqn", MinorType.INT).build();
    SchemaUtils.markImplicit(providedSchema.metadata("myFqn"), ColumnMetadata.IMPLICIT_FQN);
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
    parseFixture.tracker.applyProvidedSchema(providedSchema);
    try {
        parseFixture.parseImplicit();
    } catch (UserException e) {
        assertTrue(e.getMessage().contains("wrong type"));
    }
}
Also used : 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) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 77 with UserException

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

the class TestImplicitColumnResolver method testProvidedUndefinedImplicitCol.

@Test
public void testProvidedUndefinedImplicitCol() {
    TupleMetadata providedSchema = new SchemaBuilder().add("myDir", MinorType.VARCHAR).build();
    SchemaUtils.markImplicit(providedSchema.metadata("myDir"), "bogus");
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
    parseFixture.tracker.applyProvidedSchema(providedSchema);
    parseFixture.options.maxPartitionDepth(1);
    try {
        parseFixture.parseImplicit();
    } catch (UserException e) {
        assertTrue(e.getMessage().contains("references an undefined implicit column"));
    }
}
Also used : 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) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 78 with UserException

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

the class TestImplicitColumnResolver method testProvidedPartitionColTypeConflict.

@Test
public void testProvidedPartitionColTypeConflict() {
    TupleMetadata providedSchema = new SchemaBuilder().addNullable("myDir", MinorType.INT).build();
    SchemaUtils.markAsPartition(providedSchema.metadata("myDir"), 0);
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
    parseFixture.tracker.applyProvidedSchema(providedSchema);
    parseFixture.options.maxPartitionDepth(1);
    try {
        parseFixture.parseImplicit();
    } catch (UserException e) {
        assertTrue(e.getMessage().contains("wrong type"));
    }
}
Also used : 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) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 79 with UserException

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

the class TestScanLifecycleTwoReaders method testLateSchemaTypeConflict.

/**
 * SELECT * from two readers: both (a, b), but with a conflicting
 * type for the column b. The reader fail will with a type conflict.
 */
@Test
public void testLateSchemaTypeConflict() {
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.allowSchemaChange(true);
    builder.readerFactory(new TwoReaderFactory() {

        @Override
        public ManagedReader firstReader(SchemaNegotiator negotiator) {
            return new MockLateSchemaReader(negotiator, 1);
        }

        @Override
        public ManagedReader secondReader(SchemaNegotiator negotiator) {
            return new MockLateSchemaTypeConflictReader(negotiator);
        }
    });
    ScanLifecycle scan = buildScan(builder);
    verifyStandardReader(scan, 0);
    RowBatchReader reader = scan.nextReader();
    assertTrue(reader.open());
    try {
        reader.next();
        fail();
    } catch (UserException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    reader.close();
    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) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 80 with UserException

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

the class TestScanLifecycleTwoReaders method testModeConflict.

/**
 * SELECT * from two readers: both (a, b), but with a conflicting
 * type for the column b. The reader fail will with a type conflict.
 * We could possibly try to handle a NULLABLE --> NON NULLABLE conflict,
 * but there does not yet appear to be a compelling case for doing so.
 */
@Test
public void testModeConflict() {
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.allowSchemaChange(true);
    builder.readerFactory(new TwoReaderFactory() {

        @Override
        public ManagedReader firstReader(SchemaNegotiator negotiator) {
            return new MockLateSchemaReader(negotiator, 1);
        }

        @Override
        public ManagedReader secondReader(SchemaNegotiator negotiator) {
            return new MockModeConflictReader(negotiator);
        }
    });
    ScanLifecycle scan = buildScan(builder);
    verifyStandardReader(scan, 0);
    RowBatchReader reader = scan.nextReader();
    try {
        reader.open();
        fail();
    } catch (UserException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    reader.close();
    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) 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