use of org.apache.drill.exec.physical.impl.scan.v3.schema.MutableTupleSchema.ColumnHandle in project drill by apache.
the class TestImplicitColumnResolver method testFileImplicitColumnSelection.
/**
* Test including file implicit columns in the project list.
*/
@Test
public void testFileImplicitColumnSelection() {
// Simulate SELECT a, fqn, filEPath, filename, suffix ...
ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList("a", ScanTestUtils.FULLY_QUALIFIED_NAME_COL, // Sic, to test case sensitivity
"filEPath", ScanTestUtils.FILE_NAME_COL, ScanTestUtils.SUFFIX_COL));
ParseResult result = parseFixture.parseImplicit();
assertFalse(result.isMetadataScan());
assertEquals(4, result.columns().size());
TupleMetadata expected = new SchemaBuilder().add(ScanTestUtils.FULLY_QUALIFIED_NAME_COL, MinorType.VARCHAR).add("filEPath", MinorType.VARCHAR).add(ScanTestUtils.FILE_NAME_COL, MinorType.VARCHAR).add(ScanTestUtils.SUFFIX_COL, 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));
assertTrue(isImplicit(cols, 4));
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.MutableTupleSchema.ColumnHandle in project drill by apache.
the class TestImplicitColumnResolver method testInternalImplicitColumnSelection.
/**
* Test including internal implicit columns in the project list.
* @throws IOException
*/
@Test
public void testInternalImplicitColumnSelection() throws IOException {
// Simulate SELECT lmt, $project_metadata$", rgi, rgs, rgl ...
Configuration conf = new Configuration();
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, FileSystem.DEFAULT_FS);
DrillFileSystem dfs = new DrillFileSystem(conf);
ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectList("a", ScanTestUtils.LAST_MODIFIED_TIME_COL, ScanTestUtils.PROJECT_METADATA_COL, ScanTestUtils.ROW_GROUP_INDEX_COL, ScanTestUtils.ROW_GROUP_START_COL, ScanTestUtils.ROW_GROUP_LENGTH_COL));
parseFixture.options.dfs(dfs);
ParseResult result = parseFixture.parseImplicit();
assertTrue(result.isMetadataScan());
assertEquals(5, result.columns().size());
TupleMetadata expected = new SchemaBuilder().add(ScanTestUtils.LAST_MODIFIED_TIME_COL, MinorType.VARCHAR).addNullable(ScanTestUtils.PROJECT_METADATA_COL, MinorType.VARCHAR).add(ScanTestUtils.ROW_GROUP_INDEX_COL, MinorType.VARCHAR).add(ScanTestUtils.ROW_GROUP_START_COL, MinorType.VARCHAR).add(ScanTestUtils.ROW_GROUP_LENGTH_COL, 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));
assertTrue(isImplicit(cols, 4));
assertTrue(isImplicit(cols, 5));
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.MutableTupleSchema.ColumnHandle in project drill by apache.
the class TestImplicitColumnResolver method testProvidedImplicitCols.
@Test
public void testProvidedImplicitCols() {
TupleMetadata providedSchema = new SchemaBuilder().add("a", MinorType.INT).add("myFqn", MinorType.VARCHAR).addNullable("myFilePath", MinorType.VARCHAR).add("myFileName", MinorType.VARCHAR).add("mySuffix", MinorType.VARCHAR).addNullable("myDir", MinorType.VARCHAR).build();
SchemaUtils.markImplicit(providedSchema.metadata("myFqn"), ColumnMetadata.IMPLICIT_FQN);
// Sic, to test case sensitivity
SchemaUtils.markImplicit(providedSchema.metadata("myFilePath"), ColumnMetadata.IMPLICIT_FILEPATH.toUpperCase());
SchemaUtils.markImplicit(providedSchema.metadata("myFileName"), ColumnMetadata.IMPLICIT_FILENAME);
SchemaUtils.markImplicit(providedSchema.metadata("mySuffix"), ColumnMetadata.IMPLICIT_SUFFIX);
SchemaUtils.markAsPartition(providedSchema.metadata("myDir"), 0);
ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
parseFixture.tracker.applyProvidedSchema(providedSchema);
parseFixture.options.maxPartitionDepth(1);
ParseResult result = parseFixture.parseImplicit();
assertEquals(5, result.columns().size());
TupleMetadata expected = new SchemaBuilder().add("myFqn", MinorType.VARCHAR).addNullable("myFilePath", MinorType.VARCHAR).add("myFileName", MinorType.VARCHAR).add("mySuffix", MinorType.VARCHAR).addNullable("myDir", 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));
assertTrue(isImplicit(cols, 4));
assertTrue(isImplicit(cols, 5));
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.MutableTupleSchema.ColumnHandle 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.schema.MutableTupleSchema.ColumnHandle 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));
}
Aggregations