add limit_offset testcase
@@ -13,6 +13,36 @@ async fn test_transform_limit() -> anyhow::Result<()> {
use crate::pipelines::processors::*;
use crate::pipelines::transforms::*;
+ let testcases = vec![
+ ((Some(2), 0), vec![
+ "+--------+",
+ "| number |",
+ "+--------+",
+ "| 7 |",
+ "| 6 |",
+ "+--------+",
+ ]),
+ ((Some(2), 2), vec![
+ "+--------+",
+ "| number |",
+ "+--------+",
+ "| 4 |",
+ "| 5 |",
+ "+--------+",
+ ]),
+ ((None, 4), vec![
+ "+--------+",
+ "| number |",
+ "+--------+",
+ "| 0 |",
+ "| 1 |",
+ "| 2 |",
+ "| 3 |",
+ "+--------+",
+ ]),
+ ];
+
+ for ((limit, offset), expected) in testcases {
let ctx = crate::tests::try_create_context()?;
let test_source = crate::tests::NumberTestData::create(ctx.clone());
@@ -24,7 +54,7 @@ async fn test_transform_limit() -> anyhow::Result<()> {
pipeline.merge_processor()?;
if let PlanNode::Limit(plan) = PlanBuilder::create(test_source.number_schema_for_test()?)
- .limit(2)?
+ .limit_offset(limit, offset)?
.build()?
{
pipeline.add_simple_transform(|| {
@@ -37,15 +67,8 @@ async fn test_transform_limit() -> anyhow::Result<()> {
let block = &result[0];
assert_eq!(block.num_columns(), 1);
- let expected = vec![
- "+--------+",
- "| number |",
- "+--------+",
- "| 7 |",
- "| 6 |",
- "+--------+",
- ];
common_datablocks::assert_blocks_sorted_eq(expected, result.as_slice());
+ }
Ok(())
}
