Constructor and Description |
---|
LocalExecutor(Environment defaultEnvironment,
List<URL> dependencies,
Configuration flinkConfig,
CustomCommandLine commandLine,
ClusterClientServiceLoader clusterClientServiceLoader)
Constructor for testing purposes.
|
LocalExecutor(URL defaultEnv,
List<URL> jars,
List<URL> libraries)
Creates a local executor for submitting table programs and retrieving results.
|
Modifier and Type | Method and Description |
---|---|
void |
addView(String sessionId,
String name,
String query)
Add a new view to the given session.
|
void |
cancelQuery(String sessionId,
String resultId)
Cancels a table program and stops the result retrieval.
|
void |
closeSession(String sessionId)
Close the resources of session for given session id.
|
List<String> |
completeStatement(String sessionId,
String statement,
int position)
Returns a list of completion hints for the given statement at the given position.
|
void |
createTable(String sessionId,
String ddl)
Create a table with a DDL statement.
|
void |
dropTable(String sessionId,
String ddl)
Drop a table with a DDL statement.
|
ResultDescriptor |
executeQuery(String sessionId,
String query)
Submits a Flink SQL query job (detached) and returns the result descriptor.
|
ProgramTargetDescriptor |
executeUpdate(String sessionId,
String statement)
Submits a Flink SQL update statement such as INSERT INTO.
|
String |
explainStatement(String sessionId,
String statement)
Returns a string-based explanation about AST and execution plan of the given statement.
|
protected ExecutionContext<?> |
getExecutionContext(String sessionId)
Get the existed
ExecutionContext from contextMap, or thrown exception if does not exist. |
Map<String,String> |
getSessionProperties(String sessionId)
Lists all session properties that are defined by the executor and the session.
|
TableSchema |
getTableSchema(String sessionId,
String name)
Returns the schema of a table.
|
List<String> |
listCatalogs(String sessionId)
Lists all registered catalogs.
|
List<String> |
listDatabases(String sessionId)
Lists all databases in the current catalog.
|
List<String> |
listFunctions(String sessionId)
Lists all functions known to the executor.
|
List<String> |
listModules(String sessionId)
Lists all modules known to the executor in their loaded order.
|
List<String> |
listTables(String sessionId)
Lists all tables in the current database of the current catalog.
|
List<String> |
listUserDefinedFunctions(String sessionId)
Lists all user-defined functions known to the executor.
|
Map<String,ViewEntry> |
listViews(String sessionId)
Lists all registered views for the given session.
|
String |
openSession(SessionContext sessionContext)
Open a new session by using the given
SessionContext . |
void |
removeView(String sessionId,
String name)
Remove the view with given name for the given session.
|
void |
resetSessionProperties(String sessionId)
Reset all the properties for the given session identifier.
|
TypedResult<List<Tuple2<Boolean,Row>>> |
retrieveResultChanges(String sessionId,
String resultId)
Asks for the next changelog results (non-blocking).
|
List<Row> |
retrieveResultPage(String resultId,
int page)
Returns the rows that are part of the current page or throws an exception if the snapshot has been expired.
|
void |
setSessionProperty(String sessionId,
String key,
String value)
Set given key's session property to the specific value.
|
TypedResult<Integer> |
snapshotResult(String sessionId,
String resultId,
int pageSize)
Creates an immutable result snapshot of the running Flink job.
|
void |
start()
Starts the executor and ensures that its is ready for commands to be executed.
|
void |
useCatalog(String sessionId,
String catalogName)
Sets a catalog with given name as the current catalog.
|
void |
useDatabase(String sessionId,
String databaseName)
Sets a database with given name as the current database of the current catalog.
|
public LocalExecutor(URL defaultEnv, List<URL> jars, List<URL> libraries)
public LocalExecutor(Environment defaultEnvironment, List<URL> dependencies, Configuration flinkConfig, CustomCommandLine commandLine, ClusterClientServiceLoader clusterClientServiceLoader)
public void start()
Executor
public String openSession(SessionContext sessionContext) throws SqlExecutionException
Executor
SessionContext
.openSession
in interface Executor
sessionContext
- context to create new session.SqlExecutionException
- if any error happenpublic void closeSession(String sessionId) throws SqlExecutionException
Executor
closeSession
in interface Executor
sessionId
- session identifierSqlExecutionException
- if any error happen@VisibleForTesting protected ExecutionContext<?> getExecutionContext(String sessionId) throws SqlExecutionException
ExecutionContext
from contextMap, or thrown exception if does not exist.SqlExecutionException
public Map<String,String> getSessionProperties(String sessionId) throws SqlExecutionException
Executor
getSessionProperties
in interface Executor
SqlExecutionException
public void resetSessionProperties(String sessionId) throws SqlExecutionException
Executor
resetSessionProperties
in interface Executor
sessionId
- to identifier the sessionSqlExecutionException
- if any error happen.public void setSessionProperty(String sessionId, String key, String value) throws SqlExecutionException
Executor
setSessionProperty
in interface Executor
key
- of the session propertyvalue
- of the session propertySqlExecutionException
- if any error happen.public void addView(String sessionId, String name, String query) throws SqlExecutionException
Executor
addView
in interface Executor
sessionId
- to identify the session.name
- of the view.query
- to represent the view.SqlExecutionException
public void removeView(String sessionId, String name) throws SqlExecutionException
Executor
removeView
in interface Executor
sessionId
- to identify the session.name
- of the view.SqlExecutionException
public Map<String,ViewEntry> listViews(String sessionId) throws SqlExecutionException
Executor
listViews
in interface Executor
sessionId
- to identify the session.SqlExecutionException
public List<String> listCatalogs(String sessionId) throws SqlExecutionException
Executor
listCatalogs
in interface Executor
SqlExecutionException
public List<String> listDatabases(String sessionId) throws SqlExecutionException
Executor
listDatabases
in interface Executor
SqlExecutionException
public void createTable(String sessionId, String ddl) throws SqlExecutionException
Executor
createTable
in interface Executor
SqlExecutionException
public void dropTable(String sessionId, String ddl) throws SqlExecutionException
Executor
dropTable
in interface Executor
SqlExecutionException
public List<String> listTables(String sessionId) throws SqlExecutionException
Executor
listTables
in interface Executor
SqlExecutionException
public List<String> listUserDefinedFunctions(String sessionId) throws SqlExecutionException
Executor
listUserDefinedFunctions
in interface Executor
SqlExecutionException
public List<String> listFunctions(String sessionId) throws SqlExecutionException
Executor
listFunctions
in interface Executor
SqlExecutionException
public List<String> listModules(String sessionId) throws SqlExecutionException
Executor
listModules
in interface Executor
SqlExecutionException
public void useCatalog(String sessionId, String catalogName) throws SqlExecutionException
Executor
useCatalog
in interface Executor
SqlExecutionException
public void useDatabase(String sessionId, String databaseName) throws SqlExecutionException
Executor
useDatabase
in interface Executor
SqlExecutionException
public TableSchema getTableSchema(String sessionId, String name) throws SqlExecutionException
Executor
getTableSchema
in interface Executor
SqlExecutionException
public String explainStatement(String sessionId, String statement) throws SqlExecutionException
Executor
explainStatement
in interface Executor
SqlExecutionException
public List<String> completeStatement(String sessionId, String statement, int position)
Executor
completeStatement
in interface Executor
public ResultDescriptor executeQuery(String sessionId, String query) throws SqlExecutionException
Executor
executeQuery
in interface Executor
SqlExecutionException
public TypedResult<List<Tuple2<Boolean,Row>>> retrieveResultChanges(String sessionId, String resultId) throws SqlExecutionException
Executor
retrieveResultChanges
in interface Executor
SqlExecutionException
public TypedResult<Integer> snapshotResult(String sessionId, String resultId, int pageSize) throws SqlExecutionException
Executor
snapshotResult
in interface Executor
SqlExecutionException
public List<Row> retrieveResultPage(String resultId, int page) throws SqlExecutionException
Executor
retrieveResultPage
in interface Executor
SqlExecutionException
public void cancelQuery(String sessionId, String resultId) throws SqlExecutionException
Executor
cancelQuery
in interface Executor
SqlExecutionException
public ProgramTargetDescriptor executeUpdate(String sessionId, String statement) throws SqlExecutionException
Executor
executeUpdate
in interface Executor
sessionId
- to identify the user session.statement
- SQL update statement (currently only INSERT INTO is supported)SqlExecutionException
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.