public class SqlGatewayServiceImpl extends Object implements SqlGatewayService
SqlGatewayService
interface.Constructor and Description |
---|
SqlGatewayServiceImpl(SessionManager sessionManager) |
Modifier and Type | Method and Description |
---|---|
void |
cancelOperation(SessionHandle sessionHandle,
OperationHandle operationHandle)
Cancel the operation when it is not in terminal status.
|
void |
closeOperation(SessionHandle sessionHandle,
OperationHandle operationHandle)
Close the operation and release all used resource by the operation.
|
void |
closeSession(SessionHandle sessionHandle)
Close the
Session . |
List<String> |
completeStatement(SessionHandle sessionHandle,
String statement,
int position)
Returns a list of completion hints for the given statement at the given position.
|
void |
configureSession(SessionHandle sessionHandle,
String statement,
long executionTimeoutMs)
Using the statement to initialize the Session.
|
OperationHandle |
executeStatement(SessionHandle sessionHandle,
String statement,
long executionTimeoutMs,
Configuration executionConfig)
Execute the submitted statement.
|
ResultSet |
fetchResults(SessionHandle sessionHandle,
OperationHandle operationHandle,
FetchOrientation orientation,
int maxRows)
Fetch the results from the operation.
|
ResultSet |
fetchResults(SessionHandle sessionHandle,
OperationHandle operationHandle,
long token,
int maxRows)
Fetch the results from the operation.
|
String |
getCurrentCatalog(SessionHandle sessionHandle)
Return current catalog name.
|
FunctionDefinition |
getFunctionDefinition(SessionHandle sessionHandle,
UnresolvedIdentifier functionIdentifier)
Get the specific definition of the function.
|
GatewayInfo |
getGatewayInfo()
Get the info about the
SqlGatewayService . |
OperationInfo |
getOperationInfo(SessionHandle sessionHandle,
OperationHandle operationHandle)
Get the
OperationInfo of the operation. |
ResolvedSchema |
getOperationResultSchema(SessionHandle sessionHandle,
OperationHandle operationHandle)
Get the result schema for the specified Operation.
|
Session |
getSession(SessionHandle sessionHandle) |
Map<String,String> |
getSessionConfig(SessionHandle sessionHandle)
Get the current configuration of the
Session . |
EndpointVersion |
getSessionEndpointVersion(SessionHandle sessionHandle)
Get endpoint version that is negotiated in the openSession.
|
ResolvedCatalogBaseTable<?> |
getTable(SessionHandle sessionHandle,
ObjectIdentifier tableIdentifier)
Return table of the given fully qualified name.
|
Set<String> |
listCatalogs(SessionHandle sessionHandle)
Return all available catalogs in the current session.
|
Set<String> |
listDatabases(SessionHandle sessionHandle,
String catalogName)
Return all available schemas in the given catalog.
|
Set<FunctionInfo> |
listSystemFunctions(SessionHandle sessionHandle)
List all available system functions.
|
Set<TableInfo> |
listTables(SessionHandle sessionHandle,
String catalogName,
String databaseName,
Set<CatalogBaseTable.TableKind> tableKinds)
Return all available tables/views in the given catalog and database.
|
Set<FunctionInfo> |
listUserDefinedFunctions(SessionHandle sessionHandle,
String catalogName,
String databaseName)
List all user defined functions.
|
SessionHandle |
openSession(SessionEnvironment environment)
Open the
Session . |
OperationHandle |
refreshMaterializedTable(SessionHandle sessionHandle,
String materializedTableIdentifier,
boolean isPeriodic,
String scheduleTime,
Map<String,String> dynamicOptions,
Map<String,String> staticPartitions,
Map<String,String> executionConfig)
Trigger a refresh operation of specific materialized table.
|
OperationHandle |
submitOperation(SessionHandle sessionHandle,
Callable<ResultSet> executor)
Submit an operation and execute.
|
public SqlGatewayServiceImpl(SessionManager sessionManager)
public SessionHandle openSession(SessionEnvironment environment) throws SqlGatewayException
SqlGatewayService
Session
.openSession
in interface SqlGatewayService
environment
- Environment to initialize the Session.SqlGatewayException
public void closeSession(SessionHandle sessionHandle) throws SqlGatewayException
SqlGatewayService
Session
.closeSession
in interface SqlGatewayService
sessionHandle
- handle to identify the Session needs to be closed.SqlGatewayException
public void configureSession(SessionHandle sessionHandle, String statement, long executionTimeoutMs) throws SqlGatewayException
SqlGatewayService
It returns until the execution finishes.
configureSession
in interface SqlGatewayService
sessionHandle
- handle to identify the session.statement
- the statement used to configure the session.executionTimeoutMs
- the execution timeout. Please use non-positive value to forbid the
timeout mechanism.SqlGatewayException
public Map<String,String> getSessionConfig(SessionHandle sessionHandle) throws SqlGatewayException
SqlGatewayService
Session
.getSessionConfig
in interface SqlGatewayService
sessionHandle
- handle to identify the session.SqlGatewayException
public EndpointVersion getSessionEndpointVersion(SessionHandle sessionHandle) throws SqlGatewayException
SqlGatewayService
getSessionEndpointVersion
in interface SqlGatewayService
sessionHandle
- handle to identify the session.SqlGatewayException
public OperationHandle submitOperation(SessionHandle sessionHandle, Callable<ResultSet> executor) throws SqlGatewayException
SqlGatewayService
SqlGatewayService
will take care of the
execution and assign the OperationHandle
for later to retrieve the results.submitOperation
in interface SqlGatewayService
sessionHandle
- handle to identify the session.executor
- the main logic to get the execution results.SqlGatewayException
public void cancelOperation(SessionHandle sessionHandle, OperationHandle operationHandle)
SqlGatewayService
It can't cancel an Operation if it is terminated.
cancelOperation
in interface SqlGatewayService
sessionHandle
- handle to identify the session.operationHandle
- handle to identify the operation.JarURLConnectionpublic void closeOperation(SessionHandle sessionHandle, OperationHandle operationHandle)
SqlGatewayService
closeOperation
in interface SqlGatewayService
sessionHandle
- handle to identify the session.operationHandle
- handle to identify the operation.public OperationInfo getOperationInfo(SessionHandle sessionHandle, OperationHandle operationHandle)
SqlGatewayService
OperationInfo
of the operation.getOperationInfo
in interface SqlGatewayService
sessionHandle
- handle to identify the session.operationHandle
- handle to identify the operation.public ResolvedSchema getOperationResultSchema(SessionHandle sessionHandle, OperationHandle operationHandle) throws SqlGatewayException
SqlGatewayService
Note: The result schema is available when the Operation is in the OperationStatus.FINISHED
.
getOperationResultSchema
in interface SqlGatewayService
sessionHandle
- handle to identify the session.operationHandle
- handle to identify the operation.SqlGatewayException
public OperationHandle executeStatement(SessionHandle sessionHandle, String statement, long executionTimeoutMs, Configuration executionConfig) throws SqlGatewayException
SqlGatewayService
executeStatement
in interface SqlGatewayService
sessionHandle
- handle to identify the session.statement
- the SQL to execute.executionTimeoutMs
- the execution timeout. Please use non-positive value to forbid the
timeout mechanism.executionConfig
- execution config for the statement.SqlGatewayException
public ResultSet fetchResults(SessionHandle sessionHandle, OperationHandle operationHandle, long token, int maxRows) throws SqlGatewayException
SqlGatewayService
fetchResults
in interface SqlGatewayService
sessionHandle
- handle to identify the session.operationHandle
- handle to identify the operation.token
- token to identify results.maxRows
- max number of rows to fetch.SqlGatewayException
public ResultSet fetchResults(SessionHandle sessionHandle, OperationHandle operationHandle, FetchOrientation orientation, int maxRows)
SqlGatewayService
fetchResults
in interface SqlGatewayService
sessionHandle
- handle to identify the session.operationHandle
- handle to identify the operation.orientation
- orientation to fetch the results.maxRows
- max number of rows to fetch.public String getCurrentCatalog(SessionHandle sessionHandle)
SqlGatewayService
getCurrentCatalog
in interface SqlGatewayService
sessionHandle
- handle to identify the session.public Set<String> listCatalogs(SessionHandle sessionHandle) throws SqlGatewayException
SqlGatewayService
listCatalogs
in interface SqlGatewayService
sessionHandle
- handle to identify the session.SqlGatewayException
public Set<String> listDatabases(SessionHandle sessionHandle, String catalogName)
SqlGatewayService
listDatabases
in interface SqlGatewayService
sessionHandle
- handle to identify the session.catalogName
- name string of the given catalog.public Set<TableInfo> listTables(SessionHandle sessionHandle, String catalogName, String databaseName, Set<CatalogBaseTable.TableKind> tableKinds)
SqlGatewayService
listTables
in interface SqlGatewayService
sessionHandle
- handle to identify the session.catalogName
- name of the given catalog.databaseName
- name of the given database.tableKinds
- used to specify the type of return values.public ResolvedCatalogBaseTable<?> getTable(SessionHandle sessionHandle, ObjectIdentifier tableIdentifier) throws SqlGatewayException
SqlGatewayService
getTable
in interface SqlGatewayService
sessionHandle
- handle to identify the session.tableIdentifier
- fully qualified name of the table.SqlGatewayException
public OperationHandle refreshMaterializedTable(SessionHandle sessionHandle, String materializedTableIdentifier, boolean isPeriodic, @Nullable String scheduleTime, Map<String,String> dynamicOptions, Map<String,String> staticPartitions, Map<String,String> executionConfig)
SqlGatewayService
refreshMaterializedTable
in interface SqlGatewayService
sessionHandle
- handle to identify the session.materializedTableIdentifier
- A fully qualified materialized table identifier:
'catalogName.databaseName.objectName', used for locating the materialized table in
catalog.isPeriodic
- Represents whether the workflow is refreshed periodically or one-time-only.scheduleTime
- The time point at which the scheduler triggers this refresh operation.staticPartitions
- The specific partitions for one-time-only refresh workflow.executionConfig
- The flink job config.public Set<FunctionInfo> listUserDefinedFunctions(SessionHandle sessionHandle, String catalogName, String databaseName) throws SqlGatewayException
SqlGatewayService
listUserDefinedFunctions
in interface SqlGatewayService
sessionHandle
- handle to identify the session.catalogName
- name string of the given catalog.databaseName
- name string of the given database.SqlGatewayException
public Set<FunctionInfo> listSystemFunctions(SessionHandle sessionHandle)
SqlGatewayService
listSystemFunctions
in interface SqlGatewayService
sessionHandle
- handle to identify the session.public FunctionDefinition getFunctionDefinition(SessionHandle sessionHandle, UnresolvedIdentifier functionIdentifier) throws SqlGatewayException
SqlGatewayService
getFunctionDefinition
in interface SqlGatewayService
sessionHandle
- handle to identify the session.functionIdentifier
- identifier of the function.SqlGatewayException
public GatewayInfo getGatewayInfo()
SqlGatewayService
SqlGatewayService
.getGatewayInfo
in interface SqlGatewayService
public List<String> completeStatement(SessionHandle sessionHandle, String statement, int position) throws SqlGatewayException
SqlGatewayService
completeStatement
in interface SqlGatewayService
sessionHandle
- handle to identify the session.statement
- sql statement to be completed.position
- position of where need completion hints.SqlGatewayException
@VisibleForTesting public Session getSession(SessionHandle sessionHandle)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.