Search in sources :

Example 1 with ProjectionParseResult

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

the class TestProjectedPath method test3DArray.

@Test
public void test3DArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[0][1][2]"));
    TupleMetadata projSet = result.dynamicSchema;
    assertNotConsistent(projSet, INT_COLUMN);
    assertNotConsistent(projSet, INT_ARRAY_COLUMN);
    assertNotConsistent(projSet, MAP_COLUMN);
    assertNotConsistent(projSet, MAP_ARRAY_COLUMN);
    assertConsistent(projSet, UNION_COLUMN);
    assertConsistent(projSet, LIST_COLUMN);
    assertConsistent(projSet, DICT_INT_INT_COLUMN);
// TODO: Enforce specific DICT keys, if needed.
// assertDictNotConsistent(projSet, DICT_INT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_INT_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_INT_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_BIGINT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_BIGINT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_VARCHAR_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_VARCHAR_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_VARCHAR_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_DOUBLE_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_DOUBLE_INT_COLUMN);
}
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 2 with ProjectionParseResult

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

the class TestProjectedPath method test2DArray.

@Test
public void test2DArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[0][1]"));
    TupleMetadata projSet = result.dynamicSchema;
    assertNotConsistent(projSet, INT_COLUMN);
    assertNotConsistent(projSet, INT_ARRAY_COLUMN);
    assertNotConsistent(projSet, MAP_COLUMN);
    assertNotConsistent(projSet, MAP_ARRAY_COLUMN);
    assertConsistent(projSet, UNION_COLUMN);
    assertConsistent(projSet, LIST_COLUMN);
    assertConsistent(projSet, DICT_INT_INT_COLUMN);
// TODO: Enforce specific DICT keys, if needed.
// assertDictNotConsistent(projSet, DICT_INT_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_INT_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_INT_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_BIGINT_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_BIGINT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_VARCHAR_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_VARCHAR_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_VARCHAR_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_DOUBLE_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_DOUBLE_INT_COLUMN);
}
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 3 with ProjectionParseResult

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

the class TestProjectedPath method testMap.

@Test
public void testMap() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a.b"));
    TupleMetadata projSet = result.dynamicSchema;
    assertNotConsistent(projSet, INT_COLUMN);
    assertNotConsistent(projSet, INT_ARRAY_COLUMN);
    assertConsistent(projSet, MAP_COLUMN);
    assertConsistent(projSet, MAP_ARRAY_COLUMN);
    // A UNION could contain a map, which would allow the
    // a.b path to be valid.
    assertConsistent(projSet, UNION_COLUMN);
    // A LIST could be a list of MAPs, so a.b could mean
    // to pick out the b column in all array entries.
    assertConsistent(projSet, LIST_COLUMN);
    assertConsistent(projSet, DICT_INT_INT_COLUMN);
// TODO: Enforce specific DICT keys, if needed.
// assertDictNotConsistent(projSet, DICT_INT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_INT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_INT_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_BIGINT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_BIGINT_INT_COLUMN);
// assertDictConsistent(projSet, DICT_VARCHAR_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_VARCHAR_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_VARCHAR_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_DOUBLE_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_DOUBLE_INT_COLUMN);
}
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 4 with ProjectionParseResult

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

the class TestProjectedPath method testMapArray.

@Test
public void testMapArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[0].b"));
    TupleMetadata projSet = result.dynamicSchema;
    assertNotConsistent(projSet, INT_COLUMN);
    assertNotConsistent(projSet, INT_ARRAY_COLUMN);
    assertNotConsistent(projSet, MAP_COLUMN);
    assertConsistent(projSet, MAP_ARRAY_COLUMN);
    // A UNION could contain a repeated map, which would allow the
    // a.b path to be valid.
    assertConsistent(projSet, UNION_COLUMN);
    // A LIST could contain MAPs.
    assertConsistent(projSet, LIST_COLUMN);
    assertConsistent(projSet, DICT_INT_INT_COLUMN);
// TODO: Enforce specific DICT keys, if needed.
// assertDictNotConsistent(projSet, DICT_INT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_INT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_INT_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_BIGINT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_BIGINT_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_VARCHAR_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_VARCHAR_INT_COLUMN);
// assertDictConsistent(projSet, DICT_ARRAY_VARCHAR_INT_ARRAY_COLUMN);
// assertDictNotConsistent(projSet, DICT_DOUBLE_INT_COLUMN);
// assertDictNotConsistent(projSet, DICT_ARRAY_DOUBLE_INT_COLUMN);
}
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 5 with ProjectionParseResult

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

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