final RequestStatus status = resp.getStatus(); if (status != RequestStatus.OK) { final String errMsgFromServer = resp.getError() != null ? resp.getError().getMessage() : ""; throw new SQLException("Failed to create prepared statement: " + resp.getError()); h, signature, resp.getPreparedStatement(), resultSetType, resultSetConcurrency,
@Override protected MessageLite getResponseDefaultInstance(int rpcType) throws RpcException { switch (rpcType) { case RpcType.ACK_VALUE: return Ack.getDefaultInstance(); case RpcType.HANDSHAKE_VALUE: return BitToUserHandshake.getDefaultInstance(); case RpcType.QUERY_HANDLE_VALUE: return QueryId.getDefaultInstance(); case RpcType.QUERY_RESULT_VALUE: return QueryResult.getDefaultInstance(); case RpcType.QUERY_DATA_VALUE: return QueryData.getDefaultInstance(); case RpcType.QUERY_PLAN_FRAGMENTS_VALUE: return QueryPlanFragments.getDefaultInstance(); case RpcType.CATALOGS_VALUE: return GetCatalogsResp.getDefaultInstance(); case RpcType.SCHEMAS_VALUE: return GetSchemasResp.getDefaultInstance(); case RpcType.TABLES_VALUE: return GetTablesResp.getDefaultInstance(); case RpcType.COLUMNS_VALUE: return GetColumnsResp.getDefaultInstance(); case RpcType.PREPARED_STATEMENT_VALUE: return CreatePreparedStatementResp.getDefaultInstance(); case RpcType.SERVER_META_VALUE: return GetServerMetaResp.getDefaultInstance(); } throw new RpcException(String.format("Unable to deal with RpcType of %d", rpcType)); }
@Test public void prepare() throws Exception { CreatePreparedStatementResp resp = rpc.createPreparedStatement("select * from sys.options").checkedGet(); JobDetailsUI job = getDetails(resp.getQueryId()); assertTrue(job.getTimeSpentInPlanning() > 0); assertTrue(job.getSql() != null); rpc.executePreparedStatement(resp.getPreparedStatement().getServerHandle(), new UserResultsListener() {
public Builder toBuilder() { return newBuilder(this); }
public Builder mergeFrom(com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp other) { if (other == com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp.getDefaultInstance()) return this; if (other.hasStatus()) { setStatus(other.getStatus()); } if (other.hasPreparedStatement()) { mergePreparedStatement(other.getPreparedStatement()); } if (other.hasError()) { mergeError(other.getError()); } if (other.hasQueryId()) { mergeQueryId(other.getQueryId()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp prototype) {
public com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp getDefaultInstanceForType() { return com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp.getDefaultInstance(); }
public static Builder newBuilder(com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public static CreatePreparedStatementResp build(BatchSchema schema, ServerPreparedStatementState handle, QueryId queryId, String catalogName) { final CreatePreparedStatementResp.Builder respBuilder = CreatePreparedStatementResp.newBuilder(); final PreparedStatement.Builder prepStmtBuilder = PreparedStatement.newBuilder(); prepStmtBuilder.setServerHandle(PreparedStatementHandle.newBuilder().setServerInfo(handle.toByteString())); for (Field field : schema) { prepStmtBuilder.addColumns(serializeColumn(field, catalogName)); } respBuilder.setStatus(RequestStatus.OK); respBuilder.setPreparedStatement(prepStmtBuilder.build()); respBuilder.setQueryId(queryId); return respBuilder.build(); }
@Override protected CreatePreparedStatementResp getException(UserException ex) { final CreatePreparedStatementResp.Builder respBuilder = CreatePreparedStatementResp.newBuilder(); respBuilder.setStatus(RequestStatus.FAILED); respBuilder.setError(ex.getOrCreatePBError(false)); return respBuilder.build(); }
private static PreparedStatement createPrepareStmt(String query, boolean expectFailure, ErrorType errorType) throws Exception { CreatePreparedStatementResp resp = client.createPreparedStatement(query).get(); assertTrue("status field was not set", resp.hasStatus()); assertEquals(expectFailure ? RequestStatus.FAILED : RequestStatus.OK, resp.getStatus()); if (expectFailure) { assertEquals(errorType, resp.getError().getErrorType()); } return resp.getPreparedStatement(); }
public com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp.Builder newMessage() { return com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp.newBuilder(); } public java.lang.String getFieldName(int number)
public void writeTo(io.protostuff.Output output, com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp message) throws java.io.IOException { if(message.hasStatus()) output.writeEnum(1, message.getStatus().getNumber(), false); if(message.hasPreparedStatement()) output.writeObject(2, message.getPreparedStatement(), com.dremio.exec.proto.SchemaUserProtos.PreparedStatement.WRITE, false); if(message.hasError()) output.writeObject(3, message.getError(), com.dremio.exec.proto.SchemaUserBitShared.DremioPBError.WRITE, false); if(message.hasQueryId()) output.writeObject(13, message.getQueryId(), com.dremio.exec.proto.SchemaUserBitShared.QueryId.WRITE, false); } public boolean isInitialized(com.dremio.exec.proto.UserProtos.CreatePreparedStatementResp message)