Package org.apache.flink.table.connector
Class Projection
java.lang.Object
org.apache.flink.table.connector.Projection
Projection represents a list of (possibly nested) indexes that can be used to project
data types. A row projection includes both reducing the accessible fields and reordering them.-
Method Summary
Modifier and TypeMethodDescriptionstatic ProjectionCreate aProjectionof all the fields in the provideddataType.abstract Projectioncomplement(int fieldsNumber) Complement this projection.complement(DataType dataType) Likecomplement(int), using thedataTypefields count.abstract Projectiondifference(Projection other) Perform a difference of thisProjectionwith anotherProjection.static Projectionempty()Create an emptyProjection, that is a projection that projects no fields, returning an emptyDataType.booleanstatic ProjectionfromFieldNames(DataType dataType, List<String> projectedFields) inthashCode()abstract booleanisNested()static Projectionof(int[] indexes) Create aProjectionof the providedindexes.static Projectionof(int[][] indexes) Create aProjectionof the providedindexes.abstract DataTypeProjects a (possibly nested) row data type by returning a new data type that only includes fields of the given index paths.project(LogicalType logicalType) Same asproject(DataType), but accepting and returningLogicalType.static Projectionrange(int startInclusive, int endExclusive) Create aProjectionof a field range.abstract int[][]Convert this instance to a nested projection index paths.toString()abstract int[]Convert this instance to a projection of top level indexes.
-
Method Details
-
project
Projects a (possibly nested) row data type by returning a new data type that only includes fields of the given index paths.When extracting nested fields, the name of the resulting fields is the full path of the field separated by
_. For example, the fieldbinside the row fieldaof the rootDataTypeis nameda_bin the resultDataType. In case of naming conflicts the postfix notation '_$%d' is used, where%dis an arbitrary number, in order to generate a unique field name. For example if the rootDataTypeincludes both a fielda_band a nested rowawith fieldb, the resultDataTypewill contain one field nameda_band the other nameda_b_1. -
project
Same asproject(DataType), but accepting and returningLogicalType. -
isNested
public abstract boolean isNested()- Returns:
truewhether this projection is nested or not.
-
difference
Perform a difference of thisProjectionwith anotherProjection. The result of this operation is a newProjectionretaining the same ordering of this instance but with the indexes fromotherremoved. For example:[4, 1, 0, 3, 2] - [4, 2] = [1, 0, 2]Note how the index
3in the minuend becomes2because it's rescaled to project correctly aRowDataor arity 3.- Parameters:
other- the subtrahend- Throws:
IllegalArgumentException- whenotheris nested.
-
complement
Complement this projection. The returned projection is an ordered projection of fields from 0 tofieldsNumberexcept the indexes in thisProjection. For example:[4, 2].complement(5) = [0, 1, 3]- Parameters:
fieldsNumber- the size of the universe- Throws:
IllegalStateException- if this projection is nested.
-
complement
Likecomplement(int), using thedataTypefields count. -
toTopLevelIndexes
public abstract int[] toTopLevelIndexes()Convert this instance to a projection of top level indexes. The array represents the mapping of the fields of the originalDataType. For example,[0, 2, 1]specifies to include in the following order the 1st field, the 3rd field and the 2nd field of the row.- Throws:
IllegalStateException- if this projection is nested.
-
toNestedIndexes
public abstract int[][] toNestedIndexes()Convert this instance to a nested projection index paths. The array represents the mapping of the fields of the originalDataType, including nested rows. For example,[[0, 2, 1], ...]specifies to include the 2nd field of the 3rd field of the 1st field in the top-level row. -
empty
Create an emptyProjection, that is a projection that projects no fields, returning an emptyDataType. -
of
Create aProjectionof the providedindexes.- See Also:
-
of
Create aProjectionof the providedindexes.- See Also:
-
fromFieldNames
-
all
Create aProjectionof all the fields in the provideddataType. -
range
Create aProjectionof a field range. -
equals
-
hashCode
public int hashCode() -
toString
-