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));
}
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);
}
Aggregations