use of org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator 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.v3.SchemaNegotiator 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.v3.SchemaNegotiator 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.exec.physical.impl.scan.v3.SchemaNegotiator in project drill by apache.
the class TestScanLifecycleTwoReaders method testSpecifiedColumnOrder.
/**
* {@code SELECT , b FROM} (b,a) then (a, b). The order of the project list
* drives the order of the results.
*/
@Test
public void testSpecifiedColumnOrder() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.projection(RowSetTestUtils.projectList("a", "b"));
builder.readerFactory(new TwoReaderFactory() {
@Override
public ManagedReader firstReader(SchemaNegotiator negotiator) {
return new MockReorderedReader(negotiator);
}
@Override
public ManagedReader secondReader(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(SCHEMA).addRow(30, "barney").addRow(40, "betty").build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
verifyStandardReader(scan, 0);
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator in project drill by apache.
the class TestScanLifecycleTwoReaders method testColumnReorderingAB.
/**
* {@code SELECT * FROM} (a, b) then (b,a). The order of the first
* table drives the order of the results.
*/
@Test
public void testColumnReorderingAB() {
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 MockReorderedReader(negotiator);
}
});
ScanLifecycle scan = buildScan(builder);
verifyStandardReader(scan, 0);
RowBatchReader reader = scan.nextReader();
reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(SCHEMA).addRow(30, "barney").addRow(40, "betty").build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
Aggregations