Search in sources :

Example 1 with SessionContext

use of org.apache.flink.table.client.gateway.context.SessionContext in project flink by apache.

the class LocalExecutor method executeQuery.

@Override
public ResultDescriptor executeQuery(String sessionId, QueryOperation query) throws SqlExecutionException {
    final TableResultInternal tableResult = executeOperation(sessionId, query);
    final SessionContext context = getSessionContext(sessionId);
    final ReadableConfig config = context.getReadableConfig();
    final DynamicResult result = resultStore.createResult(config, tableResult);
    checkArgument(tableResult.getJobClient().isPresent());
    String jobId = tableResult.getJobClient().get().getJobID().toString();
    // store the result under the JobID
    resultStore.storeResult(jobId, result);
    return new ResultDescriptor(jobId, tableResult.getResolvedSchema(), result.isMaterialized(), config, tableResult.getRowDataToStringConverter());
}
Also used : ReadableConfig(org.apache.flink.configuration.ReadableConfig) SessionContext(org.apache.flink.table.client.gateway.context.SessionContext) ResultDescriptor(org.apache.flink.table.client.gateway.ResultDescriptor) DynamicResult(org.apache.flink.table.client.gateway.local.result.DynamicResult) TableResultInternal(org.apache.flink.table.api.internal.TableResultInternal)

Example 2 with SessionContext

use of org.apache.flink.table.client.gateway.context.SessionContext in project flink by apache.

the class LocalExecutor method addJar.

@Override
public void addJar(String sessionId, String jarUrl) {
    final SessionContext context = getSessionContext(sessionId);
    context.addJar(jarUrl);
}
Also used : SessionContext(org.apache.flink.table.client.gateway.context.SessionContext)

Example 3 with SessionContext

use of org.apache.flink.table.client.gateway.context.SessionContext in project flink by apache.

the class LocalExecutor method closeSession.

@Override
public void closeSession(String sessionId) throws SqlExecutionException {
    resultStore.getResults().forEach((resultId) -> {
        try {
            cancelQuery(sessionId, resultId);
        } catch (Throwable t) {
        // ignore any throwable to keep the clean up running
        }
    });
    // Remove the session's ExecutionContext from contextMap and close it.
    SessionContext context = this.contextMap.remove(sessionId);
    if (context != null) {
        context.close();
    }
}
Also used : SessionContext(org.apache.flink.table.client.gateway.context.SessionContext)

Example 4 with SessionContext

use of org.apache.flink.table.client.gateway.context.SessionContext in project flink by apache.

the class LocalExecutor method setSessionProperty.

@Override
public void setSessionProperty(String sessionId, String key, String value) throws SqlExecutionException {
    SessionContext context = getSessionContext(sessionId);
    context.set(key, value);
}
Also used : SessionContext(org.apache.flink.table.client.gateway.context.SessionContext)

Example 5 with SessionContext

use of org.apache.flink.table.client.gateway.context.SessionContext in project flink by apache.

the class LocalExecutor method resetSessionProperties.

@Override
public void resetSessionProperties(String sessionId) throws SqlExecutionException {
    SessionContext context = getSessionContext(sessionId);
    context.reset();
}
Also used : SessionContext(org.apache.flink.table.client.gateway.context.SessionContext)

Aggregations

SessionContext (org.apache.flink.table.client.gateway.context.SessionContext)8 ReadableConfig (org.apache.flink.configuration.ReadableConfig)1 TableResultInternal (org.apache.flink.table.api.internal.TableResultInternal)1 ResultDescriptor (org.apache.flink.table.client.gateway.ResultDescriptor)1 SqlExecutionException (org.apache.flink.table.client.gateway.SqlExecutionException)1 DynamicResult (org.apache.flink.table.client.gateway.local.result.DynamicResult)1