use of org.apache.flink.table.client.gateway.context.ExecutionContext in project flink by apache.
the class LocalExecutor method executeOperation.
@Override
public TableResultInternal executeOperation(String sessionId, Operation operation) throws SqlExecutionException {
final ExecutionContext context = getExecutionContext(sessionId);
final TableEnvironmentInternal tEnv = (TableEnvironmentInternal) context.getTableEnvironment();
try {
return context.wrapClassLoader(() -> tEnv.executeInternal(operation));
} catch (Exception e) {
throw new SqlExecutionException(MESSAGE_SQL_EXECUTION_ERROR, e);
}
}
use of org.apache.flink.table.client.gateway.context.ExecutionContext in project flink by apache.
the class LocalExecutor method completeStatement.
@Override
public List<String> completeStatement(String sessionId, String statement, int position) {
final ExecutionContext context = getExecutionContext(sessionId);
final TableEnvironmentInternal tableEnv = (TableEnvironmentInternal) context.getTableEnvironment();
try {
return context.wrapClassLoader(() -> Arrays.asList(tableEnv.getParser().getCompletionHints(statement, position)));
} catch (Throwable t) {
// catch everything such that the query does not crash the executor
if (LOG.isDebugEnabled()) {
LOG.debug("Could not complete statement at " + position + ":" + statement, t);
}
return Collections.emptyList();
}
}
use of org.apache.flink.table.client.gateway.context.ExecutionContext in project flink by apache.
the class LocalExecutor method parseStatement.
@Override
public Operation parseStatement(String sessionId, String statement) throws SqlExecutionException {
final ExecutionContext context = getExecutionContext(sessionId);
final TableEnvironment tableEnv = context.getTableEnvironment();
Parser parser = ((TableEnvironmentInternal) tableEnv).getParser();
List<Operation> operations;
try {
operations = context.wrapClassLoader(() -> parser.parse(statement));
} catch (Exception e) {
throw new SqlExecutionException("Failed to parse statement: " + statement, e);
}
if (operations.isEmpty()) {
throw new SqlExecutionException("Failed to parse statement: " + statement);
}
return operations.get(0);
}
use of org.apache.flink.table.client.gateway.context.ExecutionContext in project flink by apache.
the class LocalExecutor method executeModifyOperations.
@Override
public TableResultInternal executeModifyOperations(String sessionId, List<ModifyOperation> operations) throws SqlExecutionException {
final ExecutionContext context = getExecutionContext(sessionId);
final TableEnvironmentInternal tEnv = (TableEnvironmentInternal) context.getTableEnvironment();
try {
return context.wrapClassLoader(() -> tEnv.executeInternal(operations));
} catch (Exception e) {
throw new SqlExecutionException(MESSAGE_SQL_EXECUTION_ERROR, e);
}
}
Aggregations