Search in sources :

Example 21 with ProjectionParseResult

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

the class TestProjectionParser method testArrayAndMap.

/**
 * Projection does not enforce semantics; it just report what it
 * sees. This allows cases such as m.a and m[0], which might mean
 * that m is a map array, m.a wants an array of a-member values, and m[0]
 * wants the first map in the array. Not clear Drill actually supports
 * these cases, however.
 */
@Test
public void testArrayAndMap() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("m.a", "m[0]"));
    doTestArrayAndMap(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 22 with ProjectionParseResult

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

the class TestProjectionParser method testMapDups.

/**
 * Duplicate column names are merged for projection.
 */
@Test
public void testMapDups() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a.b", "a.c", "a.b"));
    TupleMetadata projSet = result.dynamicSchema;
    ProjectedColumn a = (ProjectedColumn) projSet.metadata("a");
    TupleMetadata aMap = a.tupleSchema();
    assertEquals(2, aMap.size());
    assertEquals(2, ((ProjectedColumn) aMap.metadata("b")).refCount());
}
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 23 with ProjectionParseResult

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

the class TestProjectionParser method testMapArray.

@Test
public // Drill syntax does not support map arrays
void testMapArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1].x"));
    TupleMetadata projSet = result.dynamicSchema;
    assertEquals(1, projSet.size());
    ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
    // Column acts like an array
    assertTrue(a.isArray());
    assertTrue(a.hasIndexes());
    assertEquals(1, a.arrayDims());
    // And the column acts like a map
    assertTrue(a.isMap());
    TupleMetadata aProj = a.tupleSchema();
    assertFalse(SchemaUtils.isProjectAll(aProj));
    assertFalse(SchemaUtils.isProjectNone(aProj));
    assertNotNull(aProj.metadata("x"));
    assertNull(aProj.metadata("y"));
}
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 24 with ProjectionParseResult

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

the class TestProjectionParser method testMap2DArray.

@Test
public // Drill syntax does not support map arrays
void testMap2DArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1][2].x"));
    TupleMetadata projSet = result.dynamicSchema;
    assertEquals(1, projSet.size());
    ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
    // Column acts like an array
    assertTrue(a.isArray());
    assertTrue(a.hasIndexes());
    // Note that the multiple dimensions are inferred only through
    // the multiple levels of qualifiers.
    // And the column acts like a map
    assertTrue(a.isMap());
    TupleMetadata aProj = a.tupleSchema();
    assertNotNull(aProj.metadata("x"));
    assertNull(aProj.metadata("y"));
}
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 25 with ProjectionParseResult

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

the class TestProjectionParser method testSimpleDups.

/**
 * The projection set does not enforce uniqueness.
 */
@Test
public void testSimpleDups() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a", "b", "a"));
    assertEquals(-1, result.wildcardPosn);
    TupleMetadata projSet = result.dynamicSchema;
    assertEquals(2, projSet.size());
    assertEquals(2, ((ProjectedColumn) projSet.metadata("a")).refCount());
}
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