diff --git a/CHANGES.md b/CHANGES.md index 3cc600644..8aa375d35 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 bd4377a39..db4d75821 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 55a6b5fb3..ac55dbdd3 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 5f94caf28..3480ea806 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 103a8c5d1..4b4126fb7 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 7613fae33..5036e0619 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 15ccfca34..ebbe32e02 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+ +