use of org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn in project drill by apache.
the class TestScanLevelProjection method testEmptyProvidedSchema.
@Test
public void testEmptyProvidedSchema() {
TupleMetadata providedSchema = new SchemaBuilder().buildSchema();
// Simulate SELECT a
final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a"), ScanTestUtils.parsers(), providedSchema);
assertEquals(ScanProjectionType.EXPLICIT, scanProj.projectionType());
assertEquals(1, scanProj.columns().size());
assertEquals("a", scanProj.columns().get(0).name());
assertTrue(scanProj.columns().get(0) instanceof UnresolvedColumn);
}
use of org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn in project drill by apache.
the class TestScanLevelProjection method testBasics.
/**
* Basic test: select a set of columns (a, b, c) when the
* data source has an early schema of (a, c, d). (a, c) are
* projected, (d) is null.
*/
@Test
public void testBasics() {
// Simulate SELECT a, b, c ...
// Build the projection plan and verify
final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a", "b", "c"), ScanTestUtils.parsers());
assertFalse(scanProj.projectAll());
assertFalse(scanProj.isEmptyProjection());
assertEquals(3, scanProj.requestedCols().size());
assertEquals("a", scanProj.requestedCols().get(0).rootName());
assertEquals("b", scanProj.requestedCols().get(1).rootName());
assertEquals("c", scanProj.requestedCols().get(2).rootName());
assertEquals(3, scanProj.columns().size());
assertEquals("a", scanProj.columns().get(0).name());
assertEquals("b", scanProj.columns().get(1).name());
assertEquals("c", scanProj.columns().get(2).name());
// Verify column type
assertTrue(scanProj.columns().get(0) instanceof UnresolvedColumn);
// Verify tuple projection
RequestedTuple outputProj = scanProj.rootProjection();
assertEquals(3, outputProj.projections().size());
assertNotNull(outputProj.get("a"));
assertTrue(outputProj.get("a").isSimple());
// Make up a reader schema and test the projection set.
TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.INT).add("c", MinorType.INT).add("d", MinorType.INT).buildSchema();
ProjectionFilter projSet = scanProj.readerProjection();
assertTrue(isProjected(projSet, readerSchema.metadata("a")));
assertFalse(isProjected(projSet, readerSchema.metadata("d")));
}
Aggregations