Search in sources :

Example 11 with ParseResult

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

the class TestImplicitColumnResolver method testPartitionColumnSelection.

@Test
public void testPartitionColumnSelection() {
    String dir0 = ScanTestUtils.partitionColName(0);
    // Sic: case insensitivity, but name in project list
    // is preferred over "natural" name.
    String dir1 = "DIR1";
    String dir2 = ScanTestUtils.partitionColName(2);
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList(dir2, dir1, dir0, "a"));
    ParseResult result = parseFixture.parseImplicit();
    assertFalse(result.isMetadataScan());
    assertEquals(3, result.columns().size());
    TupleMetadata expected = new SchemaBuilder().addNullable(dir2, MinorType.VARCHAR).addNullable(dir1, MinorType.VARCHAR).addNullable(dir0, MinorType.VARCHAR).build();
    assertEquals(expected, result.schema());
    List<ColumnHandle> cols = parseFixture.tracker.internalSchema().columns();
    assertTrue(isImplicit(cols, 0));
    assertTrue(isImplicit(cols, 1));
    assertTrue(isImplicit(cols, 2));
    assertFalse(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 12 with ParseResult

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

the class TestImplicitColumnResolver method testRevisedWildcard.

@Test
public void testRevisedWildcard() {
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
    parseFixture.options.maxPartitionDepth(3).useLegacyWildcardExpansion(false);
    ParseResult result = parseFixture.parseImplicit();
    assertTrue(result.columns().isEmpty());
    assertTrue(result.schema().isEmpty());
    assertTrue(parseFixture.tracker.internalSchema().columns().isEmpty());
}
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 13 with ParseResult

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

the class TestImplicitColumnResolver method testLegacyWildcard.

@Test
public void testLegacyWildcard() {
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
    parseFixture.options.maxPartitionDepth(3).useLegacyWildcardExpansion(true);
    ParseResult result = parseFixture.parseImplicit();
    assertFalse(result.isMetadataScan());
    assertEquals(3, result.columns().size());
    TupleMetadata expected = new SchemaBuilder().addNullable(ScanTestUtils.partitionColName(0), MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(1), MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(2), MinorType.VARCHAR).build();
    assertEquals(expected, result.schema());
    List<ColumnHandle> cols = parseFixture.tracker.internalSchema().columns();
    assertTrue(isImplicit(cols, 0));
    assertTrue(isImplicit(cols, 1));
    assertTrue(isImplicit(cols, 2));
}
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 14 with ParseResult

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

the class TestImplicitColumnResolver method testShadowed.

/**
 * Verify that names that look like metadata columns, but appear
 * to be maps or arrays, are not interpreted as metadata. That is,
 * the projected table map or array "shadows" the metadata column.
 */
@Test
public void testShadowed() {
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList(ScanTestUtils.FILE_NAME_COL + ".a", ScanTestUtils.FILE_PATH_COL + "[0]", ScanTestUtils.partitionColName(0) + ".b", ScanTestUtils.partitionColName(1) + "[0]", ScanTestUtils.SUFFIX_COL));
    ParseResult result = parseFixture.parseImplicit();
    TupleMetadata expected = new SchemaBuilder().add(ScanTestUtils.SUFFIX_COL, MinorType.VARCHAR).build();
    assertEquals(expected, result.schema());
    List<ColumnHandle> cols = parseFixture.tracker.internalSchema().columns();
    assertFalse(isImplicit(cols, 0));
    assertFalse(isImplicit(cols, 1));
    assertFalse(isImplicit(cols, 2));
    assertFalse(isImplicit(cols, 3));
    assertTrue(isImplicit(cols, 4));
}
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 15 with ParseResult

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

the class TestImplicitColumnResolver method testPartitionExpansionPlacement.

/**
 * The scan framework should expand partitions after table columns.
 */
@Test
public void testPartitionExpansionPlacement() {
    // Parse out implicit columns at start of scan
    ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
    parseFixture.options.maxPartitionDepth(2).useLegacyWildcardExpansion(true);
    ParseResult result = parseFixture.parseImplicit();
    // Later resolve the table schema
    TupleMetadata tableSchema = new SchemaBuilder().add("a", MinorType.INT).add("f", MinorType.BIGINT).build();
    parseFixture.tracker.applyReaderSchema(tableSchema, ERROR_CONTEXT);
    TupleMetadata expected = new SchemaBuilder().addNullable(ScanTestUtils.partitionColName(0), MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(1), MinorType.VARCHAR).build();
    assertEquals(expected, result.schema());
    // Implicit columns follow the table columns
    expected = new SchemaBuilder().add("a", MinorType.INT).add("f", MinorType.BIGINT).addNullable(ScanTestUtils.partitionColName(0), MinorType.VARCHAR).addNullable(ScanTestUtils.partitionColName(1), MinorType.VARCHAR).build();
    assertEquals(expected, parseFixture.tracker.outputSchema());
}
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)

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