Search in sources :

Example 11 with UnresolvedColumn

use of org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn in project drill by apache.

the class TestScanLevelProjection method testEmptyProvidedSchema.

@Test
public void testEmptyProvidedSchema() {
    TupleMetadata providedSchema = new SchemaBuilder().buildSchema();
    // Simulate SELECT a
    final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a"), ScanTestUtils.parsers(), providedSchema);
    assertEquals(ScanProjectionType.EXPLICIT, scanProj.projectionType());
    assertEquals(1, scanProj.columns().size());
    assertEquals("a", scanProj.columns().get(0).name());
    assertTrue(scanProj.columns().get(0) instanceof UnresolvedColumn);
}
Also used : UnresolvedColumn(org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 12 with UnresolvedColumn

use of org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn in project drill by apache.

the class TestScanLevelProjection method testBasics.

/**
 * Basic test: select a set of columns (a, b, c) when the
 * data source has an early schema of (a, c, d). (a, c) are
 * projected, (d) is null.
 */
@Test
public void testBasics() {
    // Simulate SELECT a, b, c ...
    // Build the projection plan and verify
    final ScanLevelProjection scanProj = ScanLevelProjection.build(RowSetTestUtils.projectList("a", "b", "c"), ScanTestUtils.parsers());
    assertFalse(scanProj.projectAll());
    assertFalse(scanProj.isEmptyProjection());
    assertEquals(3, scanProj.requestedCols().size());
    assertEquals("a", scanProj.requestedCols().get(0).rootName());
    assertEquals("b", scanProj.requestedCols().get(1).rootName());
    assertEquals("c", scanProj.requestedCols().get(2).rootName());
    assertEquals(3, scanProj.columns().size());
    assertEquals("a", scanProj.columns().get(0).name());
    assertEquals("b", scanProj.columns().get(1).name());
    assertEquals("c", scanProj.columns().get(2).name());
    // Verify column type
    assertTrue(scanProj.columns().get(0) instanceof UnresolvedColumn);
    // Verify tuple projection
    RequestedTuple outputProj = scanProj.rootProjection();
    assertEquals(3, outputProj.projections().size());
    assertNotNull(outputProj.get("a"));
    assertTrue(outputProj.get("a").isSimple());
    // Make up a reader schema and test the projection set.
    TupleMetadata readerSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.INT).add("c", MinorType.INT).add("d", MinorType.INT).buildSchema();
    ProjectionFilter projSet = scanProj.readerProjection();
    assertTrue(isProjected(projSet, readerSchema.metadata("a")));
    assertFalse(isProjected(projSet, readerSchema.metadata("d")));
}
Also used : ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) UnresolvedColumn(org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn) RequestedTuple(org.apache.drill.exec.physical.resultSet.project.RequestedTuple) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Aggregations

UnresolvedColumn (org.apache.drill.exec.physical.impl.scan.project.AbstractUnresolvedColumn.UnresolvedColumn)12 SubOperatorTest (org.apache.drill.test.SubOperatorTest)10 Test (org.junit.Test)10 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)8 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)8 EvfTest (org.apache.drill.categories.EvfTest)6 ProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter)5 FileMetadataColumn (org.apache.drill.exec.physical.impl.scan.file.FileMetadataColumn)3 ImplicitColumnManager (org.apache.drill.exec.physical.impl.scan.file.ImplicitColumnManager)3 ScanLevelProjection (org.apache.drill.exec.physical.impl.scan.project.ScanLevelProjection)3 RequestedTuple (org.apache.drill.exec.physical.resultSet.project.RequestedTuple)3 Path (org.apache.hadoop.fs.Path)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)2 ColumnProjection (org.apache.drill.exec.physical.impl.scan.project.ColumnProjection)2 NullBuilderBuilder (org.apache.drill.exec.physical.impl.scan.project.NullColumnBuilder.NullBuilderBuilder)2 ResolvedRow (org.apache.drill.exec.physical.impl.scan.project.ResolvedTuple.ResolvedRow)2 RequestedColumn (org.apache.drill.exec.physical.resultSet.project.RequestedColumn)2 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)2 PartitionColumn (org.apache.drill.exec.physical.impl.scan.file.PartitionColumn)1 ExplicitSchemaProjection (org.apache.drill.exec.physical.impl.scan.project.ExplicitSchemaProjection)1