Search in sources :

Example 16 with NoSuchStatementException

use of org.apache.calcite.avatica.NoSuchStatementException in project calcite-avatica by apache.

the class LocalService method apply.

public ExecuteResponse apply(PrepareAndExecuteRequest request) {
    try (final Context ignore = prepareAndExecuteTimer.start()) {
        final Meta.StatementHandle sh = new Meta.StatementHandle(request.connectionId, request.statementId, null);
        try {
            final Meta.ExecuteResult executeResult = meta.prepareAndExecute(sh, request.sql, request.maxRowCount, request.maxRowsInFirstFrame, new Meta.PrepareCallback() {

                @Override
                public Object getMonitor() {
                    return LocalService.class;
                }

                @Override
                public void clear() {
                }

                @Override
                public void assign(Meta.Signature signature, Meta.Frame firstFrame, long updateCount) {
                }

                @Override
                public void execute() {
                }
            });
            final List<ResultSetResponse> results = new ArrayList<>();
            for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) {
                results.add(toResponse(metaResultSet));
            }
            return new ExecuteResponse(results, false, serverLevelRpcMetadata);
        } catch (NoSuchStatementException e) {
            // The Statement doesn't exist anymore, bubble up this information
            return new ExecuteResponse(null, true, serverLevelRpcMetadata);
        }
    }
}
Also used : Context(org.apache.calcite.avatica.metrics.Timer.Context) Meta(org.apache.calcite.avatica.Meta) ArrayList(java.util.ArrayList) NoSuchStatementException(org.apache.calcite.avatica.NoSuchStatementException)

Aggregations

NoSuchStatementException (org.apache.calcite.avatica.NoSuchStatementException)16 SQLException (java.sql.SQLException)7 PreparedStatement (java.sql.PreparedStatement)6 AvaticaPreparedStatement (org.apache.calcite.avatica.AvaticaPreparedStatement)6 Statement (java.sql.Statement)3 ArrayList (java.util.ArrayList)3 NoSuchConnectionException (org.apache.calcite.avatica.NoSuchConnectionException)3 TypedValue (org.apache.calcite.avatica.remote.TypedValue)3 CalciteServerStatement (org.apache.calcite.server.CalciteServerStatement)3 DataContext (org.apache.calcite.DataContext)2 Meta (org.apache.calcite.avatica.Meta)2 Context (org.apache.calcite.avatica.metrics.Timer.Context)2 ISE (org.apache.druid.java.util.common.ISE)2 AuthenticationResult (org.apache.druid.server.security.AuthenticationResult)2 ForbiddenException (org.apache.druid.server.security.ForbiddenException)2 Connection (java.sql.Connection)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Nonnull (javax.annotation.Nonnull)1 AvaticaStatement (org.apache.calcite.avatica.AvaticaStatement)1 Common (org.apache.calcite.avatica.proto.Common)1