Search in sources :

Example 11 with ProjectionParseResult

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

the class TestProjectionParser method testProjectionMapAndWildcard.

/**
 * Project both a map member and the entire map.
 */
@Test
public void testProjectionMapAndWildcard() {
    // Built up by hand because "map.*" is not valid Drill
    // expression syntax.
    List<SchemaPath> projCols = new ArrayList<>();
    projCols.add(SchemaPath.getCompoundPath("map", "a"));
    projCols.add(SchemaPath.getCompoundPath("map", SchemaPath.DYNAMIC_STAR));
    ProjectionParseResult result = ScanProjectionParser.parse(projCols);
    assertEquals(-1, result.wildcardPosn);
    TupleMetadata projSet = result.dynamicSchema;
    doTestMapAndSimple(projSet);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) SchemaPath(org.apache.drill.common.expression.SchemaPath) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 12 with ProjectionParseResult

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

the class TestProjectionParser method testProjectionWildcardAndMap.

/**
 * Project both an entire map and a map member.
 */
@Test
public void testProjectionWildcardAndMap() {
    List<SchemaPath> projCols = new ArrayList<>();
    projCols.add(SchemaPath.getCompoundPath("map", SchemaPath.DYNAMIC_STAR));
    projCols.add(SchemaPath.getCompoundPath("map", "a"));
    ProjectionParseResult result = ScanProjectionParser.parse(projCols);
    assertEquals(-1, result.wildcardPosn);
    TupleMetadata projSet = result.dynamicSchema;
    doTestMapAndSimple(projSet);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) SchemaPath(org.apache.drill.common.expression.SchemaPath) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Example 13 with ProjectionParseResult

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

the class TestProjectionParser method testMapDetails.

@Test
public void testMapDetails() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a.b.c", "a.c", "d"));
    TupleMetadata projSet = result.dynamicSchema;
    assertEquals(2, projSet.size());
    ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
    assertEquals("a", a.name());
    assertFalse(a.isSimple());
    assertFalse(a.isArray());
    assertTrue(a.isMap());
    // a{}
    TupleMetadata aMembers = a.tupleSchema();
    assertNotNull(aMembers);
    assertEquals(2, aMembers.size());
    // a.b
    ProjectedColumn a_b = (ProjectedColumn) aMembers.metadata(0);
    assertEquals("b", a_b.name());
    assertTrue(a_b.isMap());
    // a.b{}
    TupleMetadata a_bMembers = a_b.tupleSchema();
    assertNotNull(a_bMembers);
    assertEquals(1, a_bMembers.size());
    // a.b.c
    ProjectedColumn a_b_c = (ProjectedColumn) a_bMembers.metadata(0);
    assertNotNull(a_b_c);
    assertEquals("c", a_b_c.name());
    assertTrue(a_b_c.isSimple());
    // a.c
    ProjectedColumn a_c = (ProjectedColumn) aMembers.metadata(1);
    assertNotNull(a_c);
    assertEquals("c", a_c.name());
    assertTrue(a_c.isSimple());
    // d
    ProjectedColumn d = (ProjectedColumn) projSet.metadata(1);
    assertNotNull(d);
    assertEquals("d", d.name());
    assertTrue(d.isSimple());
}
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 14 with ProjectionParseResult

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

the class TestProjectionParser method testArrayDupsIgnored.

/**
 * Duplicate array entries are allowed to handle the
 * use case of a[1], a[1].z. Each element is reported once;
 * the project operator will create copies as needed.
 */
@Test
public void testArrayDupsIgnored() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1]", "a[3]", "a[1]", "a[3].z"));
    TupleMetadata projSet = result.dynamicSchema;
    assertEquals(1, projSet.size());
    ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
    assertEquals("a", a.name());
    assertTrue(a.isArray());
    boolean[] indexes = a.indexes();
    assertNotNull(indexes);
    assertEquals(4, indexes.length);
    assertFalse(indexes[0]);
    assertTrue(indexes[1]);
    assertFalse(indexes[2]);
    assertTrue(indexes[3]);
}
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 15 with ProjectionParseResult

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

the class TestProjectionParser method testProjectionSimple.

/**
 * Simple non-map columns
 */
@Test
public void testProjectionSimple() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a", "b", "c"));
    assertEquals(-1, result.wildcardPosn);
    TupleMetadata projSet = result.dynamicSchema;
    assertFalse(SchemaUtils.isProjectAll(projSet));
    assertFalse(SchemaUtils.isProjectNone(projSet));
    assertNotNull(projSet.metadata("a"));
    assertNotNull(projSet.metadata("b"));
    assertNotNull(projSet.metadata("c"));
    assertNull(projSet.metadata("d"));
    assertEquals(3, projSet.size());
    ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
    assertEquals("a", a.name());
    assertTrue(a.isSimple());
    assertFalse(a.isArray());
    assertFalse(a.isMap());
    assertNull(a.tupleSchema());
}
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)

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