public Builder mergeFrom(com.dremio.exec.proto.UserProtos.GetCatalogsResp other) { if (other == com.dremio.exec.proto.UserProtos.GetCatalogsResp.getDefaultInstance()) return this; if (other.hasStatus()) { setStatus(other.getStatus()); if (other.hasError()) { mergeError(other.getError()); if (other.hasQueryId()) { mergeQueryId(other.getQueryId()); this.mergeUnknownFields(other.getUnknownFields()); return this;
@Override public GetCatalogsResp execute() throws Exception { final GetCatalogsResp.Builder respBuilder = GetCatalogsResp.newBuilder(); final Predicate<String> catalogNamePred = MetadataProviderConditions .getLikePredicate(req.hasCatalogNameFilter() ? req.getCatalogNameFilter() : null); final Iterable<Catalog> records = FluentIterable.<Catalog>from(table.<Catalog>asIterable(catalogName, username, datasetListing, null)) .filter(new Predicate<Catalog>() { @Override public boolean apply(Catalog input) { return catalogNamePred.apply(input.CATALOG_NAME); } }); List<CatalogMetadata> metadata = new ArrayList<>(); for(Catalog c : records) { final CatalogMetadata.Builder catBuilder = CatalogMetadata.newBuilder(); catBuilder.setCatalogName(c.CATALOG_NAME); catBuilder.setDescription(c.CATALOG_DESCRIPTION); catBuilder.setConnect(c.CATALOG_CONNECT); metadata.add(catBuilder.build()); } // Reorder results according to JDBC spec Collections.sort(metadata, CATALOGS_ORDERING); respBuilder.setQueryId(queryId); respBuilder.addAllCatalogs(metadata); respBuilder.setStatus(RequestStatus.OK); return respBuilder.build(); } }
public com.dremio.exec.proto.UserProtos.GetCatalogsResp buildPartial() { com.dremio.exec.proto.UserProtos.GetCatalogsResp result = new com.dremio.exec.proto.UserProtos.GetCatalogsResp(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
@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)); }
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeEnumSize(1, status_.getNumber()); } for (int i = 0; i < catalogs_.size(); i++) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, catalogs_.get(i)); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, error_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(13, queryId_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; }
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeEnum(1, status_.getNumber()); } for (int i = 0; i < catalogs_.size(); i++) { output.writeMessage(2, catalogs_.get(i)); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeMessage(3, error_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeMessage(13, queryId_); } getUnknownFields().writeTo(output); }
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(com.dremio.exec.proto.UserProtos.GetCatalogsResp prototype) {
@Test public void catalogsWithFilter() throws Exception { // test("SELECT * FROM INFORMATION_SCHEMA.CATALOGS " + // "WHERE CATALOG_NAME LIKE '%DRE%' ESCAPE '\\'"); // SQL equivalent GetCatalogsResp resp = client.getCatalogs(LikeFilter.newBuilder().setPattern("%DRE%").setEscape("\\").build()).get(); assertEquals(RequestStatus.OK, resp.getStatus()); List<CatalogMetadata> catalogs = resp.getCatalogsList(); assertEquals(1, catalogs.size()); CatalogMetadata c = catalogs.get(0); assertEquals(IS_CATALOG_NAME, c.getCatalogName()); assertEquals(IS_CATALOG_DESCR, c.getDescription()); assertEquals(IS_CATALOG_CONNECT, c.getConnect()); }
@Override protected List<CatalogMetadata> getResult(GetCatalogsResp response) { return response.getCatalogsList(); }
@Override protected RequestStatus getStatus(GetCatalogsResp response) { return response.getStatus(); }
public com.dremio.exec.proto.UserProtos.GetCatalogsResp getDefaultInstanceForType() { return com.dremio.exec.proto.UserProtos.GetCatalogsResp.getDefaultInstance(); }
@Override protected DremioPBError getError(GetCatalogsResp response) { return response.getError(); }
@Test public void catalogs() throws Exception { // test("SELECT * FROM INFORMATION_SCHEMA.CATALOGS"); // SQL equivalent GetCatalogsResp resp = client.getCatalogs(null).get(); assertEquals(RequestStatus.OK, resp.getStatus()); List<CatalogMetadata> catalogs = resp.getCatalogsList(); assertEquals(1, catalogs.size()); CatalogMetadata c = catalogs.get(0); assertEquals(IS_CATALOG_NAME, c.getCatalogName()); assertEquals(IS_CATALOG_DESCR, c.getDescription()); assertEquals(IS_CATALOG_CONNECT, c.getConnect()); }
public static Builder newBuilder(com.dremio.exec.proto.UserProtos.GetCatalogsResp prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
@Override protected GetCatalogsResp getException(UserException ex) { final GetCatalogsResp.Builder respBuilder = GetCatalogsResp.newBuilder(); respBuilder.setStatus(RequestStatus.FAILED); respBuilder.setError(createPBError("get catalogs", ex)); return respBuilder.build(); }
@Test public void getCatalogs() throws Exception { GetCatalogsResp resp = rpc.getCatalogs(LikeFilter.getDefaultInstance()).checkedGet(); JobDetailsUI job = getDetails(resp.getQueryId()); assertEquals(RequestType.GET_CATALOGS, job.getRequestType()); }
public void writeTo(io.protostuff.Output output, com.dremio.exec.proto.UserProtos.GetCatalogsResp message) throws java.io.IOException { if(message.hasStatus()) output.writeEnum(1, message.getStatus().getNumber(), false); for(com.dremio.exec.proto.UserProtos.CatalogMetadata catalogs : message.getCatalogsList()) output.writeObject(2, catalogs, com.dremio.exec.proto.SchemaUserProtos.CatalogMetadata.WRITE, true); 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.GetCatalogsResp message)
public com.dremio.exec.proto.UserProtos.GetCatalogsResp.Builder newMessage() { return com.dremio.exec.proto.UserProtos.GetCatalogsResp.newBuilder(); } public java.lang.String getFieldName(int number)
@Test public void catalogsWithFilterNegative() throws Exception { // test("SELECT * FROM INFORMATION_SCHEMA.CATALOGS // WHERE CATALOG_NAME LIKE '%DRIj\\\\hgjh%' ESCAPE '\\'"); // SQL equivalent GetCatalogsResp resp = client.getCatalogs(LikeFilter.newBuilder().setPattern("%DRIj\\%hgjh%").setEscape("\\").build()).get(); assertEquals(RequestStatus.OK, resp.getStatus()); List<CatalogMetadata> catalogs = resp.getCatalogsList(); assertEquals(0, catalogs.size()); }