hanahmily commented on code in PR #778: URL: https://github.com/apache/skywalking-banyandb/pull/778#discussion_r2366476106
########## api/proto/banyandb/bydbql/v1/query.proto: ########## @@ -0,0 +1,177 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +syntax = "proto3"; + +package banyandb.bydbql.v1; + +import "banyandb/common/v1/common.proto"; +import "banyandb/common/v1/trace.proto"; +import "banyandb/measure/v1/query.proto"; +import "banyandb/measure/v1/topn.proto"; +import "banyandb/property/v1/rpc.proto"; +import "banyandb/stream/v1/query.proto"; +import "banyandb/trace/v1/query.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/apache/skywalking-banyandb/api/proto/banyandb/bydbql/v1"; +option java_package = "org.apache.skywalking.banyandb.bydbql.v1"; + +// QueryExecutionContext provides resource context when FROM clause is omitted +message QueryExecutionContext { + // catalog indicates the type of resource (STREAM, MEASURE, PROPERTY, TRACE) + common.v1.Catalog catalog = 1 [(validate.rules).enum.defined_only = true]; + // name is the identity of the resource + string name = 2 [(validate.rules).string.min_len = 1]; + // group indicates where the data point is stored + string group = 3; +} + +// QueryRequest is the main request message for BydbQL queries +message QueryRequest { + // query is the BydbQL query string + string query = 1 [(validate.rules).string.min_len = 1]; + // execution_context provides resource context when FROM clause is omitted + // This field is optional when the FROM clause is present in the query + QueryExecutionContext execution_context = 2; +} + +// QueryResponse contains the result of a BydbQL query +message QueryResponse { + // result contains the actual query result based on the query type + oneof result { + // stream_result is returned for stream queries + stream.v1.QueryResponse stream_result = 1; + // measure_result is returned for measure queries + measure.v1.QueryResponse measure_result = 2; + // property_result is returned for property queries + property.v1.QueryResponse property_result = 3; + // trace_result is returned for trace queries + trace.v1.QueryResponse trace_result = 4; + // topn_result is returned for TopN queries + measure.v1.TopNResponse topn_result = 5; + } + // trace contains the trace information of the query when trace is enabled + common.v1.Trace trace = 6; + // error contains error information if the query failed + string error = 7; Review Comment: If the query failed, a gRPC error will be sent to the client. I don't see the use case of this field ########## api/proto/banyandb/bydbql/v1/query.proto: ########## @@ -0,0 +1,177 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +syntax = "proto3"; + +package banyandb.bydbql.v1; + +import "banyandb/common/v1/common.proto"; +import "banyandb/common/v1/trace.proto"; +import "banyandb/measure/v1/query.proto"; +import "banyandb/measure/v1/topn.proto"; +import "banyandb/property/v1/rpc.proto"; +import "banyandb/stream/v1/query.proto"; +import "banyandb/trace/v1/query.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/apache/skywalking-banyandb/api/proto/banyandb/bydbql/v1"; +option java_package = "org.apache.skywalking.banyandb.bydbql.v1"; + +// QueryExecutionContext provides resource context when FROM clause is omitted +message QueryExecutionContext { + // catalog indicates the type of resource (STREAM, MEASURE, PROPERTY, TRACE) + common.v1.Catalog catalog = 1 [(validate.rules).enum.defined_only = true]; + // name is the identity of the resource + string name = 2 [(validate.rules).string.min_len = 1]; + // group indicates where the data point is stored + string group = 3; +} + +// QueryRequest is the main request message for BydbQL queries +message QueryRequest { + // query is the BydbQL query string + string query = 1 [(validate.rules).string.min_len = 1]; + // execution_context provides resource context when FROM clause is omitted + // This field is optional when the FROM clause is present in the query + QueryExecutionContext execution_context = 2; +} + +// QueryResponse contains the result of a BydbQL query +message QueryResponse { + // result contains the actual query result based on the query type + oneof result { + // stream_result is returned for stream queries + stream.v1.QueryResponse stream_result = 1; + // measure_result is returned for measure queries + measure.v1.QueryResponse measure_result = 2; + // property_result is returned for property queries + property.v1.QueryResponse property_result = 3; + // trace_result is returned for trace queries + trace.v1.QueryResponse trace_result = 4; + // topn_result is returned for TopN queries + measure.v1.TopNResponse topn_result = 5; + } + // trace contains the trace information of the query when trace is enabled + common.v1.Trace trace = 6; Review Comment: Each response contains a `trace` field. What's the purpose of this `trace`? ########## api/proto/banyandb/bydbql/v1/query.proto: ########## @@ -0,0 +1,177 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +syntax = "proto3"; + +package banyandb.bydbql.v1; + +import "banyandb/common/v1/common.proto"; +import "banyandb/common/v1/trace.proto"; +import "banyandb/measure/v1/query.proto"; +import "banyandb/measure/v1/topn.proto"; +import "banyandb/property/v1/rpc.proto"; +import "banyandb/stream/v1/query.proto"; +import "banyandb/trace/v1/query.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/apache/skywalking-banyandb/api/proto/banyandb/bydbql/v1"; +option java_package = "org.apache.skywalking.banyandb.bydbql.v1"; + +// QueryExecutionContext provides resource context when FROM clause is omitted +message QueryExecutionContext { + // catalog indicates the type of resource (STREAM, MEASURE, PROPERTY, TRACE) + common.v1.Catalog catalog = 1 [(validate.rules).enum.defined_only = true]; + // name is the identity of the resource + string name = 2 [(validate.rules).string.min_len = 1]; + // group indicates where the data point is stored + string group = 3; Review Comment: `group` is mandatory. ########## api/proto/banyandb/bydbql/v1/rpc.proto: ########## @@ -0,0 +1,112 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +syntax = "proto3"; + +package banyandb.bydbql.v1; + +import "banyandb/bydbql/v1/query.proto"; +import "google/api/annotations.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +option go_package = "github.com/apache/skywalking-banyandb/api/proto/banyandb/bydbql/v1"; +option java_package = "org.apache.skywalking.banyandb.bydbql.v1"; +option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {base_path: "/api"}; + +// BydbQLService provides query interface for BanyanDB Query Language (BydbQL) +service BydbQLService { + // Query executes a generic BydbQL query with explicit FROM clause + // This endpoint requires the query to specify the resource type and name + // in the FROM clause (e.g., "FROM STREAM sw", "FROM MEASURE metrics") + rpc Query(QueryRequest) returns (QueryResponse) { + option (google.api.http) = { + post: "/v1/bydbql/query" + body: "*" + }; + } + + // QueryStream executes a BydbQL query against a specific stream resource + // The stream name is provided in the URL path, eliminating the need + // for a FROM clause in the query string + rpc QueryStream(QueryStreamRequest) returns (QueryStreamResponse) { + option (google.api.http) = { + post: "/v1/bydbql/stream/{group}/{name}/query" + body: "*" + additional_bindings: { + post: "/v1/bydbql/stream/{name}/query" + body: "*" + } Review Comment: ```suggestion ``` As I mentioned above, the `group` is not optional. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@skywalking.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org