use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult in project drill by apache.
the class TestDynamicSchemaFilter method testProjectList.
@Test
public void testProjectList() {
ProjectionParseResult parseResult = ScanProjectionParser.parse(RowSetTestUtils.projectList("a", "c", "m", "special"));
ProjectionFilter filter = new DynamicTupleFilter(parseResult.dynamicSchema, EmptyErrorContext.INSTANCE);
assertFalse(filter.isEmpty());
assertTrue(filter.isProjected(A_COL.name()));
ProjResult result = filter.projection(A_COL);
assertTrue(result.isProjected);
assertNotNull(result.projection);
assertTrue(result.projection.isDynamic());
assertEquals(A_COL.name(), result.projection.name());
assertFalse(filter.isProjected(B_COL.name()));
result = filter.projection(B_COL);
assertFalse(result.isProjected);
assertTrue(filter.isProjected(MAP_COL.name()));
result = filter.projection(MAP_COL);
assertTrue(result.isProjected);
assertNotNull(result.projection);
assertTrue(result.projection.isDynamic());
assertEquals(MAP_COL.name(), result.projection.name());
assertSame(ProjectionFilter.PROJECT_ALL, result.mapFilter);
assertTrue(filter.isProjected(SPECIAL_COLUMN.name()));
result = filter.projection(SPECIAL_COLUMN);
assertTrue(result.isProjected);
assertNotNull(result.projection);
assertTrue(result.projection.isDynamic());
assertEquals(SPECIAL_COLUMN.name(), result.projection.name());
assertFalse(filter.isProjected(SPECIAL_COLUMN2.name()));
result = filter.projection(SPECIAL_COLUMN2);
assertFalse(result.isProjected);
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult in project drill by apache.
the class TestDynamicSchemaFilter method testEmptyProjectList.
@Test
public void testEmptyProjectList() {
ProjectionFilter filter = ProjectionFilter.PROJECT_NONE;
assertTrue(filter.isEmpty());
assertFalse(filter.isProjected(A_COL.name()));
ProjResult result = filter.projection(A_COL);
assertFalse(result.isProjected);
assertFalse(filter.isProjected(MAP_COL.name()));
result = filter.projection(MAP_COL);
assertFalse(result.isProjected);
assertSame(ProjectionFilter.PROJECT_NONE, result.mapFilter);
assertFalse(filter.isProjected(SPECIAL_COLUMN.name()));
result = filter.projection(SPECIAL_COLUMN);
assertFalse(result.isProjected);
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult in project drill by apache.
the class TestDynamicSchemaFilter method testProjectAll.
@Test
public void testProjectAll() {
ProjectionFilter filter = ProjectionFilter.PROJECT_ALL;
assertFalse(filter.isEmpty());
assertTrue(filter.isProjected(A_COL.name()));
ProjResult result = filter.projection(A_COL);
assertTrue(result.isProjected);
assertNull(result.projection);
assertTrue(filter.isProjected(MAP_COL.name()));
result = filter.projection(MAP_COL);
assertTrue(result.isProjected);
assertNull(result.projection);
assertSame(ProjectionFilter.PROJECT_ALL, result.mapFilter);
// "Special" columns are projected only by name, but rely on
// a property in the column itself, so give inconsistent answers
// from the filter.
assertTrue(filter.isProjected(SPECIAL_COLUMN.name()));
result = filter.projection(SPECIAL_COLUMN);
assertFalse(result.isProjected);
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult 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"));
}
use of org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult in project drill by apache.
the class TestProjectionFilter method testImplicitNone.
@Test
public void testImplicitNone() {
ProjectionFilter filter = ProjectionFilter.PROJECT_NONE;
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);
}
Aggregations