Search in sources :

Example 6 with ColumnsArrayParser

use of org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayParser in project drill by apache.

the class TestColumnsArrayParser method testRequiredColumnsArray.

@Test
public void testRequiredColumnsArray() {
    ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList(ColumnsScanFramework.COLUMNS_COL), ScanTestUtils.parsers(new ColumnsArrayParser(true)));
    assertFalse(scanProj.projectAll());
    assertEquals(1, scanProj.requestedCols().size());
    assertEquals(1, scanProj.columns().size());
    assertEquals(ColumnsScanFramework.COLUMNS_COL, scanProj.columns().get(0).name());
    // Verify column type
    assertTrue(scanProj.columns().get(0) instanceof UnresolvedColumnsArrayColumn);
}
Also used : UnresolvedColumnsArrayColumn(org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn) ScanLevelProjection(org.apache.drill.exec.physical.impl.scan.project.ScanLevelProjection) ColumnsArrayParser(org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayParser) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 7 with ColumnsArrayParser

use of org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayParser in project drill by apache.

the class TestColumnsArrayParser method testWildcardAndColumns.

/**
 * If a query is of the form:
 * <pre><code>
 * select * from dfs.`multilevel/csv` where columns[1] < 1000
 * </code><pre>
 * Then the projection list passed to the scan operator
 * includes both the wildcard and the `columns` array.
 * We can ignore one of them.
 */
@Test
public void testWildcardAndColumns() {
    ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList(SchemaPath.DYNAMIC_STAR, ColumnsScanFramework.COLUMNS_COL), ScanTestUtils.parsers(new ColumnsArrayParser(true)));
    assertTrue(scanProj.projectAll());
    assertEquals(2, scanProj.requestedCols().size());
    assertEquals(1, scanProj.columns().size());
    assertEquals(ColumnsScanFramework.COLUMNS_COL, scanProj.columns().get(0).name());
    // Verify column type
    assertTrue(scanProj.columns().get(0) instanceof UnresolvedColumnsArrayColumn);
}
Also used : UnresolvedColumnsArrayColumn(org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn) ScanLevelProjection(org.apache.drill.exec.physical.impl.scan.project.ScanLevelProjection) ColumnsArrayParser(org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayParser) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 8 with ColumnsArrayParser

use of org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayParser in project drill by apache.

the class TestColumnsArrayParser method testColumnsArrayCaseInsensitive.

@Test
public void testColumnsArrayCaseInsensitive() {
    // Sic: case variation of standard name
    ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("Columns"), ScanTestUtils.parsers(new ColumnsArrayParser(true)));
    assertFalse(scanProj.projectAll());
    assertEquals(1, scanProj.requestedCols().size());
    assertEquals(1, scanProj.columns().size());
    assertEquals("Columns", scanProj.columns().get(0).name());
    // Verify column type
    assertTrue(scanProj.columns().get(0) instanceof UnresolvedColumnsArrayColumn);
}
Also used : UnresolvedColumnsArrayColumn(org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn) ScanLevelProjection(org.apache.drill.exec.physical.impl.scan.project.ScanLevelProjection) ColumnsArrayParser(org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayParser) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

ColumnsArrayParser (org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayParser)8 ScanLevelProjection (org.apache.drill.exec.physical.impl.scan.project.ScanLevelProjection)8 SubOperatorTest (org.apache.drill.test.SubOperatorTest)8 Test (org.junit.Test)8 UnresolvedColumnsArrayColumn (org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn)7 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 FileMetadataColumn (org.apache.drill.exec.physical.impl.scan.file.FileMetadataColumn)1 ImplicitColumnManager (org.apache.drill.exec.physical.impl.scan.file.ImplicitColumnManager)1 Path (org.apache.hadoop.fs.Path)1