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