use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testProjectionMapAndWildcard.
/**
* Project both a map member and the entire map.
*/
@Test
public void testProjectionMapAndWildcard() {
// Built up by hand because "map.*" is not valid Drill
// expression syntax.
List<SchemaPath> projCols = new ArrayList<>();
projCols.add(SchemaPath.getCompoundPath("map", "a"));
projCols.add(SchemaPath.getCompoundPath("map", SchemaPath.DYNAMIC_STAR));
ProjectionParseResult result = ScanProjectionParser.parse(projCols);
assertEquals(-1, result.wildcardPosn);
TupleMetadata projSet = result.dynamicSchema;
doTestMapAndSimple(projSet);
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testProjectionWildcardAndMap.
/**
* Project both an entire map and a map member.
*/
@Test
public void testProjectionWildcardAndMap() {
List<SchemaPath> projCols = new ArrayList<>();
projCols.add(SchemaPath.getCompoundPath("map", SchemaPath.DYNAMIC_STAR));
projCols.add(SchemaPath.getCompoundPath("map", "a"));
ProjectionParseResult result = ScanProjectionParser.parse(projCols);
assertEquals(-1, result.wildcardPosn);
TupleMetadata projSet = result.dynamicSchema;
doTestMapAndSimple(projSet);
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testMapDetails.
@Test
public void testMapDetails() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a.b.c", "a.c", "d"));
TupleMetadata projSet = result.dynamicSchema;
assertEquals(2, projSet.size());
ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
assertEquals("a", a.name());
assertFalse(a.isSimple());
assertFalse(a.isArray());
assertTrue(a.isMap());
// a{}
TupleMetadata aMembers = a.tupleSchema();
assertNotNull(aMembers);
assertEquals(2, aMembers.size());
// a.b
ProjectedColumn a_b = (ProjectedColumn) aMembers.metadata(0);
assertEquals("b", a_b.name());
assertTrue(a_b.isMap());
// a.b{}
TupleMetadata a_bMembers = a_b.tupleSchema();
assertNotNull(a_bMembers);
assertEquals(1, a_bMembers.size());
// a.b.c
ProjectedColumn a_b_c = (ProjectedColumn) a_bMembers.metadata(0);
assertNotNull(a_b_c);
assertEquals("c", a_b_c.name());
assertTrue(a_b_c.isSimple());
// a.c
ProjectedColumn a_c = (ProjectedColumn) aMembers.metadata(1);
assertNotNull(a_c);
assertEquals("c", a_c.name());
assertTrue(a_c.isSimple());
// d
ProjectedColumn d = (ProjectedColumn) projSet.metadata(1);
assertNotNull(d);
assertEquals("d", d.name());
assertTrue(d.isSimple());
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testArrayDupsIgnored.
/**
* Duplicate array entries are allowed to handle the
* use case of a[1], a[1].z. Each element is reported once;
* the project operator will create copies as needed.
*/
@Test
public void testArrayDupsIgnored() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1]", "a[3]", "a[1]", "a[3].z"));
TupleMetadata projSet = result.dynamicSchema;
assertEquals(1, projSet.size());
ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
assertEquals("a", a.name());
assertTrue(a.isArray());
boolean[] indexes = a.indexes();
assertNotNull(indexes);
assertEquals(4, indexes.length);
assertFalse(indexes[0]);
assertTrue(indexes[1]);
assertFalse(indexes[2]);
assertTrue(indexes[3]);
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testProjectionSimple.
/**
* Simple non-map columns
*/
@Test
public void testProjectionSimple() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a", "b", "c"));
assertEquals(-1, result.wildcardPosn);
TupleMetadata projSet = result.dynamicSchema;
assertFalse(SchemaUtils.isProjectAll(projSet));
assertFalse(SchemaUtils.isProjectNone(projSet));
assertNotNull(projSet.metadata("a"));
assertNotNull(projSet.metadata("b"));
assertNotNull(projSet.metadata("c"));
assertNull(projSet.metadata("d"));
assertEquals(3, projSet.size());
ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
assertEquals("a", a.name());
assertTrue(a.isSimple());
assertFalse(a.isArray());
assertFalse(a.isMap());
assertNull(a.tupleSchema());
}
Aggregations