Search in sources :

Example 16 with ParseResult

use of org.apache.drill.exec.physical.impl.scan.v3.file.ImplicitColumnResolver.ParseResult in project drill by apache.

the class TestImplicitColumnResolver method testProvidedImplicitMatchesProject.

@Test
public void testProvidedImplicitMatchesProject() {
    TupleMetadata providedSchema = new SchemaBuilder().add("a", MinorType.INT).add("fqn", MinorType.VARCHAR).add("filePath", MinorType.VARCHAR).addNullable("dir0", MinorType.VARCHAR).build();
    SchemaUtils.markImplicit(providedSchema.metadata("fqn"), ColumnMetadata.IMPLICIT_FQN);
    SchemaUtils.markImplicit(providedSchema.metadata("filePath"), ColumnMetadata.IMPLICIT_FILEPATH.toUpperCase());
    SchemaUtils.markAsPartition(providedSchema.metadata("dir0"), 0);
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
    parseFixture.tracker.applyProvidedSchema(providedSchema);
    parseFixture.options.maxPartitionDepth(1);
    ParseResult result = parseFixture.parseImplicit();
    assertEquals(3, result.columns().size());
    TupleMetadata expected = new SchemaBuilder().add("fqn", MinorType.VARCHAR).add("filePath", MinorType.VARCHAR).addNullable("dir0", MinorType.VARCHAR).build();
    assertEquals(expected, result.schema());
    List<ColumnHandle> cols = parseFixture.tracker.internalSchema().columns();
    assertFalse(isImplicit(cols, 0));
    assertTrue(isImplicit(cols, 1));
    assertTrue(isImplicit(cols, 2));
    assertTrue(isImplicit(cols, 3));
}
Also used : ColumnHandle(org.apache.drill.exec.physical.impl.scan.v3.schema.MutableTupleSchema.ColumnHandle) ParseResult(org.apache.drill.exec.physical.impl.scan.v3.file.ImplicitColumnResolver.ParseResult) ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 17 with ParseResult

use of org.apache.drill.exec.physical.impl.scan.v3.file.ImplicitColumnResolver.ParseResult in project drill by apache.

the class TestDynamicSchemaFilter method testProjectList.

@Test
public void testProjectList() {
    ProjectionParseResult parseResult = ScanProjectionParser.parse(RowSetTestUtils.projectList("a", "c", "m", "special"));
    ProjectionFilter filter = new DynamicTupleFilter(parseResult.dynamicSchema, EmptyErrorContext.INSTANCE);
    assertFalse(filter.isEmpty());
    assertTrue(filter.isProjected(A_COL.name()));
    ProjResult result = filter.projection(A_COL);
    assertTrue(result.isProjected);
    assertNotNull(result.projection);
    assertTrue(result.projection.isDynamic());
    assertEquals(A_COL.name(), result.projection.name());
    assertFalse(filter.isProjected(B_COL.name()));
    result = filter.projection(B_COL);
    assertFalse(result.isProjected);
    assertTrue(filter.isProjected(MAP_COL.name()));
    result = filter.projection(MAP_COL);
    assertTrue(result.isProjected);
    assertNotNull(result.projection);
    assertTrue(result.projection.isDynamic());
    assertEquals(MAP_COL.name(), result.projection.name());
    assertSame(ProjectionFilter.PROJECT_ALL, result.mapFilter);
    assertTrue(filter.isProjected(SPECIAL_COLUMN.name()));
    result = filter.projection(SPECIAL_COLUMN);
    assertTrue(result.isProjected);
    assertNotNull(result.projection);
    assertTrue(result.projection.isDynamic());
    assertEquals(SPECIAL_COLUMN.name(), result.projection.name());
    assertFalse(filter.isProjected(SPECIAL_COLUMN2.name()));
    result = filter.projection(SPECIAL_COLUMN2);
    assertFalse(result.isProjected);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) ProjectionFilter(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter) DynamicTupleFilter(org.apache.drill.exec.physical.impl.scan.v3.schema.DynamicSchemaFilter.DynamicTupleFilter) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) EvfTest(org.apache.drill.categories.EvfTest)

Aggregations

EvfTest (org.apache.drill.categories.EvfTest)17 ProjectionParseResult (org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult)17 Test (org.junit.Test)17 ParseResult (org.apache.drill.exec.physical.impl.scan.v3.file.ImplicitColumnResolver.ParseResult)15 SubOperatorTest (org.apache.drill.test.SubOperatorTest)15 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)11 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)11 ColumnHandle (org.apache.drill.exec.physical.impl.scan.v3.schema.MutableTupleSchema.ColumnHandle)7 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 BaseTest (org.apache.drill.test.BaseTest)2 ImplicitColumnOptions (org.apache.drill.exec.physical.impl.scan.v3.file.ImplicitColumnResolver.ImplicitColumnOptions)1 ScanSchemaConfigBuilder (org.apache.drill.exec.physical.impl.scan.v3.schema.ScanSchemaConfigBuilder)1 ScanSchemaTracker (org.apache.drill.exec.physical.impl.scan.v3.schema.ScanSchemaTracker)1 SchemaBasedTracker (org.apache.drill.exec.physical.impl.scan.v3.schema.SchemaBasedTracker)1 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 DrillFileSystem (org.apache.drill.exec.store.dfs.DrillFileSystem)1 Configuration (org.apache.hadoop.conf.Configuration)1