From 273f58a9d14c1e70dc39e27d7753d450b300e5e1 Mon Sep 17 00:00:00 2001 From: zhang2014 Date: Mon, 18 Apr 2022 09:51:00 +0800 Subject: [PATCH 1/3] fixes(limit): fixes limit and offset with one block --- .../new/processors/transforms/transform_limit.rs | 15 +++++++++++++-- .../01_system/01_0004_system_engines.result | 2 ++ .../01_system/01_0004_system_engines.sql | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/suites/0_stateless/01_system/01_0004_system_engines.result create mode 100644 tests/suites/0_stateless/01_system/01_0004_system_engines.sql diff --git a/query/src/pipelines/new/processors/transforms/transform_limit.rs b/query/src/pipelines/new/processors/transforms/transform_limit.rs index 72a46f410a6a..72966d82a744 100644 --- a/query/src/pipelines/new/processors/transforms/transform_limit.rs +++ b/query/src/pipelines/new/processors/transforms/transform_limit.rs @@ -100,9 +100,20 @@ impl TransformLimitImpl { return None; } - let remaining = self.skip_remaining; self.skip_remaining = 0; - Some(data_block.slice(remaining, rows - remaining)) + + match MODE { + OFFSET_AND_LIMIT => { + let offset = self.skip_remaining; + let length = std::cmp::min(self.take_remaining, rows - offset); + self.take_remaining -= length; + Some(data_block.slice(offset, length)) + } + _ => { + let offset = self.skip_remaining; + Some(data_block.slice(offset, rows - offset)) + } + } } } diff --git a/tests/suites/0_stateless/01_system/01_0004_system_engines.result b/tests/suites/0_stateless/01_system/01_0004_system_engines.result new file mode 100644 index 000000000000..7a91b0cf8267 --- /dev/null +++ b/tests/suites/0_stateless/01_system/01_0004_system_engines.result @@ -0,0 +1,2 @@ +FUSE FUSE Storage Engine +GITHUB GITHUB Storage Engine diff --git a/tests/suites/0_stateless/01_system/01_0004_system_engines.sql b/tests/suites/0_stateless/01_system/01_0004_system_engines.sql new file mode 100644 index 000000000000..7c9aa0ae6936 --- /dev/null +++ b/tests/suites/0_stateless/01_system/01_0004_system_engines.sql @@ -0,0 +1 @@ +SELECT * FROM system.engines ORDER BY Engine LIMIT 1,2; From 4ded34297b899bc10f630567c1956912b7790038 Mon Sep 17 00:00:00 2001 From: zhang2014 Date: Mon, 18 Apr 2022 12:59:18 +0800 Subject: [PATCH 2/3] fixes(processor): fixes stateless test --- .../pipelines/new/processors/transforms/transform_limit.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/query/src/pipelines/new/processors/transforms/transform_limit.rs b/query/src/pipelines/new/processors/transforms/transform_limit.rs index 72966d82a744..fbc71a707e9a 100644 --- a/query/src/pipelines/new/processors/transforms/transform_limit.rs +++ b/query/src/pipelines/new/processors/transforms/transform_limit.rs @@ -100,17 +100,17 @@ impl TransformLimitImpl { return None; } - self.skip_remaining = 0; - match MODE { OFFSET_AND_LIMIT => { let offset = self.skip_remaining; + self.skip_remaining = 0; let length = std::cmp::min(self.take_remaining, rows - offset); self.take_remaining -= length; Some(data_block.slice(offset, length)) } _ => { let offset = self.skip_remaining; + self.skip_remaining = 0; Some(data_block.slice(offset, rows - offset)) } } From 909f454f660bd2df2d1a6e5f64cb02feb0551144 Mon Sep 17 00:00:00 2001 From: zhang2014 Date: Mon, 18 Apr 2022 13:42:28 +0800 Subject: [PATCH 3/3] fixes(processor): fixes stateless test --- .../suites/0_stateless/01_system/01_0004_system_engines.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/0_stateless/01_system/01_0004_system_engines.result b/tests/suites/0_stateless/01_system/01_0004_system_engines.result index 7a91b0cf8267..d652e4ee6db2 100644 --- a/tests/suites/0_stateless/01_system/01_0004_system_engines.result +++ b/tests/suites/0_stateless/01_system/01_0004_system_engines.result @@ -1,2 +1,2 @@ -FUSE FUSE Storage Engine GITHUB GITHUB Storage Engine +MEMORY MEMORY Storage Engine