Search in sources :

Example 16 with ProjectionFilter

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);
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 17 with ProjectionFilter

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")));
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 18 with ProjectionFilter

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")));
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 19 with ProjectionFilter

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")));
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) RequestedTuple(org.apache.drill.exec.physical.resultSet.project.RequestedTuple) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 20 with ProjectionFilter

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")));
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) UnresolvedColumn(org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn) RequestedTuple(org.apache.drill.exec.physical.resultSet.project.RequestedTuple) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Aggregations

ProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter)42 EvfTest (org.apache.drill.categories.EvfTest)36 Test (org.junit.Test)36 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)35 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)33 BaseTest (org.apache.drill.test.BaseTest)24 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)13 SubOperatorTest (org.apache.drill.test.SubOperatorTest)12 ProjResult (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult)7 RequestedTuple (org.apache.drill.exec.physical.resultSet.project.RequestedTuple)6 UnresolvedColumn (org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn)5 UserException (org.apache.drill.common.exceptions.UserException)3 DynamicTupleFilter (org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter)3 ProjectionParseResult (org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult)2 RequestedColumn (org.apache.drill.exec.physical.resultSet.project.RequestedColumn)2 UnresolvedWildcardColumn (org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedWildcardColumn)1