Search in sources :

Example 16 with SqlExecutionException

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);
}
Also used : SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) URL(java.net.URL)

Example 17 with SqlExecutionException

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);
}
Also used : SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) ExecutionContext(org.apache.flink.table.client.gateway.context.ExecutionContext) TableEnvironmentInternal(org.apache.flink.table.api.internal.TableEnvironmentInternal) TableEnvironment(org.apache.flink.table.api.TableEnvironment) ModifyOperation(org.apache.flink.table.operations.ModifyOperation) QueryOperation(org.apache.flink.table.operations.QueryOperation) Operation(org.apache.flink.table.operations.Operation) SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) Parser(org.apache.flink.table.delegation.Parser)

Example 18 with SqlExecutionException

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;
}
Also used : SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) SessionContext(org.apache.flink.table.client.gateway.context.SessionContext)

Example 19 with SqlExecutionException

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);
    }
}
Also used : SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) ExecutionContext(org.apache.flink.table.client.gateway.context.ExecutionContext) TableEnvironmentInternal(org.apache.flink.table.api.internal.TableEnvironmentInternal) SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException)

Aggregations

SqlExecutionException (org.apache.flink.table.client.gateway.SqlExecutionException)19 Configuration (org.apache.flink.configuration.Configuration)5 URL (java.net.URL)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Test (org.junit.Test)4 MalformedURLException (java.net.MalformedURLException)3 TableEnvironmentInternal (org.apache.flink.table.api.internal.TableEnvironmentInternal)3 ResultDescriptor (org.apache.flink.table.client.gateway.ResultDescriptor)3 ExecutionContext (org.apache.flink.table.client.gateway.context.ExecutionContext)3 IOException (java.io.IOException)2 SqlClientException (org.apache.flink.table.client.SqlClientException)2 RowData (org.apache.flink.table.data.RowData)2 ModifyOperation (org.apache.flink.table.operations.ModifyOperation)2 Operation (org.apache.flink.table.operations.Operation)2 QueryOperation (org.apache.flink.table.operations.QueryOperation)2 File (java.io.File)1 IOError (java.io.IOError)1 URISyntaxException (java.net.URISyntaxException)1 LinkedList (java.util.LinkedList)1