use of org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn in project drill by apache.
the class TestColumnsArrayParser method testColumnsElements.
@Test
public void testColumnsElements() {
ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList(ColumnsScanFramework.COLUMNS_COL + "[3]", ColumnsScanFramework.COLUMNS_COL + "[1]"), ScanTestUtils.parsers(new ColumnsArrayParser(true)));
assertFalse(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);
UnresolvedColumnsArrayColumn colsCol = (UnresolvedColumnsArrayColumn) scanProj.columns().get(0);
boolean[] indexes = colsCol.selectedIndexes();
assertNotNull(indexes);
assertEquals(4, indexes.length);
assertFalse(indexes[0]);
assertTrue(indexes[1]);
assertFalse(indexes[0]);
assertTrue(indexes[1]);
}
use of org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn in project drill by apache.
the class TestColumnsArrayParser method testMetadataColumnsWithColumnsArray.
/**
* The `columns` column is special: can't be used with other column names.
* Make sure that the rule <i>does not</i> apply to implicit columns.
*/
@Test
public void testMetadataColumnsWithColumnsArray() {
Path filePath = new Path("hdfs:///w/x/y/z.csv");
ImplicitColumnManager metadataManager = new ImplicitColumnManager(fixture.getOptionManager(), standardOptions(filePath));
ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList(ScanTestUtils.FILE_NAME_COL, ColumnsScanFramework.COLUMNS_COL, ScanTestUtils.SUFFIX_COL), ScanTestUtils.parsers(new ColumnsArrayParser(true), metadataManager.projectionParser()));
assertFalse(scanProj.projectAll());
assertEquals(3, scanProj.columns().size());
assertEquals(ScanTestUtils.FILE_NAME_COL, scanProj.columns().get(0).name());
assertEquals(ColumnsScanFramework.COLUMNS_COL, scanProj.columns().get(1).name());
assertEquals(ScanTestUtils.SUFFIX_COL, scanProj.columns().get(2).name());
// Verify column type
assertTrue(scanProj.columns().get(0) instanceof FileMetadataColumn);
assertTrue(scanProj.columns().get(1) instanceof UnresolvedColumnsArrayColumn);
assertTrue(scanProj.columns().get(2) instanceof FileMetadataColumn);
}
use of org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn in project drill by apache.
the class TestColumnsArrayParser method testColumnsArray.
/**
* Test the special "columns" column that asks to return all columns
* as an array. No need for early schema. This case is special: it actually
* creates the one and only table column to match the desired output column.
*/
@Test
public void testColumnsArray() {
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);
}
use of org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn in project drill by apache.
the class TestColumnsArrayParser method testRequiredWildcard.
@Test
public void testRequiredWildcard() {
ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectAll(), ScanTestUtils.parsers(new ColumnsArrayParser(true)));
assertTrue(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);
}
use of org.apache.drill.exec.physical.impl.scan.columns.UnresolvedColumnsArrayColumn 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);
}
Aggregations