use of org.apache.drill.exec.physical.impl.scan.RowBatchReader 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.exec.physical.impl.scan.RowBatchReader 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();
}
use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.
the class TestScanLifecycleTwoReaders method testExpandingSchemaDisallowingSchemaChange.
/**
* SELECT * FROM two readers, one (a, b), the other (a, b, c).
* With schema change disabled, the third column is ignored in the
* second reader: the first reader "fixes" projection to just (a, b)
* even though projection started as wildcard.
* <p>
* We can argue if this behavior is correct. We know most operators,
* and no ODBC or JDBC client can handle schema change. So, our other
* options are do the schema change anyway (the above test), fail, or
* this choice, which is to try to muddle though. The correct solution
* is to provide a schema (tested elsewhere.)
*/
@Test
public void testExpandingSchemaDisallowingSchemaChange() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.allowSchemaChange(false);
builder.readerFactory(new TwoReaderFactory() {
@Override
public ManagedReader firstReader(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 1);
}
@Override
public ManagedReader secondReader(SchemaNegotiator negotiator) {
return new MockThreeColReader(negotiator);
}
});
ScanLifecycle scan = buildScan(builder);
verifyStandardReader(scan, 0);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(SCHEMA).addRow(101, "wilma").addRow(102, "betty").build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.
the class TestScanLifecycleTwoReaders method testValidThenNullReader.
@Test
public void testValidThenNullReader() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new TwoReaderFactory() {
@Override
public ManagedReader firstReader(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 1);
}
@Override
public ManagedReader secondReader(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 0);
}
});
ScanLifecycle scan = buildScan(builder);
verifyStandardReader(scan, 0);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertFalse(reader.next());
assertTrue(scan.hasOutputSchema());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.RowBatchReader 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();
}
Aggregations