use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class TestScanLifecycleTwoReaders method testEarlySchemaTypeConflict.
/**
* 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 testEarlySchemaTypeConflict() {
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 MockEarlySchemaTypeConflictReader(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();
}
use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class TestReaderErrors method testCloseError.
@Test
public void testCloseError() {
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");
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertFalse(reader.next());
try {
reader.close();
fail();
} catch (UserException e) {
// Expected
}
scan.close();
}
use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class TestScanLifecycleTwoReaders method testShrinkingSchemaWithConflict.
/**
* Shrinking schema, as above. Explicit projection:<pre><code>
* SELECT a, b FROM (a) then (a,b)
* </code></pre><p>
* But choose a missing column type (the default
* Nullable INT) in the first reader that will conflict with the actual column type
* (VARCHAR) in the second.
*/
@Test
public void testShrinkingSchemaWithConflict() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.projection(RowSetTestUtils.projectList("a", "b"));
builder.readerFactory(new TwoReaderFactory() {
@Override
public ManagedReader firstReader(SchemaNegotiator negotiator) {
return new MockSingleColReader(negotiator);
}
@Override
public ManagedReader secondReader(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
reader.output().clear();
assertFalse(reader.next());
reader.close();
reader = scan.nextReader();
try {
reader.open();
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 TestSchemaTrackerEarlyReaderSchema method testModeConflict.
@Test
public void testModeConflict() {
ProjectionSchemaTracker tracker = trackerFor(RowSetTestUtils.projectAll());
tracker.applyProvidedSchema(SCHEMA);
assertTrue(tracker.isResolved());
TupleMetadata readerSchema = new SchemaBuilder().addNullable("a", MinorType.INT).build();
try {
tracker.applyEarlyReaderSchema(readerSchema);
fail();
} catch (UserException e) {
assertTrue(e.getMessage().contains("type conflict"));
assertTrue(e.getMessage().contains("Scan column: `a` INT NOT NULL"));
assertTrue(e.getMessage().contains("Reader column: `a` INT"));
}
}
use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class TestSchemaTrackerEarlyReaderSchema method testTypeConflict.
@Test
public void testTypeConflict() {
ProjectionSchemaTracker tracker = trackerFor(RowSetTestUtils.projectAll());
tracker.applyProvidedSchema(SCHEMA);
assertTrue(tracker.isResolved());
TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.BIGINT).build();
try {
tracker.applyEarlyReaderSchema(readerSchema);
fail();
} catch (UserException e) {
assertTrue(e.getMessage().contains("type conflict"));
assertTrue(e.getMessage().contains("Scan column: `a` INT NOT NULL"));
assertTrue(e.getMessage().contains("Reader column: `a` BIGINT NOT NULL"));
}
}
Aggregations