From 73eaaebdf7f8dbe36c93398824a70859dfa981c1 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Thu, 16 Mar 2023 08:57:44 +0800 Subject: [PATCH 1/5] chore(storage): const predication returns empty partitions --- .../fuse/src/operations/read_partitions.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/query/storages/fuse/src/operations/read_partitions.rs b/src/query/storages/fuse/src/operations/read_partitions.rs index 4fe1f34154114..cee26270400cf 100644 --- a/src/query/storages/fuse/src/operations/read_partitions.rs +++ b/src/query/storages/fuse/src/operations/read_partitions.rs @@ -27,6 +27,8 @@ use common_catalog::plan::TopK; use common_catalog::table::Table; use common_catalog::table_context::TableContext; use common_exception::Result; +use common_expression::RemoteExpr; +use common_expression::Scalar; use common_expression::TableSchemaRef; use common_meta_app::schema::TableInfo; use common_storage::ColumnNodes; @@ -57,6 +59,18 @@ impl FuseTable { ) -> Result<(PartStatistics, Partitions)> { debug!("fuse table do read partitions, push downs:{:?}", push_downs); + if let Some(PushDownInfo { + filter: + Some(RemoteExpr::Constant { + scalar: Scalar::Boolean(false), + .. + }), + .. + }) = &push_downs + { + return Ok((PartStatistics::default(), Partitions::default())); + } + let snapshot = self.read_table_snapshot().await?; match snapshot { Some(snapshot) => { From 11c1c3c3919f9a08e03994cc09fc401a4e98d62a Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Thu, 16 Mar 2023 09:20:01 +0800 Subject: [PATCH 2/5] chore(storage): const predication returns empty partitions --- src/query/sql/src/executor/table_read_plan.rs | 20 ++++++++++++++++--- .../fuse/src/operations/read_partitions.rs | 15 -------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/query/sql/src/executor/table_read_plan.rs b/src/query/sql/src/executor/table_read_plan.rs index 3abaa27207f30..c146c9031734b 100644 --- a/src/query/sql/src/executor/table_read_plan.rs +++ b/src/query/sql/src/executor/table_read_plan.rs @@ -17,11 +17,15 @@ use std::sync::Arc; use common_catalog::plan::DataSourcePlan; use common_catalog::plan::InternalColumn; +use common_catalog::plan::PartStatistics; +use common_catalog::plan::Partitions; use common_catalog::plan::PushDownInfo; use common_catalog::table::Table; use common_catalog::table_context::TableContext; use common_exception::Result; use common_expression::FieldIndex; +use common_expression::RemoteExpr; +use common_expression::Scalar; #[async_trait::async_trait] pub trait ToReadDataSourcePlan { @@ -53,9 +57,19 @@ impl ToReadDataSourcePlan for dyn Table { push_downs: Option, internal_columns: Option>, ) -> Result { - let (statistics, parts) = self - .read_partitions(ctx.clone(), push_downs.clone()) - .await?; + let (statistics, parts) = if let Some(PushDownInfo { + filter: + Some(RemoteExpr::Constant { + scalar: Scalar::Boolean(false), + .. + }), + .. + }) = &push_downs + { + Ok((PartStatistics::default(), Partitions::default())) + } else { + self.read_partitions(ctx.clone(), push_downs.clone()).await + }?; // We need the partition sha256 to specify the result cache. if ctx.get_settings().get_enable_query_result_cache()? { diff --git a/src/query/storages/fuse/src/operations/read_partitions.rs b/src/query/storages/fuse/src/operations/read_partitions.rs index cee26270400cf..78e3e54b34481 100644 --- a/src/query/storages/fuse/src/operations/read_partitions.rs +++ b/src/query/storages/fuse/src/operations/read_partitions.rs @@ -27,8 +27,6 @@ use common_catalog::plan::TopK; use common_catalog::table::Table; use common_catalog::table_context::TableContext; use common_exception::Result; -use common_expression::RemoteExpr; -use common_expression::Scalar; use common_expression::TableSchemaRef; use common_meta_app::schema::TableInfo; use common_storage::ColumnNodes; @@ -58,19 +56,6 @@ impl FuseTable { push_downs: Option, ) -> Result<(PartStatistics, Partitions)> { debug!("fuse table do read partitions, push downs:{:?}", push_downs); - - if let Some(PushDownInfo { - filter: - Some(RemoteExpr::Constant { - scalar: Scalar::Boolean(false), - .. - }), - .. - }) = &push_downs - { - return Ok((PartStatistics::default(), Partitions::default())); - } - let snapshot = self.read_table_snapshot().await?; match snapshot { Some(snapshot) => { From 4f218f052c5ab33f811b7d8e4b46023fd03edf5a Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Thu, 16 Mar 2023 09:59:35 +0800 Subject: [PATCH 3/5] chore(storage): const predication returns empty partitions --- .../suites/mode/standalone/explain/select.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sqllogictests/suites/mode/standalone/explain/select.test b/tests/sqllogictests/suites/mode/standalone/explain/select.test index 6dfe7eb591a9e..9879645aea1b6 100644 --- a/tests/sqllogictests/suites/mode/standalone/explain/select.test +++ b/tests/sqllogictests/suites/mode/standalone/explain/select.test @@ -99,10 +99,10 @@ Filter ├── estimated rows: 0.00 └── TableScan ├── table: default.system.numbers - ├── read rows: 1 - ├── read bytes: 8 - ├── partitions total: 1 - ├── partitions scanned: 1 + ├── read rows: 0 + ├── read bytes: 0 + ├── partitions total: 0 + ├── partitions scanned: 0 ├── push downs: [filters: [false], limit: NONE] └── estimated rows: 1.00 From bab6b2f8e8adf6cbdb9efbc3fe9d5b2396ee0fc6 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Thu, 16 Mar 2023 10:37:25 +0800 Subject: [PATCH 4/5] update --- .../suites/mode/standalone/explain/select.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sqllogictests/suites/mode/standalone/explain/select.test b/tests/sqllogictests/suites/mode/standalone/explain/select.test index 9879645aea1b6..a794b593415ac 100644 --- a/tests/sqllogictests/suites/mode/standalone/explain/select.test +++ b/tests/sqllogictests/suites/mode/standalone/explain/select.test @@ -114,10 +114,10 @@ Filter ├── estimated rows: 0.00 └── TableScan ├── table: default.system.numbers - ├── read rows: 1 - ├── read bytes: 8 - ├── partitions total: 1 - ├── partitions scanned: 1 + ├── read rows: 0 + ├── read bytes: 0 + ├── partitions total: 0 + ├── partitions scanned: 0 ├── push downs: [filters: [false], limit: NONE] └── estimated rows: 1.00 From be10eb0d57d58303a827a4a8da71bfec301d52a5 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Thu, 16 Mar 2023 10:53:58 +0800 Subject: [PATCH 5/5] update --- .../suites/mode/standalone/explain/select.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sqllogictests/suites/mode/standalone/explain/select.test b/tests/sqllogictests/suites/mode/standalone/explain/select.test index a794b593415ac..fdab644de1d13 100644 --- a/tests/sqllogictests/suites/mode/standalone/explain/select.test +++ b/tests/sqllogictests/suites/mode/standalone/explain/select.test @@ -129,10 +129,10 @@ Filter ├── estimated rows: 0.00 └── TableScan ├── table: default.system.numbers - ├── read rows: 1 - ├── read bytes: 8 - ├── partitions total: 1 - ├── partitions scanned: 1 + ├── read rows: 0 + ├── read bytes: 0 + ├── partitions total: 0 + ├── partitions scanned: 0 ├── push downs: [filters: [false], limit: NONE] └── estimated rows: 1.00