diff --git a/query/src/pipelines/new/processors/transforms/transform_limit.rs b/query/src/pipelines/new/processors/transforms/transform_limit.rs index 72a46f410a6a..fbc71a707e9a 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; + 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)) + } + } } } 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..d652e4ee6db2 --- /dev/null +++ b/tests/suites/0_stateless/01_system/01_0004_system_engines.result @@ -0,0 +1,2 @@ +GITHUB GITHUB Storage Engine +MEMORY MEMORY 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;