use of org.apache.flink.table.client.gateway.SqlExecutionException in project flink by apache.
the class SessionContext method updateClassLoaderAndDependencies.
private void updateClassLoaderAndDependencies(Collection<URL> newDependencies) {
// merge the jar in config with the jar maintained in session
Set<URL> jarsInConfig;
try {
jarsInConfig = new HashSet<>(ConfigUtils.decodeListFromConfig(sessionConfiguration, PipelineOptions.JARS, URL::new));
} catch (MalformedURLException e) {
throw new SqlExecutionException("Failed to parse the option `pipeline.jars` in configuration.", e);
}
jarsInConfig.addAll(newDependencies);
ConfigUtils.encodeCollectionToConfig(sessionConfiguration, PipelineOptions.JARS, new ArrayList<>(jarsInConfig), URL::toString);
// TODO: update the classloader in CatalogManager.
classLoader = ClientUtils.buildUserCodeClassLoader(new ArrayList<>(newDependencies), Collections.emptyList(), SessionContext.class.getClassLoader(), sessionConfiguration);
dependencies = new HashSet<>(newDependencies);
}
use of org.apache.flink.table.client.gateway.SqlExecutionException 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.SqlExecutionException in project flink by apache.
the class LocalExecutor method openSession.
@Override
public String openSession(@Nullable String sessionId) throws SqlExecutionException {
SessionContext sessionContext = LocalContextUtils.buildSessionContext(sessionId, defaultContext);
sessionId = sessionContext.getSessionId();
if (this.contextMap.containsKey(sessionId)) {
throw new SqlExecutionException("Found another session with the same session identifier: " + sessionId);
} else {
this.contextMap.put(sessionId, sessionContext);
}
return sessionId;
}
use of org.apache.flink.table.client.gateway.SqlExecutionException 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