BatchTableEnvironment will be dropped in Flink 1.14 because it only supports
the old planner. Use the unified TableEnvironment instead, which supports both batch
and streaming. More advanced operations previously covered by the DataSet API can now use the
DataStream API in BATCH execution mode.@Deprecated @PublicEvolving public interface BatchTableEnvironment extends org.apache.flink.table.api.TableEnvironment
TableEnvironment for a Java batch ExecutionEnvironment that works with DataSets.
A TableEnvironment can be used to:
DataSet to a Table
DataSet in the TableEnvironment's catalog
Table in the TableEnvironment's catalog
Table
Table
Table into a DataSet
Table
| Modifier and Type | Method and Description |
|---|---|
org.apache.flink.table.descriptors.BatchTableDescriptor |
connect(org.apache.flink.table.descriptors.ConnectorDescriptor connectorDescriptor)
Deprecated.
The SQL
CREATE TABLE DDL is richer than this part of the API. This method
might be refactored in the next versions. Please use executeSql(ddl) to register a table instead. |
static BatchTableEnvironment |
create(org.apache.flink.api.java.ExecutionEnvironment executionEnvironment)
Deprecated.
Returns a
TableEnvironment for a Java batch ExecutionEnvironment that works
with DataSets. |
static BatchTableEnvironment |
create(org.apache.flink.api.java.ExecutionEnvironment executionEnvironment,
org.apache.flink.table.api.TableConfig tableConfig)
Deprecated.
Returns a
TableEnvironment for a Java batch ExecutionEnvironment that works
with DataSets. |
<T> void |
createTemporaryView(String path,
org.apache.flink.api.java.DataSet<T> dataSet)
Deprecated.
Creates a view from the given
DataSet in a given path. |
<T> void |
createTemporaryView(String path,
org.apache.flink.api.java.DataSet<T> dataSet,
org.apache.flink.table.expressions.Expression... fields)
Deprecated.
Creates a view from the given
DataSet in a given path with specified field names. |
<T> void |
createTemporaryView(String path,
org.apache.flink.api.java.DataSet<T> dataSet,
String fields)
Deprecated.
|
<T> org.apache.flink.table.api.Table |
fromDataSet(org.apache.flink.api.java.DataSet<T> dataSet)
Deprecated.
Converts the given
DataSet into a Table. |
<T> org.apache.flink.table.api.Table |
fromDataSet(org.apache.flink.api.java.DataSet<T> dataSet,
org.apache.flink.table.expressions.Expression... fields)
Deprecated.
Converts the given
DataSet into a Table with specified field names. |
<T> org.apache.flink.table.api.Table |
fromDataSet(org.apache.flink.api.java.DataSet<T> dataSet,
String fields)
Deprecated.
|
<T> void |
registerDataSet(String name,
org.apache.flink.api.java.DataSet<T> dataSet)
Deprecated.
|
<T> void |
registerDataSet(String name,
org.apache.flink.api.java.DataSet<T> dataSet,
String fields)
Deprecated.
|
<T,ACC> void |
registerFunction(String name,
org.apache.flink.table.functions.AggregateFunction<T,ACC> aggregateFunction)
Deprecated.
Registers an
AggregateFunction under a unique name in the TableEnvironment's catalog. |
<T> void |
registerFunction(String name,
org.apache.flink.table.functions.TableFunction<T> tableFunction)
Deprecated.
Registers a
TableFunction under a unique name in the TableEnvironment's catalog. |
<T> org.apache.flink.api.java.DataSet<T> |
toDataSet(org.apache.flink.table.api.Table table,
Class<T> clazz)
Deprecated.
Converts the given
Table into a DataSet of a specified type. |
<T> org.apache.flink.api.java.DataSet<T> |
toDataSet(org.apache.flink.table.api.Table table,
org.apache.flink.api.common.typeinfo.TypeInformation<T> typeInfo)
Deprecated.
Converts the given
Table into a DataSet of a specified type. |
create, create, createFunction, createFunction, createStatementSet, createTemporaryFunction, createTemporaryFunction, createTemporarySystemFunction, createTemporarySystemFunction, createTemporaryView, dropFunction, dropTemporaryFunction, dropTemporarySystemFunction, dropTemporaryTable, dropTemporaryView, execute, executeSql, explain, explain, explain, explainSql, from, fromTableSource, fromValues, fromValues, fromValues, fromValues, fromValues, fromValues, getCatalog, getCompletionHints, getConfig, getCurrentCatalog, getCurrentDatabase, insertInto, insertInto, listCatalogs, listDatabases, listFullModules, listFunctions, listModules, listTables, listTemporaryTables, listTemporaryViews, listUserDefinedFunctions, listViews, loadModule, registerCatalog, registerFunction, registerTable, scan, sqlQuery, sqlUpdate, unloadModule, useCatalog, useDatabase, useModules<T> void registerFunction(String name, org.apache.flink.table.functions.TableFunction<T> tableFunction)
TableFunction under a unique name in the TableEnvironment's catalog.
Registered functions can be referenced in Table API and SQL queries.T - The type of the output row.name - The name under which the function is registered.tableFunction - The TableFunction to register.<T,ACC> void registerFunction(String name, org.apache.flink.table.functions.AggregateFunction<T,ACC> aggregateFunction)
AggregateFunction under a unique name in the TableEnvironment's catalog.
Registered functions can be referenced in Table API and SQL queries.T - The type of the output value.ACC - The type of aggregate accumulator.name - The name under which the function is registered.aggregateFunction - The AggregateFunction to register.<T> org.apache.flink.table.api.Table fromDataSet(org.apache.flink.api.java.DataSet<T> dataSet)
DataSet into a Table.
The field names of the Table are automatically derived from the type of the DataSet.
T - The type of the DataSet.dataSet - The DataSet to be converted.Table.@Deprecated <T> org.apache.flink.table.api.Table fromDataSet(org.apache.flink.api.java.DataSet<T> dataSet, String fields)
fromDataSet(DataSet, Expression...)DataSet into a Table with specified field names.
There are two modes for mapping original fields to the fields of the Table:
1. Reference input fields by name: All fields in the schema definition are referenced by name (and possibly renamed using an alias (as). In this mode, fields can be reordered and projected out. This mode can be used for any input type, including POJOs.
Example:
DataSet<Tuple2<String, Long>> set = ...
// use the original 'f0' field and give a better name to the 'f1' field
Table table = tableEnv.fromTable(set, "f0, f1 as name");
2. Reference input fields by position: In this mode, fields are simply renamed. This mode
can only be used if the input type has a defined field order (tuple, case class, Row) and
none of the fields references a field of the input type.
Example:
DataSet<Tuple2<String, Long>> set = ...
// renames the original fields as 'a' and 'b'
Table table = tableEnv.fromDataSet(set, "a, b");
T - The type of the DataSet.dataSet - The DataSet to be converted.fields - The fields expressions to map original fields of the DataSet to the fields of
the Table.Table.<T> org.apache.flink.table.api.Table fromDataSet(org.apache.flink.api.java.DataSet<T> dataSet,
org.apache.flink.table.expressions.Expression... fields)
DataSet into a Table with specified field names.
There are two modes for mapping original fields to the fields of the Table:
1. Reference input fields by name: All fields in the schema definition are referenced by name (and possibly renamed using an alias (as). In this mode, fields can be reordered and projected out. This mode can be used for any input type, including POJOs.
Example:
DataSet<Tuple2<String, Long>> set = ...
Table table = tableEnv.fromDataSet(
set,
$("f1"), // reorder and use the original field
$("f0").as("name") // reorder and give the original field a better name
);
2. Reference input fields by position: In this mode, fields are simply renamed. This mode
can only be used if the input type has a defined field order (tuple, case class, Row) and
none of the fields references a field of the input type.
Example:
DataSet<Tuple2<String, Long>> set = ...
Table table = tableEnv.fromDataSet(
set,
$("a"), // renames the first field to 'a'
$("b") // renames the second field to 'b'
);
T - The type of the DataSet.dataSet - The DataSet to be converted.fields - The fields expressions to map original fields of the DataSet to the fields of
the Table.Table.@Deprecated <T> void registerDataSet(String name, org.apache.flink.api.java.DataSet<T> dataSet)
createTemporaryView(String, DataSet)DataSet. Registered views can be referenced in SQL
queries.
The field names of the Table are automatically derived from the type of the DataSet.
The view is registered in the namespace of the current catalog and database. To register
the view in a different catalog use createTemporaryView(String, DataSet).
Temporary objects can shadow permanent ones. If a permanent object in a given path exists, it will be inaccessible in the current session. To make the permanent object available again you can drop the corresponding temporary object.
T - The type of the DataSet to register.name - The name under which the DataSet is registered in the catalog.dataSet - The DataSet to register.<T> void createTemporaryView(String path, org.apache.flink.api.java.DataSet<T> dataSet)
DataSet in a given path. Registered views can be
referenced in SQL queries.
The field names of the Table are automatically derived from the type of the DataSet.
Temporary objects can shadow permanent ones. If a permanent object in a given path exists, it will be inaccessible in the current session. To make the permanent object available again you can drop the corresponding temporary object.
T - The type of the DataSet.path - The path under which the view is created. See also the TableEnvironment
class description for the format of the path.dataSet - The DataSet out of which to create the view.@Deprecated <T> void registerDataSet(String name, org.apache.flink.api.java.DataSet<T> dataSet, String fields)
createTemporaryView(String, DataSet, String)DataSet in a given path with specified field names.
Registered views can be referenced in SQL queries.
There are two modes for mapping original fields to the fields of the View:
1. Reference input fields by name: All fields in the schema definition are referenced by name (and possibly renamed using an alias (as). In this mode, fields can be reordered and projected out. This mode can be used for any input type, including POJOs.
Example:
DataSet<Tuple2<String, Long>> set = ...
// use the original 'f0' field and give a better name to the 'f1' field
tableEnv.registerDataSet("myTable", set, "f0, f1 as name");
2. Reference input fields by position: In this mode, fields are simply renamed. This mode
can only be used if the input type has a defined field order (tuple, case class, Row) and
none of the fields references a field of the input type.
Example:
DataSet<Tuple2<String, Long>> set = ...
// renames the original fields as 'a' and 'b'
tableEnv.registerDataSet("myTable", set, "a, b");
The view is registered in the namespace of the current catalog and database. To register
the view in a different catalog use createTemporaryView(String, DataSet).
Temporary objects can shadow permanent ones. If a permanent object in a given path exists, it will be inaccessible in the current session. To make the permanent object available again you can drop the corresponding temporary object.
T - The type of the DataSet to register.name - The name under which the DataSet is registered in the catalog.dataSet - The DataSet to register.fields - The fields expressions to map original fields of the DataSet to the fields of
the View.@Deprecated <T> void createTemporaryView(String path, org.apache.flink.api.java.DataSet<T> dataSet, String fields)
createTemporaryView(String, DataSet, Expression...)DataSet in a given path with specified field names.
Registered views can be referenced in SQL queries.
There are two modes for mapping original fields to the fields of the View:
1. Reference input fields by name: All fields in the schema definition are referenced by name (and possibly renamed using an alias (as). In this mode, fields can be reordered and projected out. This mode can be used for any input type, including POJOs.
Example:
DataSet<Tuple2<String, Long>> set = ...
// use the original 'f0' field and give a better name to the 'f1' field
tableEnv.createTemporaryView("cat.db.myTable", set, "f0, f1 as name");
2. Reference input fields by position: In this mode, fields are simply renamed. This mode
can only be used if the input type has a defined field order (tuple, case class, Row) and
none of the fields references a field of the input type.
Example:
DataSet<Tuple2<String, Long>> set = ...
// renames the original fields as 'a' and 'b'
tableEnv.createTemporaryView("cat.db.myTable", set, "a, b");
Temporary objects can shadow permanent ones. If a permanent object in a given path exists, it will be inaccessible in the current session. To make the permanent object available again you can drop the corresponding temporary object.
T - The type of the DataSet.path - The path under which the view is created. See also the TableEnvironment
class description for the format of the path.dataSet - The DataSet out of which to create the view.fields - The fields expressions to map original fields of the DataSet to the fields of
the View.<T> void createTemporaryView(String path, org.apache.flink.api.java.DataSet<T> dataSet, org.apache.flink.table.expressions.Expression... fields)
DataSet in a given path with specified field names.
Registered views can be referenced in SQL queries.
There are two modes for mapping original fields to the fields of the View:
1. Reference input fields by name: All fields in the schema definition are referenced by name (and possibly renamed using an alias (as). In this mode, fields can be reordered and projected out. This mode can be used for any input type, including POJOs.
Example:
DataSet<Tuple2<String, Long>> set = ...
tableEnv.createTemporaryView(
"cat.db.myTable",
set,
$("f1"), // reorder and use the original field
$("f0").as("name") // reorder and give the original field a better name
);
2. Reference input fields by position: In this mode, fields are simply renamed. This mode
can only be used if the input type has a defined field order (tuple, case class, Row) and
none of the fields references a field of the input type.
Example:
DataSet<Tuple2<String, Long>> set = ...
tableEnv.createTemporaryView(
"cat.db.myTable",
set,
$("a"), // renames the first field to 'a'
$("b") // renames the second field to 'b'
);
Temporary objects can shadow permanent ones. If a permanent object in a given path exists, it will be inaccessible in the current session. To make the permanent object available again you can drop the corresponding temporary object.
T - The type of the DataSet.path - The path under which the view is created. See also the TableEnvironment
class description for the format of the path.dataSet - The DataSet out of which to create the view.fields - The fields expressions to map original fields of the DataSet to the fields of
the View.<T> org.apache.flink.api.java.DataSet<T> toDataSet(org.apache.flink.table.api.Table table,
Class<T> clazz)
Table into a DataSet of a specified type.
The fields of the Table are mapped to DataSet fields as follows:
Row and Tuple
types: Fields are mapped by position, field types must match.
DataSet types: Fields are mapped by field name, field types must match.
T - The type of the resulting DataSet.table - The Table to convert.clazz - The class of the type of the resulting DataSet.DataSet.<T> org.apache.flink.api.java.DataSet<T> toDataSet(org.apache.flink.table.api.Table table,
org.apache.flink.api.common.typeinfo.TypeInformation<T> typeInfo)
Table into a DataSet of a specified type.
The fields of the Table are mapped to DataSet fields as follows:
Row and Tuple
types: Fields are mapped by position, field types must match.
DataSet types: Fields are mapped by field name, field types must match.
T - The type of the resulting DataSet.table - The Table to convert.typeInfo - The TypeInformation that specifies the type of the resulting DataSet.DataSet.@Deprecated org.apache.flink.table.descriptors.BatchTableDescriptor connect(org.apache.flink.table.descriptors.ConnectorDescriptor connectorDescriptor)
CREATE TABLE DDL is richer than this part of the API. This method
might be refactored in the next versions. Please use executeSql(ddl) to register a table instead.Descriptors allow for declaring the communication to external systems in an implementation-agnostic way. The classpath is scanned for suitable table factories that match the desired configuration.
The following example shows how to read from a connector using a JSON format and registering a temporary table as "MyTable":
tableEnv
.connect(
new ExternalSystemXYZ()
.version("0.11"))
.withFormat(
new Json()
.jsonSchema("{...}")
.failOnMissingField(false))
.withSchema(
new Schema()
.field("user-name", "VARCHAR").from("u_name")
.field("count", "DECIMAL")
.createTemporaryTable("MyTable")
connect in interface org.apache.flink.table.api.TableEnvironmentconnectorDescriptor - connector descriptor describing the external systemstatic BatchTableEnvironment create(org.apache.flink.api.java.ExecutionEnvironment executionEnvironment)
TableEnvironment for a Java batch ExecutionEnvironment that works
with DataSets.
A TableEnvironment can be used to:
DataSet to a Table
DataSet in the TableEnvironment's catalog
Table in the TableEnvironment's catalog
Table
Table
Table into a DataSet
Table
executionEnvironment - The Java batch ExecutionEnvironment of the
TableEnvironment.static BatchTableEnvironment create(org.apache.flink.api.java.ExecutionEnvironment executionEnvironment, org.apache.flink.table.api.TableConfig tableConfig)
TableEnvironment for a Java batch ExecutionEnvironment that works
with DataSets.
A TableEnvironment can be used to:
DataSet to a Table
DataSet in the TableEnvironment's catalog
Table in the TableEnvironment's catalog
Table
Table
Table into a DataSet
Table
executionEnvironment - The Java batch ExecutionEnvironment of the
TableEnvironment.tableConfig - The configuration of the TableEnvironment.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.