use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter in project drill by apache.
the class TestSchemaTrackerProjection method testWildcard.
@Test
public void testWildcard() {
ProjectionSchemaTracker tracker = schemaTracker(RowSetTestUtils.projectAll());
assertFalse(tracker.isResolved());
assertEquals(1, tracker.schemaVersion());
assertSame(ScanSchemaTracker.ProjectionType.ALL, tracker.projectionType());
assertTrue(tracker.internalSchema().toSchema().isEmpty());
ProjectionFilter filter = tracker.projectionFilter(ERROR_CONTEXT);
assertSame(ProjectionFilter.PROJECT_ALL, filter);
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter in project drill by apache.
the class TestScanLevelProjection method testStrictProvidedSchema.
/**
* Strict provided schema, reader that offers an extra column,
* projection list includes the column. However, column is
* not projected for reader.
*/
@Test
public void testStrictProvidedSchema() {
TupleMetadata providedSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.BIGINT).buildSchema();
providedSchema.setProperty(TupleMetadata.IS_STRICT_SCHEMA_PROP, Boolean.TRUE.toString());
final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a", "c"), ScanTestUtils.parsers(), providedSchema);
// Make up a reader schema and test the projection set.
TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.BIGINT).add("c", MinorType.INT).buildSchema();
ProjectionFilter projSet = scanProj.readerProjection();
assertTrue(isProjected(projSet, readerSchema.metadata("a")));
assertFalse(isProjected(projSet, readerSchema.metadata("b")));
assertFalse(isProjected(projSet, readerSchema.metadata("c")));
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter in project drill by apache.
the class TestScanLevelProjection method testNonStrictProvidedSchema.
/**
* Non-strict provided schema, reader that offers an extra column,
* projection list includes the column.
*/
@Test
public void testNonStrictProvidedSchema() {
TupleMetadata providedSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.BIGINT).buildSchema();
final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a", "c"), ScanTestUtils.parsers(), providedSchema);
// Make up a reader schema and test the projection set.
TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.BIGINT).add("c", MinorType.INT).buildSchema();
ProjectionFilter projSet = scanProj.readerProjection();
assertTrue(isProjected(projSet, readerSchema.metadata("a")));
assertFalse(isProjected(projSet, readerSchema.metadata("b")));
assertTrue(isProjected(projSet, readerSchema.metadata("c")));
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter in project drill by apache.
the class TestScanLevelProjection method testEmptyProjection.
/**
* Test an empty projection which occurs in a
* SELECT COUNT(*) query.
*/
@Test
public void testEmptyProjection() {
final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList(), ScanTestUtils.parsers());
assertFalse(scanProj.projectAll());
assertTrue(scanProj.isEmptyProjection());
assertEquals(0, scanProj.requestedCols().size());
// Verify tuple projection
RequestedTuple outputProj = scanProj.rootProjection();
assertEquals(0, outputProj.projections().size());
// Make up a reader schema and test the projection set.
TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.INT).buildSchema();
ProjectionFilter projSet = scanProj.readerProjection();
assertFalse(isProjected(projSet, readerSchema.metadata("a")));
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter 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