Search in sources :

Example 6 with ProjectionParseResult

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

the class TestProjectionParser method testArray.

@Test
public void testArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1]", "a[3]"));
    TupleMetadata projSet = result.dynamicSchema;
    assertEquals(1, projSet.size());
    ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
    assertEquals("a", a.name());
    assertTrue(a.isArray());
    assertEquals(1, a.arrayDims());
    assertFalse(a.isSimple());
    assertFalse(a.isMap());
    assertTrue(a.hasIndexes());
    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 7 with ProjectionParseResult

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

the class TestProjectionParser method testSimpleAndArray.

@Test
public void testSimpleAndArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a", "a[1]"));
    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 8 with ProjectionParseResult

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

the class TestProjectionParser method testMapAndArray.

@Test
public void testMapAndArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("m[0]", "m.a"));
    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 9 with ProjectionParseResult

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

the class TestProjectionParser method testMultiDimArray.

@Test
public void testMultiDimArray() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[0][1][2]", "a[2][3]"));
    TupleMetadata projSet = result.dynamicSchema;
    assertEquals(1, projSet.size());
    ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
    assertEquals("a", a.name());
    assertTrue(a.isArray());
    // Dimension count is the maximum seen.
    assertEquals(3, a.arrayDims());
    assertFalse(a.isSimple());
    assertFalse(a.isMap());
    // Indexes only at the first dimension
    boolean[] indexes = a.indexes();
    assertNotNull(indexes);
    assertEquals(3, indexes.length);
    assertTrue(indexes[0]);
    assertFalse(indexes[1]);
    assertTrue(indexes[2]);
}
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 10 with ProjectionParseResult

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

the class TestProjectionParser method testWildcard.

/**
 * SELECT * means everything is projected
 */
@Test
public void testWildcard() {
    ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectAll());
    assertEquals(0, result.wildcardPosn);
    TupleMetadata projSet = result.dynamicSchema;
    assertTrue(SchemaUtils.isProjectAll(projSet));
    assertFalse(SchemaUtils.isProjectNone(projSet));
    assertTrue(projSet.isEmpty());
}
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