@PublicEvolving public interface SupportsProjectionPushDown
ScanTableSource
.
Given the following SQL:
CREATE TABLE t (i INT, r ROW < d DOUBLE, b BOOLEAN>, s STRING);
SELECT s, r.d FROM t;
In the above example, r.d
and s
are required fields. Other fields can be
skipped in a projection. Compared to table's schema, fields are reordered.
By default, if this interface is not implemented, a projection is applied in a subsequent operation after the source.
For efficiency, a source can push a projection further down in order to be close to the actual
data generation. A projection is only selecting fields that are used by a query (possibly in a
different field order). It does not contain any computation. A projection can either be performed
on the fields of the top-level row only or consider nested fields as well (see supportsNestedProjection()
).
Projection
,
ProjectedRowData
Modifier and Type | Method and Description |
---|---|
default void |
applyProjection(int[][] projectedFields)
Deprecated.
Please implement
applyProjection(int[][], DataType) |
default void |
applyProjection(int[][] projectedFields,
DataType producedDataType)
Provides the field index paths that should be used for a projection.
|
boolean |
supportsNestedProjection()
Returns whether this source supports nested projection.
|
boolean supportsNestedProjection()
@Deprecated default void applyProjection(int[][] projectedFields)
applyProjection(int[][], DataType)
default void applyProjection(int[][] projectedFields, DataType producedDataType)
supportsNestedProjection()
.
In the example mentioned in SupportsProjectionPushDown
, this method would receive:
[[2], [1]]
which is equivalent to [["s"], ["r"]]
if supportsNestedProjection()
returns false.
[[2], [1, 0]]
which is equivalent to [["s"], ["r", "d"]]]
if supportsNestedProjection()
returns true.
Note: Use the passed data type instead of ResolvedSchema.toPhysicalRowDataType()
for describing the final output data type when creating TypeInformation
.
projectedFields
- field index paths of all fields that must be present in the physically
produced dataproducedDataType
- the final output type of the source, with the projection appliedCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.