This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new aff5806b Fix trace query with empty span_id list (#803)
aff5806b is described below
commit aff5806b6336ce94a1e6c48b8fbd2143ba60aade
Author: Huang Youliang <[email protected]>
AuthorDate: Sat Oct 11 10:20:28 2025 +0800
Fix trace query with empty span_id list (#803)
---
pkg/query/logical/trace/trace_plan_tag_filter.go | 6 +++--
test/cases/trace/data/input/in_empty_span_ids.yml | 30 +++++++++++++++++++++++
test/cases/trace/data/want/in_empty_span_ids.yml | 18 ++++++++++++++
test/cases/trace/trace.go | 1 +
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/pkg/query/logical/trace/trace_plan_tag_filter.go
b/pkg/query/logical/trace/trace_plan_tag_filter.go
index 619684dc..338be6a6 100644
--- a/pkg/query/logical/trace/trace_plan_tag_filter.go
+++ b/pkg/query/logical/trace/trace_plan_tag_filter.go
@@ -347,6 +347,7 @@ func buildSpanIDFilter(criteria *modelv1.Criteria,
spanIDTagName string) *spanID
return nil
}
+ var hasSpanIDCondition bool
var extractSpanIDs func(*modelv1.Criteria) []string
extractSpanIDs = func(c *modelv1.Criteria) []string {
if c == nil {
@@ -356,7 +357,8 @@ func buildSpanIDFilter(criteria *modelv1.Criteria,
spanIDTagName string) *spanID
switch c.GetExp().(type) {
case *modelv1.Criteria_Condition:
cond := c.GetCondition()
- if cond.Name == spanIDTagName && cond.Op ==
modelv1.Condition_BINARY_OP_EQ {
+ if cond.Name == spanIDTagName && (cond.Op ==
modelv1.Condition_BINARY_OP_EQ || cond.Op == modelv1.Condition_BINARY_OP_IN) {
+ hasSpanIDCondition = true
return extractIDsFromCondition(cond)
}
case *modelv1.Criteria_Le:
@@ -374,7 +376,7 @@ func buildSpanIDFilter(criteria *modelv1.Criteria,
spanIDTagName string) *spanID
}
spanIDs := extractSpanIDs(criteria)
- if len(spanIDs) > 0 {
+ if hasSpanIDCondition {
return newSpanIDFilter(spanIDs)
}
return nil
diff --git a/test/cases/trace/data/input/in_empty_span_ids.yml
b/test/cases/trace/data/input/in_empty_span_ids.yml
new file mode 100644
index 00000000..ba3ab4fb
--- /dev/null
+++ b/test/cases/trace/data/input/in_empty_span_ids.yml
@@ -0,0 +1,30 @@
+# 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.
+
+name: "sw"
+groups: ["test-trace-group"]
+tag_projection: ["trace_id"]
+order_by:
+ index_rule_name: "timestamp"
+ sort: "SORT_DESC"
+criteria:
+ condition:
+ name: "span_id"
+ op: "BINARY_OP_IN"
+ value:
+ str_array:
+ value: []
diff --git a/test/cases/trace/data/want/in_empty_span_ids.yml
b/test/cases/trace/data/want/in_empty_span_ids.yml
new file mode 100644
index 00000000..e2c71a95
--- /dev/null
+++ b/test/cases/trace/data/want/in_empty_span_ids.yml
@@ -0,0 +1,18 @@
+# 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.
+
+traces: []
diff --git a/test/cases/trace/trace.go b/test/cases/trace/trace.go
index f4db8137..fdf141f1 100644
--- a/test/cases/trace/trace.go
+++ b/test/cases/trace/trace.go
@@ -44,6 +44,7 @@ var _ = g.DescribeTable("Scanning Traces", func(args
helpers.Args) {
},
g.Entry("query by trace id", helpers.Args{Input: "eq_trace_id",
Duration: 1 * time.Hour}),
g.Entry("query by trace ids", helpers.Args{Input: "in_trace_ids",
Duration: 1 * time.Hour}),
+ g.Entry("query by empty span ids", helpers.Args{Input:
"in_empty_span_ids", Duration: 1 * time.Hour, WantEmpty: true}),
g.Entry("order by timestamp", helpers.Args{Input:
"order_timestamp_desc", Duration: 1 * time.Hour}),
g.Entry("order by duration", helpers.Args{Input: "order_duration_desc",
Duration: 1 * time.Hour}),
g.Entry("filter by service id", helpers.Args{Input:
"eq_service_order_timestamp_desc", Duration: 1 * time.Hour}),