public class RequestedTupleImpl extends Object implements RequestedTuple
A column is projected if it is explicitly listed in the selection list.
If a column is a map, then the projection for the map's columns is based on two rules:
Examples:
m
If m
turns out to be a map, project all members of
m
.
m.a
Column m
must be a map. Project only column a
.
m, m.a
Tricky case. We interpret this as projecting only the "a" element of map m.
The projection set is built from a list of columns, represented as
SchemaPath
objects, provided by the physical plan. The structure of
SchemaPath is a bit awkward:
a
a.b
a[2]
a[2].b
a[1][2][3]
a[1][2][3].b.c
a['foo'][0].b['bar']
String colName = ...;
ColumnMetadata colDef = ...;
InputTupleProjection tupleProj = ...
if (tupleProj.isProjected(colName)) {
if (!tupleProj.isComsistentWith(colDef)) {
// Raise an error
}
// Handle a projected column.
}
RequestedTuple.TupleProjectionType
Modifier and Type | Field and Description |
---|---|
protected RequestedTuple.TupleProjectionType |
projectionType |
Constructor and Description |
---|
RequestedTupleImpl() |
RequestedTupleImpl(List<RequestedColumn> cols) |
RequestedTupleImpl(RequestedColumnImpl parent) |
Modifier and Type | Method and Description |
---|---|
void |
buildName(StringBuilder buf) |
boolean |
enforceProjection(ColumnMetadata columnSchema,
CustomErrorContext errorContext) |
RequestedColumn |
get(int i) |
RequestedColumn |
get(String colName) |
protected RequestedColumnImpl |
getImpl(String colName) |
boolean |
isEmpty()
Report if the projection is empty as occurs in
SELECT COUNT(*) FROM ... . |
boolean |
isProjected(ColumnMetadata columnSchema) |
boolean |
isProjected(String colName) |
RequestedTuple |
mapProjection(String colName) |
protected RequestedColumn |
project(String colName) |
List<RequestedColumn> |
projections() |
int |
size() |
String |
toString() |
RequestedTuple.TupleProjectionType |
type()
Tuple projection type.
|
protected RequestedTuple.TupleProjectionType projectionType
public RequestedTupleImpl()
public RequestedTupleImpl(RequestedColumnImpl parent)
public RequestedTupleImpl(List<RequestedColumn> cols)
public int size()
size
in interface RequestedTuple
public RequestedColumn get(int i)
get
in interface RequestedTuple
public RequestedColumn get(String colName)
get
in interface RequestedTuple
protected RequestedColumnImpl getImpl(String colName)
protected RequestedColumn project(String colName)
public List<RequestedColumn> projections()
projections
in interface RequestedTuple
public void buildName(StringBuilder buf)
buildName
in interface RequestedTuple
public RequestedTuple.TupleProjectionType type()
type
in interface RequestedTuple
public boolean isProjected(String colName)
isProjected
in interface RequestedTuple
public boolean isProjected(ColumnMetadata columnSchema)
isProjected
in interface RequestedTuple
public boolean enforceProjection(ColumnMetadata columnSchema, CustomErrorContext errorContext)
enforceProjection
in interface RequestedTuple
public RequestedTuple mapProjection(String colName)
mapProjection
in interface RequestedTuple
public boolean isEmpty()
RequestedTuple
SELECT COUNT(*) FROM ...
. This is not the
same as asking if this tuple is unprojected, as that concept
does not apply to tuples, only to the column that contains the
tuple.isEmpty
in interface RequestedTuple
true
if the projection set is emptyCopyright © 1970 The Apache Software Foundation. All rights reserved.