You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2024/07/29 12:39:01 UTC
(skywalking-banyandb) branch main updated: Fix distributed query bug. (#501)
This is an automated email from the ASF dual-hosted git repository.
wusheng 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 43c18379 Fix distributed query bug. (#501)
43c18379 is described below
commit 43c18379381951f093d1ff3ecea64302146f83a5
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Mon Jul 29 20:38:56 2024 +0800
Fix distributed query bug. (#501)
---
CHANGES.md | 1 +
.../logical/measure/measure_plan_distributed.go | 2 +-
.../logical/stream/stream_plan_distributed.go | 2 +-
test/cases/measure/data/input/limit.yaml | 2 +-
test/cases/measure/data/want/limit.yaml | 17 ---------
test/cases/stream/data/input/offset.yaml | 1 +
test/cases/stream/data/want/offset.yaml | 40 ++++++++--------------
7 files changed, 19 insertions(+), 46 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 3cc60064..8aa375d3 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -31,6 +31,7 @@ Release Notes.
- Fix the wrong array flags parsing in command line. The array flags should be parsed by "StringSlice" instead of "StringArray".
- Fix a bug that the Stream module didn't support duplicated in index-based filtering and sorting
- Fix the bug that segment's reference count is increased twice when the controller try to create an existing segment.
+- Fix a bug where a distributed query would return an empty result if the "limit" was set much lower than the "offset".
### Documentation
- Introduce new doc menu structure.
diff --git a/pkg/query/logical/measure/measure_plan_distributed.go b/pkg/query/logical/measure/measure_plan_distributed.go
index bd4377a3..db4d7582 100644
--- a/pkg/query/logical/measure/measure_plan_distributed.go
+++ b/pkg/query/logical/measure/measure_plan_distributed.go
@@ -87,7 +87,7 @@ func (ud *unresolvedDistributed) Analyze(s logical.Schema) (logical.Plan, error)
Name: ud.originalQuery.Name,
Groups: ud.originalQuery.Groups,
Criteria: ud.originalQuery.Criteria,
- Limit: limit,
+ Limit: limit + ud.originalQuery.Offset,
OrderBy: ud.originalQuery.OrderBy,
}
if ud.groupByEntity {
diff --git a/pkg/query/logical/stream/stream_plan_distributed.go b/pkg/query/logical/stream/stream_plan_distributed.go
index 55a6b5fb..ac55dbdd 100644
--- a/pkg/query/logical/stream/stream_plan_distributed.go
+++ b/pkg/query/logical/stream/stream_plan_distributed.go
@@ -74,7 +74,7 @@ func (ud *unresolvedDistributed) Analyze(s logical.Schema) (logical.Plan, error)
Name: ud.originalQuery.Name,
Groups: ud.originalQuery.Groups,
Criteria: ud.originalQuery.Criteria,
- Limit: limit,
+ Limit: limit + ud.originalQuery.Offset,
OrderBy: ud.originalQuery.OrderBy,
}
if ud.originalQuery.OrderBy == nil {
diff --git a/test/cases/measure/data/input/limit.yaml b/test/cases/measure/data/input/limit.yaml
index 5f94caf2..3480ea80 100644
--- a/test/cases/measure/data/input/limit.yaml
+++ b/test/cases/measure/data/input/limit.yaml
@@ -23,5 +23,5 @@ tagProjection:
tags: ["entity_id"]
fieldProjection:
names: ["total", "value"]
-limit: 2
+limit: 1
offset: 3
diff --git a/test/cases/measure/data/want/limit.yaml b/test/cases/measure/data/want/limit.yaml
index 103a8c5d..4b4126fb 100644
--- a/test/cases/measure/data/want/limit.yaml
+++ b/test/cases/measure/data/want/limit.yaml
@@ -33,20 +33,3 @@ dataPoints:
str:
value: entity_4
timestamp: "2023-06-26T01:01:00Z"
-- fields:
- - name: total
- value:
- int:
- value: "50"
- - name: value
- value:
- int:
- value: "4"
- tagFamilies:
- - name: default
- tags:
- - key: entity_id
- value:
- str:
- value: entity_5
- timestamp: "2023-06-26T01:02:00Z"
\ No newline at end of file
diff --git a/test/cases/stream/data/input/offset.yaml b/test/cases/stream/data/input/offset.yaml
index 7613fae3..5036e061 100644
--- a/test/cases/stream/data/input/offset.yaml
+++ b/test/cases/stream/data/input/offset.yaml
@@ -24,3 +24,4 @@ projection:
- name: "data"
tags: ["data_binary"]
offset: 3
+limit: 1
diff --git a/test/cases/stream/data/want/offset.yaml b/test/cases/stream/data/want/offset.yaml
index 15ccfca3..ebbe32e0 100644
--- a/test/cases/stream/data/want/offset.yaml
+++ b/test/cases/stream/data/want/offset.yaml
@@ -16,29 +16,17 @@
# under the License.
elements:
- - elementId: "3"
- tagFamilies:
- - name: searchable
- tags:
- - key: trace_id
- value:
- str:
- value: "4"
- - name: data
- tags:
- - key: data_binary
- value:
- binaryData: YWJjMTIzIT8kKiYoKSctPUB+
- - elementId: "4"
- tagFamilies:
- - name: searchable
- tags:
- - key: trace_id
- value:
- str:
- value: "5"
- - name: data
- tags:
- - key: data_binary
- value:
- binaryData: YWJjMTIzIT8kKiYoKSctPUB+
\ No newline at end of file
+- elementId: "3"
+ tagFamilies:
+ - name: searchable
+ tags:
+ - key: trace_id
+ value:
+ str:
+ value: "4"
+ - name: data
+ tags:
+ - key: data_binary
+ value:
+ binaryData: YWJjMTIzIT8kKiYoKSctPUB+
+