use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testArrayAndMap.
/**
* Projection does not enforce semantics; it just report what it
* sees. This allows cases such as m.a and m[0], which might mean
* that m is a map array, m.a wants an array of a-member values, and m[0]
* wants the first map in the array. Not clear Drill actually supports
* these cases, however.
*/
@Test
public void testArrayAndMap() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("m.a", "m[0]"));
doTestArrayAndMap(result.dynamicSchema);
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testMapDups.
/**
* Duplicate column names are merged for projection.
*/
@Test
public void testMapDups() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a.b", "a.c", "a.b"));
TupleMetadata projSet = result.dynamicSchema;
ProjectedColumn a = (ProjectedColumn) projSet.metadata("a");
TupleMetadata aMap = a.tupleSchema();
assertEquals(2, aMap.size());
assertEquals(2, ((ProjectedColumn) aMap.metadata("b")).refCount());
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testMapArray.
@Test
public // Drill syntax does not support map arrays
void testMapArray() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1].x"));
TupleMetadata projSet = result.dynamicSchema;
assertEquals(1, projSet.size());
ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
// Column acts like an array
assertTrue(a.isArray());
assertTrue(a.hasIndexes());
assertEquals(1, a.arrayDims());
// And the column acts like a map
assertTrue(a.isMap());
TupleMetadata aProj = a.tupleSchema();
assertFalse(SchemaUtils.isProjectAll(aProj));
assertFalse(SchemaUtils.isProjectNone(aProj));
assertNotNull(aProj.metadata("x"));
assertNull(aProj.metadata("y"));
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testMap2DArray.
@Test
public // Drill syntax does not support map arrays
void testMap2DArray() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a[1][2].x"));
TupleMetadata projSet = result.dynamicSchema;
assertEquals(1, projSet.size());
ProjectedColumn a = (ProjectedColumn) projSet.metadata(0);
// Column acts like an array
assertTrue(a.isArray());
assertTrue(a.hasIndexes());
// Note that the multiple dimensions are inferred only through
// the multiple levels of qualifiers.
// And the column acts like a map
assertTrue(a.isMap());
TupleMetadata aProj = a.tupleSchema();
assertNotNull(aProj.metadata("x"));
assertNull(aProj.metadata("y"));
}
use of org.apache.drill.exec.physical.impl.scan.v3.schema.ScanProjectionParser.ProjectionParseResult in project drill by apache.
the class TestProjectionParser method testSimpleDups.
/**
* The projection set does not enforce uniqueness.
*/
@Test
public void testSimpleDups() {
ProjectionParseResult result = ScanProjectionParser.parse(RowSetTestUtils.projectList("a", "b", "a"));
assertEquals(-1, result.wildcardPosn);
TupleMetadata projSet = result.dynamicSchema;
assertEquals(2, projSet.size());
assertEquals(2, ((ProjectedColumn) projSet.metadata("a")).refCount());
}
Aggregations