Search in sources :

Example 1 with DirectProjectionFilter

use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter in project drill by apache.

the class TestProjectionFilter method testProjectList.

@Test
public void testProjectList() {
    RequestedTuple projSet = Projections.parse(RowSetTestUtils.projectList("a", "c", "m.a"));
    ProjectionFilter filter = new DirectProjectionFilter(projSet, EmptyErrorContext.INSTANCE);
    assertTrue(filter.isProjected("a"));
    assertTrue(filter.projection(A_COL).isProjected);
    assertFalse(filter.isProjected("b"));
    assertFalse(filter.projection(B_COL).isProjected);
    assertFalse(filter.isEmpty());
    ProjResult result = filter.projection(MAP_COL);
    assertTrue(result.isProjected);
    ProjectionFilter child = result.mapFilter;
    assertTrue(child.isProjected("a"));
    assertFalse(child.isProjected("b"));
    result = filter.projection(MAP_COL2);
    assertFalse(result.isProjected);
    assertSame(ProjectionFilter.PROJECT_NONE, result.mapFilter);
}
Also used : DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) SchemaProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.SchemaProjectionFilter) TypeProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.TypeProjectionFilter) DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) CompoundProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter) RequestedTuple(org.apache.drill.exec.physical.resultSet.project.RequestedTuple) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 2 with DirectProjectionFilter

use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter in project drill by apache.

the class TestProjectionFilter method testBuilders.

@Test
public void testBuilders() {
    assertSame(ProjectionFilter.PROJECT_ALL, ProjectionFilter.projectionFilter(Projections.projectAll(), EmptyErrorContext.INSTANCE));
    assertSame(ProjectionFilter.PROJECT_NONE, ProjectionFilter.projectionFilter(Projections.projectNone(), EmptyErrorContext.INSTANCE));
    assertTrue(ProjectionFilter.projectionFilter(Projections.parse(RowSetTestUtils.projectList("a")), EmptyErrorContext.INSTANCE) instanceof DirectProjectionFilter);
    TupleMetadata schema = new SchemaBuilder().add(A_COL.copy()).add(B_COL.copy()).build();
    assertSame(ProjectionFilter.PROJECT_NONE, ProjectionFilter.definedSchemaFilter(new TupleSchema(), EmptyErrorContext.INSTANCE));
    assertTrue(ProjectionFilter.definedSchemaFilter(schema, EmptyErrorContext.INSTANCE) instanceof SchemaProjectionFilter);
    assertTrue(ProjectionFilter.providedSchemaFilter(Projections.projectAll(), schema, EmptyErrorContext.INSTANCE) instanceof CompoundProjectionFilter);
    assertSame(ProjectionFilter.PROJECT_NONE, ProjectionFilter.providedSchemaFilter(Projections.projectNone(), schema, EmptyErrorContext.INSTANCE));
    assertSame(ProjectionFilter.PROJECT_ALL, ProjectionFilter.providedSchemaFilter(Projections.projectAll(), new TupleSchema(), EmptyErrorContext.INSTANCE));
    TupleMetadata strictEmpty = new TupleSchema();
    strictEmpty.setBooleanProperty(TupleMetadata.IS_STRICT_SCHEMA_PROP, true);
    assertSame(ProjectionFilter.PROJECT_NONE, ProjectionFilter.providedSchemaFilter(Projections.projectAll(), strictEmpty, EmptyErrorContext.INSTANCE));
    assertTrue(ProjectionFilter.providedSchemaFilter(Projections.parse(RowSetTestUtils.projectList("a")), schema, EmptyErrorContext.INSTANCE) instanceof CompoundProjectionFilter);
}
Also used : SchemaProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.SchemaProjectionFilter) DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema) CompoundProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 3 with DirectProjectionFilter

use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter in project drill by apache.

the class TestProjectionFilter method testEmptyProjectList.

@Test
public void testEmptyProjectList() {
    ProjectionFilter filter = new DirectProjectionFilter(Projections.projectNone(), EmptyErrorContext.INSTANCE);
    assertFalse(filter.isProjected("a"));
    assertFalse(filter.projection(A_COL).isProjected);
    assertTrue(filter.isEmpty());
    ProjResult result = filter.projection(MAP_COL);
    assertFalse(result.isProjected);
    assertSame(ProjectionFilter.PROJECT_NONE, result.mapFilter);
}
Also used : DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) SchemaProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.SchemaProjectionFilter) TypeProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.TypeProjectionFilter) DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) CompoundProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 4 with DirectProjectionFilter

use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter in project drill by apache.

the class TestProjectionFilter method testCompoundMap.

@Test
public void testCompoundMap() {
    TupleMetadata schema = new SchemaBuilder().add(A_COL.copy()).add(B_COL.copy()).addMap("m").add("a", MinorType.INT).add("b", MinorType.INT).resumeSchema().build();
    ProjectionFilter filter = new CompoundProjectionFilter(new DirectProjectionFilter(Projections.parse(RowSetTestUtils.projectList("a", "c", "m.a")), EmptyErrorContext.INSTANCE), new SchemaProjectionFilter(schema, EmptyErrorContext.INSTANCE));
    ProjResult result = filter.projection(MAP_COL);
    assertTrue(result.isProjected);
    assertTrue(result.mapFilter.isProjected("a"));
}
Also used : SchemaProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.SchemaProjectionFilter) DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) SchemaProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.SchemaProjectionFilter) TypeProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.TypeProjectionFilter) DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) CompoundProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) CompoundProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 5 with DirectProjectionFilter

use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter in project drill by apache.

the class TestProjectionFilter method testGenericMap.

@Test
public void testGenericMap() {
    RequestedTuple projSet = Projections.parse(RowSetTestUtils.projectList("a", "m"));
    ProjectionFilter filter = new DirectProjectionFilter(projSet, EmptyErrorContext.INSTANCE);
    assertTrue(filter.isProjected("a"));
    ProjResult result = filter.projection(MAP_COL);
    assertTrue(result.isProjected);
    assertSame(ProjectionFilter.PROJECT_ALL, result.mapFilter);
}
Also used : DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) SchemaProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.SchemaProjectionFilter) TypeProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.TypeProjectionFilter) DirectProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter) CompoundProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter) RequestedTuple(org.apache.drill.exec.physical.resultSet.project.RequestedTuple) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Aggregations

CompoundProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter)5 DirectProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter)5 SchemaProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.SchemaProjectionFilter)5 BaseTest (org.apache.drill.test.BaseTest)5 Test (org.junit.Test)5 ProjResult (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult)4 TypeProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.TypeProjectionFilter)4 RequestedTuple (org.apache.drill.exec.physical.resultSet.project.RequestedTuple)2 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)2 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)2 TupleSchema (org.apache.drill.exec.record.metadata.TupleSchema)1