Search in sources :

Example 16 with ProjectionParseResult

use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.

the class TestProjectionParser method testProjectionMapAndSimple.

/**
 * Project both a map member and the entire map.
 */
@Test
public void testProjectionMapAndSimple() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("map.a", "map"));
    doTestMapAndSimple(result.dynamicSchema);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 17 with ProjectionParseResult

use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.

the class TestProjectionParser method testProjectionMapSubset.

/**
 * Selected map projection, multiple levels, full projection
 * at leaf level.
 */
@Test
public void testProjectionMapSubset() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("map.a", "map.b", "map.map2.x"));
    TupleMetadata projSet = result.dynamicSchema;
    // Map itself is projected and has a map qualifier
    ProjectedColumn map = (ProjectedColumn) projSet.metadata("map");
    assertNotNull(map);
    // Map: an explicit map-like at top level
    assertTrue(map.isMap());
    TupleMetadata mapProj = map.tupleSchema();
    assertNotNull(mapProj);
    assertFalse(SchemaUtils.isProjectAll(mapProj));
    assertFalse(SchemaUtils.isProjectNone(mapProj));
    assertNotNull(mapProj.metadata("a"));
    assertNotNull(mapProj.metadata("b"));
    assertNotNull(mapProj.metadata("map2"));
    assertNull(mapProj.metadata("bogus"));
    // Map b: an implied nested map
    ProjectedColumn b = (ProjectedColumn) mapProj.metadata("b");
    assertTrue(b.isSimple());
    // Map2, an nested map, has an explicit projection
    ProjectedColumn map2 = (ProjectedColumn) mapProj.metadata("map2");
    TupleMetadata map2Proj = map2.tupleSchema();
    assertNotNull(map2Proj);
    assertFalse(SchemaUtils.isProjectAll(map2Proj));
    assertNotNull(map2Proj.metadata("x"));
    assertNull(map2Proj.metadata("bogus"));
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 18 with ProjectionParseResult

use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.

the class TestProjectionParser method testArrayAndSimple.

@Test
public void testArrayAndSimple() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1]", "a"));
    doTestArrayAndSimple(result.dynamicSchema);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 19 with ProjectionParseResult

use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.

the class TestProjectionParser method testProjectionSimpleAndMap.

/**
 * Project both an entire map and a map member.
 */
@Test
public void testProjectionSimpleAndMap() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("map", "map.a"));
    doTestMapAndSimple(result.dynamicSchema);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 20 with ProjectionParseResult

use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult 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

EvfTest (org.apache.drill.categories.EvfTest)31 ProjectionParseResult (org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult)31 BaseTest (org.apache.drill.test.BaseTest)31 Test (org.junit.Test)31 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)21 ArrayList (java.util.ArrayList)2 SchemaPath (org.apache.drill.common.expression.SchemaPath)2 DynamicTupleFilter (org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter)2 ProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter)2 ProjResult (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult)2 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1