public class OrcTableSource extends Object implements BatchTableSource<Row>, ProjectableTableSource<Row>, FilterableTableSource<Row>
The OrcTableSource
supports projection and filter push-down.
An OrcTableSource
is used as shown in the example below.
OrcTableSource orcSrc = OrcTableSource.builder()
.path("file:///my/data/file.orc")
.forOrcSchema("struct<col1:boolean,col2:tinyint,col3:smallint,col4:int>")
.build();
tEnv.registerTableSource("orcTable", orcSrc);
Table res = tableEnv.sqlQuery("SELECT * FROM orcTable");
Modifier and Type | Class and Description |
---|---|
static class |
OrcTableSource.Builder
Constructs an
OrcTableSource . |
Modifier and Type | Method and Description |
---|---|
TableSource<Row> |
applyPredicate(List<Expression> predicates)
Check and pick all predicates this table source can support.
|
static OrcTableSource.Builder |
builder() |
protected OrcRowInputFormat |
buildOrcInputFormat() |
String |
explainSource()
Describes the table source.
|
DataSet<Row> |
getDataSet(ExecutionEnvironment execEnv)
Returns the data of the table as a
DataSet . |
TypeInformation<Row> |
getReturnType() |
TableSchema |
getTableSchema()
Returns the schema of the produced table.
|
boolean |
isFilterPushedDown()
Return the flag to indicate whether filter push down has been tried.
|
TableSource<Row> |
projectFields(int[] selectedFields)
Creates a copy of the
TableSource that projects its output to the given field indexes. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProducedDataType
public DataSet<Row> getDataSet(ExecutionEnvironment execEnv)
BatchTableSource
DataSet
.
NOTE: This method is for internal use only for defining a TableSource
.
Do not use it in Table API programs.
getDataSet
in interface BatchTableSource<Row>
@VisibleForTesting protected OrcRowInputFormat buildOrcInputFormat()
public TypeInformation<Row> getReturnType()
getReturnType
in interface TableSource<Row>
public TableSchema getTableSchema()
TableSource
getTableSchema
in interface TableSource<Row>
TableSchema
of the produced table.public TableSource<Row> projectFields(int[] selectedFields)
ProjectableTableSource
TableSource
that projects its output to the given field indexes.
The field indexes relate to the physical poduced data type (TableSource.getProducedDataType()
)
and not to the table schema (TableSource.getTableSchema()
of the TableSource
.
The table schema (TableSource.getTableSchema()
of the TableSource
copy must not be
modified by this method, but only the produced data type (TableSource.getProducedDataType()
)
and the produced DataSet
(BatchTableSource#getDataSet(
) or DataStream
(StreamTableSource#getDataStream
).
If the TableSource
implements the DefinedFieldMapping
interface, it might
be necessary to adjust the mapping as well.
IMPORTANT: This method must return a true copy and must not modify the original table source object.
projectFields
in interface ProjectableTableSource<Row>
selectedFields
- The indexes of the fields to return.TableSource
that projects its output.public TableSource<Row> applyPredicate(List<Expression> predicates)
FilterableTableSource
WARNING: Flink planner will push down PlannerExpressions
(which are defined in flink-table-planner module), while Blink planner will push down Expression
s.
So the implementation for Flink planner and Blink planner should be different and incompatible.
PlannerExpression will be removed in the future.
After trying to push predicates down, we should return a new TableSource
instance which holds all pushed down predicates. Even if we actually pushed nothing down,
it is recommended that we still return a new TableSource
instance since we will
mark the returned instance as filter push down has been tried.
We also should note to not changing the form of the predicates passed in. It has been organized in CNF conjunctive form, and we should only take or leave each element from the list. Don't try to reorganize the predicates if you are absolutely confident with that.
applyPredicate
in interface FilterableTableSource<Row>
predicates
- A list contains conjunctive predicates, you should pick and remove all
expressions that can be pushed down. The remaining elements of this list
will further evaluated by framework.TableSource
with or without any filters been
pushed into it.public boolean isFilterPushedDown()
FilterableTableSource
FilterableTableSource.applyPredicate(java.util.List<org.apache.flink.table.expressions.Expression>)
.isFilterPushedDown
in interface FilterableTableSource<Row>
public String explainSource()
TableSource
explainSource
in interface TableSource<Row>
TableSource
.public static OrcTableSource.Builder builder()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.