Search in sources :

Example 1 with ParseResult

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

the class TestImplicitColumnResolver method testLegacyWildcardAndImplicitColsMixed.

/**
 * As above, but include implicit columns before and after the wildcard.
 * Include both a wildcard and a partition column. The wildcard, in legacy
 * mode, will create partition columns for any partitions not mentioned in the
 * project list.
 */
@Test
public void testLegacyWildcardAndImplicitColsMixed() {
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList(ScanTestUtils.FILE_NAME_COL, SchemaPath.DYNAMIC_STAR, ScanTestUtils.SUFFIX_COL, ScanTestUtils.partitionColName(0)));
    parseFixture.options.maxPartitionDepth(3).useLegacyWildcardExpansion(true);
    ParseResult result = parseFixture.parseImplicit();
    TupleMetadata expected = new SchemaBuilder().add(ScanTestUtils.FILE_NAME_COL, MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(1), MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(2), MinorType.VARCHAR).add(ScanTestUtils.SUFFIX_COL, MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(0), MinorType.VARCHAR).build();
    assertEquals(expected, result.schema());
}
Also used : 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 2 with ParseResult

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

the class TestImplicitColumnResolver method testImplicitOnly.

@Test
public void testImplicitOnly() {
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList(ScanTestUtils.FULLY_QUALIFIED_NAME_COL, ScanTestUtils.FILE_NAME_COL));
    ParseResult result = parseFixture.parseImplicit();
    assertEquals(2, result.columns().size());
    assertTrue(parseFixture.tracker.isResolved());
    assertSame(ProjectionType.NONE, parseFixture.tracker.projectionType());
}
Also used : ParseResult(org.apache.drill.exec.physical.impl.scan.v3.file.ImplicitColumnResolver.ParseResult) ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 3 with ParseResult

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

the class TestImplicitColumnResolver method testNoImplicitCols.

@Test
public void testNoImplicitCols() {
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList("a", "b", "c"));
    ParseResult result = parseFixture.parseImplicit();
    assertTrue(result.columns().isEmpty());
    assertTrue(result.schema().isEmpty());
    assertFalse(result.isMetadataScan());
}
Also used : ParseResult(org.apache.drill.exec.physical.impl.scan.v3.file.ImplicitColumnResolver.ParseResult) ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 4 with ParseResult

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

the class TestImplicitColumnResolver method testLegacyWildcardAndImplictCols.

/**
 * Combine wildcard and file metadata columns. The wildcard expands
 * table columns but not metadata columns.
 */
@Test
public void testLegacyWildcardAndImplictCols() {
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList(SchemaPath.DYNAMIC_STAR, ScanTestUtils.FILE_NAME_COL, ScanTestUtils.SUFFIX_COL));
    parseFixture.options.maxPartitionDepth(2).useLegacyWildcardExpansion(true);
    ParseResult result = parseFixture.parseImplicit();
    TupleMetadata expected = new SchemaBuilder().addNullable(ScanTestUtils.partitionColName(0), MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(1), MinorType.VARCHAR).add(ScanTestUtils.FILE_NAME_COL, MinorType.VARCHAR).add(ScanTestUtils.SUFFIX_COL, MinorType.VARCHAR).build();
    assertEquals(expected, result.schema());
}
Also used : 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 5 with ParseResult

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

the class TestDynamicSchemaFilter method testMapProjectList.

@Test
public void testMapProjectList() {
    ProjectionParseResult parseResult = ScanProjectionParser.parse(RowSetTestUtils.projectList("m.x"));
    ProjectionFilter filter = new DynamicTupleFilter(parseResult.dynamicSchema, EmptyErrorContext.INSTANCE);
    assertFalse(filter.isEmpty());
    assertTrue(filter.isProjected(MAP_COL.name()));
    ProjResult result = filter.projection(MAP_COL);
    assertTrue(result.isProjected);
    assertNotNull(result.projection);
    assertTrue(result.projection.isDynamic());
    assertEquals(MAP_COL.name(), result.projection.name());
    assertTrue(result.mapFilter instanceof DynamicTupleFilter);
    ProjectionFilter mapFilter = result.mapFilter;
    ColumnMetadata x_col = MAP_COL.tupleSchema().metadata("x");
    assertTrue(mapFilter.isProjected("x"));
    result = mapFilter.projection(x_col);
    assertTrue(result.isProjected);
    assertNotNull(result.projection);
    assertTrue(result.projection.isDynamic());
    assertEquals(x_col.name(), result.projection.name());
    ColumnMetadata y_col = MAP_COL.tupleSchema().metadata("y");
    assertFalse(mapFilter.isProjected("y"));
    result = mapFilter.projection(y_col);
    assertFalse(result.isProjected);
}
Also used : ProjectionParseResult(org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) 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