Search in sources :

Example 1 with DynamicTupleFilter

use of org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter in project drill by apache.

the class ScanSchemaResolver method mergeWithConcrete.

/**
 * Merge an incoming column with an existing resolved column. Non-map columns
 * must match. Maps are merged recursively.
 */
private void mergeWithConcrete(ColumnMetadata existing, ColumnMetadata revised) {
    SchemaUtils.verifyConsistency(existing, revised, source, errorContext);
    if (existing.isMap()) {
        ProjectionFilter filter = new DynamicTupleFilter(existing.tupleSchema(), allowMapAdditions, errorContext, source);
        expandMapProjection(existing.tupleSchema(), filter, revised.tupleSchema());
    }
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) DynamicTupleFilter(org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter)

Example 2 with DynamicTupleFilter

use of org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter in project drill by apache.

the class TestDynamicSchemaFilter method testMapProjectList.

@Test
public void testMapProjectList() {
    ProjectionParseResult parseResult = ScanProjectionParser.parse(RowSetTestUtils.projectList("m.x"));
    ProjectionFilter filter = new DynamicTupleFilter(parseResult.dynamicSchema, EmptyErrorContext.INSTANCE);
    assertFalse(filter.isEmpty());
    assertTrue(filter.isProjected(MAP_COL.name()));
    ProjResult result = filter.projection(MAP_COL);
    assertTrue(result.isProjected);
    assertNotNull(result.projection);
    assertTrue(result.projection.isDynamic());
    assertEquals(MAP_COL.name(), result.projection.name());
    assertTrue(result.mapFilter instanceof DynamicTupleFilter);
    ProjectionFilter mapFilter = result.mapFilter;
    ColumnMetadata x_col = MAP_COL.tupleSchema().metadata("x");
    assertTrue(mapFilter.isProjected("x"));
    result = mapFilter.projection(x_col);
    assertTrue(result.isProjected);
    assertNotNull(result.projection);
    assertTrue(result.projection.isDynamic());
    assertEquals(x_col.name(), result.projection.name());
    ColumnMetadata y_col = MAP_COL.tupleSchema().metadata("y");
    assertFalse(mapFilter.isProjected("y"));
    result = mapFilter.projection(y_col);
    assertFalse(result.isProjected);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) DynamicTupleFilter(org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 3 with DynamicTupleFilter

use of org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter 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);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) DynamicTupleFilter(org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Aggregations

DynamicTupleFilter (org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter)3 ProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter)3 EvfTest (org.apache.drill.categories.EvfTest)2 ProjectionParseResult (org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult)2 ProjResult (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult)2 BaseTest (org.apache.drill.test.BaseTest)2 Test (org.junit.Test)2 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1