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"));
}
}
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"));
}
}
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"));
}
}
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();
}
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();
}
Aggregations