From eba1c96d62bebfc592483500314e081de61d08ce Mon Sep 17 00:00:00 2001 From: zhyass <34016424+zhyass@users.noreply.github.com> Date: Fri, 17 Dec 2021 00:25:26 +0800 Subject: [PATCH 1/5] sql: push down filters --- common/planners/src/plan_display_indent.rs | 7 +++++++ .../sql/statements/query/query_collect_push_downs.rs | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/planners/src/plan_display_indent.rs b/common/planners/src/plan_display_indent.rs index bf5a7d1c24267..014e1f6896754 100644 --- a/common/planners/src/plan_display_indent.rs +++ b/common/planners/src/plan_display_indent.rs @@ -222,6 +222,13 @@ impl<'a> PlanNodeIndentFormatDisplay<'a> { comma = true; } + if p.filters.len() > 0 { + if comma { + write!(f, ", ")?; + } + write!(f, ", filters: {:?}", p.filters)?; + } + if p.limit.is_some() { if comma { write!(f, ", ")?; diff --git a/query/src/sql/statements/query/query_collect_push_downs.rs b/query/src/sql/statements/query/query_collect_push_downs.rs index 3866b27c969bd..285e2ebfdc73f 100644 --- a/query/src/sql/statements/query/query_collect_push_downs.rs +++ b/query/src/sql/statements/query/query_collect_push_downs.rs @@ -25,6 +25,7 @@ use crate::sql::statements::QueryASTIR; pub struct QueryCollectPushDowns { require_columns: HashSet, + require_filters: Vec, } /// Collect the query need to push downs parts . @@ -40,12 +41,18 @@ impl QueryASTIRVisitor for QueryCollectPushDowns { Ok(()) } + + fn visit_filter(predicate: &mut Expression, data: &mut QueryCollectPushDowns) -> Result<()> { + data.require_filters = vec![predicate.clone()]; + Ok(()) + } } impl QueryCollectPushDowns { pub fn collect_extras(ir: &mut QueryASTIR, schema: &mut JoinedSchema) -> Result<()> { let mut push_downs_data = Self { require_columns: HashSet::new(), + require_filters: vec![], }; QueryCollectPushDowns::visit(ir, &mut push_downs_data)?; push_downs_data.collect_push_downs(schema) @@ -58,8 +65,7 @@ impl QueryCollectPushDowns { schema.set_table_push_downs(index, Extras { projection: Some(projection), - // TODO: - filters: vec![], + filters: self.require_filters.clone(), limit: None, order_by: vec![], }); From fb20fae60135f2fcbb7ce330f9f02bdbdbeaf05b Mon Sep 17 00:00:00 2001 From: zhyass <34016424+zhyass@users.noreply.github.com> Date: Fri, 17 Dec 2021 01:07:48 +0800 Subject: [PATCH 2/5] fix invalid field --- query/src/sql/statements/query/query_collect_push_downs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query/src/sql/statements/query/query_collect_push_downs.rs b/query/src/sql/statements/query/query_collect_push_downs.rs index 285e2ebfdc73f..7adf6092733eb 100644 --- a/query/src/sql/statements/query/query_collect_push_downs.rs +++ b/query/src/sql/statements/query/query_collect_push_downs.rs @@ -44,7 +44,7 @@ impl QueryASTIRVisitor for QueryCollectPushDowns { fn visit_filter(predicate: &mut Expression, data: &mut QueryCollectPushDowns) -> Result<()> { data.require_filters = vec![predicate.clone()]; - Ok(()) + Self::visit_recursive_expr(predicate, data) } } From 5d48ab3f19c6c3ea14899366d1dabd4028588102 Mon Sep 17 00:00:00 2001 From: zhyass <34016424+zhyass@users.noreply.github.com> Date: Fri, 17 Dec 2021 01:33:23 +0800 Subject: [PATCH 3/5] fix lint --- common/functions/src/aggregates/aggregate_avg.rs | 2 +- common/planners/src/plan_display_indent.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/functions/src/aggregates/aggregate_avg.rs b/common/functions/src/aggregates/aggregate_avg.rs index 9e4c7aeac0faf..f0a90bc8c54b3 100644 --- a/common/functions/src/aggregates/aggregate_avg.rs +++ b/common/functions/src/aggregates/aggregate_avg.rs @@ -200,7 +200,7 @@ pub fn try_create_aggregate_avg_function( { Err(ErrorCode::BadDataValueType(format!( - "AggregateSumFunction does not support type '{:?}'", + "AggregateAvgFunction does not support type '{:?}'", data_type ))) }) diff --git a/common/planners/src/plan_display_indent.rs b/common/planners/src/plan_display_indent.rs index 014e1f6896754..433d3b770f082 100644 --- a/common/planners/src/plan_display_indent.rs +++ b/common/planners/src/plan_display_indent.rs @@ -222,11 +222,12 @@ impl<'a> PlanNodeIndentFormatDisplay<'a> { comma = true; } - if p.filters.len() > 0 { + if !p.filters.is_empty() { if comma { write!(f, ", ")?; } - write!(f, ", filters: {:?}", p.filters)?; + write!(f, "filters: {:?}", p.filters)?; + comma = true; } if p.limit.is_some() { From f6e0425daa24e8638cead24a2e56c7c41aacc8bd Mon Sep 17 00:00:00 2001 From: zhyass <34016424+zhyass@users.noreply.github.com> Date: Fri, 17 Dec 2021 11:08:11 +0800 Subject: [PATCH 4/5] fix test cases --- .../it/interpreters/interpreter_explain.rs | 16 +++++++------- query/tests/it/optimizers/optimizer.rs | 6 ++--- .../optimizers/optimizer_constant_folding.rs | 16 +++++++------- .../optimizer_expression_transform.rs | 22 +++++++++---------- .../tests/it/optimizers/optimizer_scatters.rs | 8 +++---- query/tests/it/sql/plan_parser.rs | 6 ++--- .../0_stateless/03_0005_select_filter.result | 2 +- .../suites/0_stateless/04_0000_explain.result | 2 +- .../0_stateless/08_0000_optimizer.result | 2 +- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/query/tests/it/interpreters/interpreter_explain.rs b/query/tests/it/interpreters/interpreter_explain.rs index da4358c062894..7d1e21dc66d7e 100644 --- a/query/tests/it/interpreters/interpreter_explain.rs +++ b/query/tests/it/interpreters/interpreter_explain.rs @@ -41,14 +41,14 @@ async fn test_explain_interpreter() -> Result<()> { assert_eq!(block.column(0).len(), 4); let expected = vec![ - "+-------------------------------------------------------------------------------------------------------------------------------------------------------+", - "| explain |", - "+-------------------------------------------------------------------------------------------------------------------------------------------------------+", - "| Projection: number:UInt64 |", - "| Having: ((number + 1) = 4) |", - "| Filter: ((number + 1) = 4) |", - "| ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]] |", - "+-------------------------------------------------------------------------------------------------------------------------------------------------------+", + "+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+", + "| explain |", + "+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+", + "| Projection: number:UInt64 |", + "| Having: ((number + 1) = 4) |", + "| Filter: ((number + 1) = 4) |", + "| ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [((number + 1) = 4)]] |", + "+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+", ]; common_datablocks::assert_blocks_eq(expected, result.as_slice()); } else { diff --git a/query/tests/it/optimizers/optimizer.rs b/query/tests/it/optimizers/optimizer.rs index f87f3f25b06d2..a84fb6e58ce39 100644 --- a/query/tests/it/optimizers/optimizer.rs +++ b/query/tests/it/optimizers/optimizer.rs @@ -56,7 +56,7 @@ fn test_literal_false_filter() -> Result<()> { let expect = "\ Projection: number:UInt64\ \n Filter: false\ - \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0]]"; + \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0], filters: [((1 + 2) = 2)]]"; assert_eq!(actual, expect); Ok(()) @@ -77,7 +77,7 @@ fn test_skip_read_data_source() -> Result<()> { expect:"\ Projection: number:UInt64\ \n Filter: false\ - \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0], filters: [((1 + 2) = 2)]]", }, Test { name: "Limit with zero should skip the scan", @@ -86,7 +86,7 @@ fn test_skip_read_data_source() -> Result<()> { Limit: 0\ \n Projection: number:UInt64\ \n Filter: true\ - \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0], filters: [true]]", }, Test { name: "Having with 'having 1+1=3' should skip the scan", diff --git a/query/tests/it/optimizers/optimizer_constant_folding.rs b/query/tests/it/optimizers/optimizer_constant_folding.rs index 740cc619c5cdd..45d8ea5c23b74 100644 --- a/query/tests/it/optimizers/optimizer_constant_folding.rs +++ b/query/tests/it/optimizers/optimizer_constant_folding.rs @@ -110,7 +110,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: (number > 1)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(true AND (number > 1))]]", }, Test { name: "Filter cond and true", @@ -118,7 +118,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: (number > 1)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [((number > 1) AND true)]]", }, Test { name: "Filter false and cond", @@ -126,7 +126,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: false\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(false AND (number > 1))]]", }, Test { name: "Filter cond and false", @@ -134,7 +134,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: false\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [((number > 1) AND false)]]", }, Test { name: "Filter false or cond", @@ -142,7 +142,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: (number > 1)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(false OR (number > 1))]]", }, Test { name: "Filter cond or false", @@ -150,7 +150,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: (number > 1)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [((number > 1) OR false)]]", }, Test { name: "Filter true or cond", @@ -158,7 +158,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: true\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(true OR (number > 1))]]", }, Test { name: "Filter cond or true", @@ -166,7 +166,7 @@ fn test_constant_folding_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: true\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [((number > 1) OR true)]]", }, ]; diff --git a/query/tests/it/optimizers/optimizer_expression_transform.rs b/query/tests/it/optimizers/optimizer_expression_transform.rs index 5d4d60a96d6b0..4b045a5759cf9 100644 --- a/query/tests/it/optimizers/optimizer_expression_transform.rs +++ b/query/tests/it/optimizers/optimizer_expression_transform.rs @@ -30,7 +30,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: ((number <= 1) or (number > 3))\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(NOT ((number > 1) AND (number <= 3)))]]", }, Test { name: "Complex expression", @@ -38,7 +38,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: ((number < 5) and ((number >= 3) or (NOT toBoolean(number))))\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(NOT ((number >= 5) OR ((number < 3) AND toBoolean(number))))]]", }, Test { name: "Like and isNotNull expression", @@ -46,7 +46,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: name:String\ \n Filter: (isnull(name) or (name not like %sys%))\ - \n ReadDataSource: scan partitions: [1], scan schema: [name:String], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [1], scan schema: [name:String], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0], filters: [(NOT (isNotNull(name) AND (name LIKE %sys%)))]]", }, Test { name: "Not like and isNull expression", @@ -54,7 +54,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: name:String\ \n Filter: (isnotnull(name) and (name like a%))\ - \n ReadDataSource: scan partitions: [1], scan schema: [name:String], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [1], scan schema: [name:String], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0], filters: [(NOT (isnull(name) OR (name NOT LIKE a%)))]]", }, Test { name: "Equal expression", @@ -62,7 +62,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: ((number <> 1) and (number < 5))\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [((NOT (number = 1)) AND (number < 5))]]", }, Test { name: "Not equal expression", @@ -70,7 +70,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: ((number = 1) or (number < 5))\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [((NOT (number <> 1)) OR (number < 5))]]", }, Test { name: "Not expression", @@ -78,7 +78,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: toBoolean(number)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(NOT (NOT toBoolean(number)))]]", }, Test { name: "Boolean transform", @@ -86,7 +86,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: (number != 0)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [number]]", }, Test { name: "Boolean and truth transform", @@ -94,7 +94,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: (number = 0)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(NOT number)]]", }, Test { name: "Literal boolean transform", @@ -102,7 +102,7 @@ fn test_expression_transform_optimizer() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: false\ - \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0], filters: [false]]", }, Test { name: "Limit zero transform", @@ -111,7 +111,7 @@ fn test_expression_transform_optimizer() -> Result<()> { Limit: 0\ \n Projection: number:UInt64\ \n Filter: true\ - \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [0], scan schema: [number:UInt64], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0], filters: [true]]", }, ]; diff --git a/query/tests/it/optimizers/optimizer_scatters.rs b/query/tests/it/optimizers/optimizer_scatters.rs index dda2f526051dd..40519b866835b 100644 --- a/query/tests/it/optimizers/optimizer_scatters.rs +++ b/query/tests/it/optimizers/optimizer_scatters.rs @@ -161,7 +161,7 @@ async fn test_scatter_optimizer() -> Result<()> { \n Create sub queries sets: [_subquery_1]\ \n Projection: number:UInt64\ \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]\ - \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0], filters: [exists(subquery(_subquery_1))]]", }, Test { name: "Standalone query with cluster subquery", @@ -172,7 +172,7 @@ async fn test_scatter_optimizer() -> Result<()> { \n RedistributeStage[expr: 0]\ \n Projection: number:UInt64\ \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]\ - \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0], filters: [exists(subquery(_subquery_1))]]", }, Test { name: "Cluster query with standalone subquery", @@ -185,7 +185,7 @@ async fn test_scatter_optimizer() -> Result<()> { \n Broadcast in cluster\ \n Projection: number:UInt64\ \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]\ - \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0], filters: [exists(subquery(_subquery_1))]]", }, Test { name: "Cluster query with cluster subquery", @@ -198,7 +198,7 @@ async fn test_scatter_optimizer() -> Result<()> { \n Broadcast in cluster\ \n Projection: number:UInt64\ \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]\ - \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 1, read_bytes: 8], push_downs: [projections: [0], filters: [exists(subquery(_subquery_1))]]", }, ]; diff --git a/query/tests/it/sql/plan_parser.rs b/query/tests/it/sql/plan_parser.rs index b36b2a4464b2a..416e002969207 100644 --- a/query/tests/it/sql/plan_parser.rs +++ b/query/tests/it/sql/plan_parser.rs @@ -180,7 +180,7 @@ fn test_plan_parser() -> Result<()> { \n AggregatorPartial: groupBy=[[(number % 3)]], aggr=[[sum((number + 1))]]\ \n Expression: (number % 3):UInt8, (number + 1):UInt64 (Before GroupBy)\ \n Filter: (number > 1)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(number > 1)]]", error: "", }, Test { @@ -195,7 +195,7 @@ fn test_plan_parser() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: NULL\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [NULL]]", error: "", }, Test { @@ -204,7 +204,7 @@ fn test_plan_parser() -> Result<()> { expect: "\ Projection: number:UInt64\ \n Filter: (NULL AND true)\ - \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0]]", + \n ReadDataSource: scan partitions: [8], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80], push_downs: [projections: [0], filters: [(NULL AND true)]]", error: "", }, Test { diff --git a/tests/suites/0_stateless/03_0005_select_filter.result b/tests/suites/0_stateless/03_0005_select_filter.result index 7849a828dd941..4135d287257ea 100644 --- a/tests/suites/0_stateless/03_0005_select_filter.result +++ b/tests/suites/0_stateless/03_0005_select_filter.result @@ -4,5 +4,5 @@ Projection: number as c1:UInt64, (number + 1) as c2:UInt64 Expression: number:UInt64, (number + 1):UInt64 (Before Projection) Filter: (number > 1) - ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 3, read_bytes: 24], push_downs: [projections: [0]] + ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 3, read_bytes: 24], push_downs: [projections: [0], filters: [(number > 1)]] 2 3 diff --git a/tests/suites/0_stateless/04_0000_explain.result b/tests/suites/0_stateless/04_0000_explain.result index 73dda416b12dc..bb71634bee959 100644 --- a/tests/suites/0_stateless/04_0000_explain.result +++ b/tests/suites/0_stateless/04_0000_explain.result @@ -5,4 +5,4 @@ Limit: 1 AggregatorPartial: groupBy=[[]], aggr=[[sum((number + 1))]] Expression: (number + 1):UInt64 (Before GroupBy) Filter: ((number + 1) = 4) - ReadDataSource: scan partitions: [16], scan schema: [number:UInt64], statistics: [read_rows: 80000, read_bytes: 640000], push_downs: [projections: [0]] + ReadDataSource: scan partitions: [16], scan schema: [number:UInt64], statistics: [read_rows: 80000, read_bytes: 640000], push_downs: [projections: [0], filters: [((number + 1) = 4)]] diff --git a/tests/suites/0_stateless/08_0000_optimizer.result b/tests/suites/0_stateless/08_0000_optimizer.result index f51cf3a2d27a2..36e4b410f4762 100644 --- a/tests/suites/0_stateless/08_0000_optimizer.result +++ b/tests/suites/0_stateless/08_0000_optimizer.result @@ -8,4 +8,4 @@ Projection: max((number + 1)) as c1:UInt64, ((number % 3) + 1) as c2:UInt16 projection push down: push (name and value) to read datasource Projection: a:Int32 Filter: (b > 10) - ReadDataSource: scan partitions: [0], scan schema: [a:Int32, b:Int32], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0, 1]] + ReadDataSource: scan partitions: [0], scan schema: [a:Int32, b:Int32], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0, 1], filters: [(b > 10)]] From e3dc40858f98a421d4681afffe70e931b265f1fa Mon Sep 17 00:00:00 2001 From: zhyass <34016424+zhyass@users.noreply.github.com> Date: Fri, 17 Dec 2021 12:31:16 +0800 Subject: [PATCH 5/5] fix stateless cluster test cases --- tests/suites/0_stateless/03_0005_select_filter_cluster.result | 2 +- tests/suites/0_stateless/08_0000_optimizer_cluster.result | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/0_stateless/03_0005_select_filter_cluster.result b/tests/suites/0_stateless/03_0005_select_filter_cluster.result index 3a83f101fc706..b62c3207e2394 100644 --- a/tests/suites/0_stateless/03_0005_select_filter_cluster.result +++ b/tests/suites/0_stateless/03_0005_select_filter_cluster.result @@ -5,5 +5,5 @@ RedistributeStage[expr: 0] Projection: number as c1:UInt64, (number + 1) as c2:UInt64 Expression: number:UInt64, (number + 1):UInt64 (Before Projection) Filter: (number > 1) - ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 3, read_bytes: 24], push_downs: [projections: [0]] + ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 3, read_bytes: 24], push_downs: [projections: [0], filters: [(number > 1)]] 2 3 diff --git a/tests/suites/0_stateless/08_0000_optimizer_cluster.result b/tests/suites/0_stateless/08_0000_optimizer_cluster.result index cfb7ab7e5ec7a..d896ba6786267 100644 --- a/tests/suites/0_stateless/08_0000_optimizer_cluster.result +++ b/tests/suites/0_stateless/08_0000_optimizer_cluster.result @@ -11,4 +11,4 @@ projection push down: push (name and value) to read datasource RedistributeStage[expr: 0] Projection: a:Int32 Filter: (b > 10) - ReadDataSource: scan partitions: [0], scan schema: [a:Int32, b:Int32], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0, 1]] + ReadDataSource: scan partitions: [0], scan schema: [a:Int32, b:Int32], statistics: [read_rows: 0, read_bytes: 0], push_downs: [projections: [0, 1], filters: [(b > 10)]]