diff --git a/Cargo.lock b/Cargo.lock index b8233527a9d2..c5c104f1406f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1724,7 +1724,10 @@ version = "0.1.0" dependencies = [ "common-catalog", "common-datavalues", + "common-meta-app", + "common-meta-types", "parking_lot 0.12.1", + "serde", ] [[package]] diff --git a/src/query/catalog/src/table.rs b/src/query/catalog/src/table.rs index cbdfee07217e..abedbae893aa 100644 --- a/src/query/catalog/src/table.rs +++ b/src/query/catalog/src/table.rs @@ -29,7 +29,6 @@ use common_legacy_planners::Extras; use common_legacy_planners::Partitions; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableInfo; use common_meta_types::MetaId; use common_pipeline_core::Pipeline; @@ -166,7 +165,8 @@ pub trait Table: Sync + Send { async fn truncate( &self, _ctx: Arc, - _truncate_plan: TruncateTablePlan, + _catalog_name: &str, + _purge: bool, ) -> Result<()> { Err(ErrorCode::UnImplement(format!( "truncate for table {} is not implemented", diff --git a/src/query/legacy-planners/src/lib.rs b/src/query/legacy-planners/src/lib.rs index 87db0d960d8b..580f8b65262d 100644 --- a/src/query/legacy-planners/src/lib.rs +++ b/src/query/legacy-planners/src/lib.rs @@ -15,13 +15,6 @@ mod plan_aggregator_final; mod plan_aggregator_partial; mod plan_broadcast; -mod plan_call; -mod plan_copy; -mod plan_database_create; -mod plan_database_drop; -mod plan_database_rename; -mod plan_database_show_create; -mod plan_database_undrop; mod plan_delete; mod plan_empty; mod plan_explain; @@ -40,10 +33,8 @@ mod plan_expression_visitor; mod plan_filter; mod plan_having; mod plan_insert_into; -mod plan_kill; mod plan_limit; mod plan_limit_by; -mod plan_list; mod plan_node; mod plan_node_builder; mod plan_node_display; @@ -55,72 +46,20 @@ mod plan_node_stage_table; mod plan_node_statistics; mod plan_node_visitor; mod plan_partition; -mod plan_privilege_grant; -mod plan_privilege_revoke; mod plan_projection; mod plan_read_datasource; mod plan_remote; -mod plan_role_create; -mod plan_role_drop; -mod plan_role_grant; -mod plan_role_revoke; mod plan_select; mod plan_setting; -mod plan_show; -mod plan_show_databases; -mod plan_show_engines; -mod plan_show_functions; -mod plan_show_grants; -mod plan_show_metrics; -mod plan_show_processlist; -mod plan_show_roles; -mod plan_show_settings; -mod plan_show_tables; -mod plan_show_tables_status; -mod plan_show_users; mod plan_sink; mod plan_sort; mod plan_subqueries_set; -mod plan_table_alter_cluster_key; -mod plan_table_describe; -mod plan_table_drop; -mod plan_table_drop_cluster_key; -mod plan_table_exists; -mod plan_table_optimize; mod plan_table_recluster; -mod plan_table_rename; -mod plan_table_show_create; -mod plan_table_truncate; -mod plan_table_undrop; -mod plan_use_database; -mod plan_user_alter; -mod plan_user_create; -mod plan_user_drop; -mod plan_user_stage_create; -mod plan_user_stage_describe; -mod plan_user_stage_drop; -mod plan_user_stage_remove; -mod plan_user_udf_alter; -mod plan_user_udf_create; -mod plan_user_udf_drop; -mod plan_view_alter; -mod plan_view_create; -mod plan_view_drop; mod plan_window_func; pub use plan_aggregator_final::AggregatorFinalPlan; pub use plan_aggregator_partial::AggregatorPartialPlan; pub use plan_broadcast::BroadcastPlan; -pub use plan_call::CallPlan; -pub use plan_copy::CopyMode; -pub use plan_copy::CopyPlan; -pub use plan_copy::ValidationMode; -pub use plan_database_create::CreateDatabasePlan; -pub use plan_database_drop::DropDatabasePlan; -pub use plan_database_rename::RenameDatabaseEntity; -pub use plan_database_rename::RenameDatabasePlan; -pub use plan_database_show_create::ShowCreateDatabasePlan; -pub use plan_database_undrop::UndropDatabasePlan; pub use plan_delete::DeletePlan; pub use plan_empty::EmptyPlan; pub use plan_explain::ExplainPlan; @@ -169,10 +108,8 @@ pub use plan_having::HavingPlan; pub use plan_insert_into::InsertInputSource; pub use plan_insert_into::InsertPlan; pub use plan_insert_into::InsertValueBlock; -pub use plan_kill::KillPlan; pub use plan_limit::LimitPlan; pub use plan_limit_by::LimitByPlan; -pub use plan_list::ListPlan; pub use plan_node::PlanNode; pub use plan_node_builder::PlanBuilder; pub use plan_node_extras::Extras; @@ -188,63 +125,18 @@ pub use plan_node_visitor::PlanVisitor; pub use plan_partition::PartInfo; pub use plan_partition::PartInfoPtr; pub use plan_partition::Partitions; -pub use plan_privilege_grant::GrantPrivilegePlan; -pub use plan_privilege_revoke::RevokePrivilegePlan; pub use plan_projection::ProjectionPlan; pub use plan_read_datasource::ReadDataSourcePlan; pub use plan_read_datasource::SourceInfo; pub use plan_remote::RemotePlan; pub use plan_remote::V1RemotePlan; pub use plan_remote::V2RemotePlan; -pub use plan_role_create::CreateRolePlan; -pub use plan_role_drop::DropRolePlan; -pub use plan_role_grant::GrantRolePlan; -pub use plan_role_revoke::RevokeRolePlan; pub use plan_select::SelectPlan; pub use plan_setting::SettingPlan; pub use plan_setting::VarValue; -pub use plan_show::PlanShowKind; -pub use plan_show::ShowPlan; -pub use plan_show_databases::ShowDatabasesPlan; -pub use plan_show_engines::ShowEnginesPlan; -pub use plan_show_functions::ShowFunctionsPlan; -pub use plan_show_grants::ShowGrantsPlan; -pub use plan_show_metrics::ShowMetricsPlan; -pub use plan_show_processlist::ShowProcessListsPlan; -pub use plan_show_roles::ShowRolesPlan; -pub use plan_show_settings::ShowSettingsPlan; -pub use plan_show_tables::ShowTablesPlan; -pub use plan_show_tables_status::ShowTablesStatusPlan; -pub use plan_show_users::ShowUsersPlan; pub use plan_sink::SinkPlan; pub use plan_sink::SINK_SCHEMA; pub use plan_sort::SortPlan; pub use plan_subqueries_set::SubQueriesSetPlan; -pub use plan_table_alter_cluster_key::AlterTableClusterKeyPlan; -pub use plan_table_describe::DescribeTablePlan; -pub use plan_table_drop::DropTablePlan; -pub use plan_table_drop_cluster_key::DropTableClusterKeyPlan; -pub use plan_table_exists::ExistsTablePlan; -pub use plan_table_optimize::OptimizeTableAction; -pub use plan_table_optimize::OptimizeTablePlan; pub use plan_table_recluster::ReclusterTablePlan; -pub use plan_table_rename::RenameTableEntity; -pub use plan_table_rename::RenameTablePlan; -pub use plan_table_show_create::ShowCreateTablePlan; -pub use plan_table_truncate::TruncateTablePlan; -pub use plan_table_undrop::UndropTablePlan; -pub use plan_use_database::UseDatabasePlan; -pub use plan_user_alter::AlterUserPlan; -pub use plan_user_create::CreateUserPlan; -pub use plan_user_drop::DropUserPlan; -pub use plan_user_stage_create::CreateUserStagePlan; -pub use plan_user_stage_describe::DescribeUserStagePlan; -pub use plan_user_stage_drop::DropUserStagePlan; -pub use plan_user_stage_remove::RemoveUserStagePlan; -pub use plan_user_udf_alter::AlterUserUDFPlan; -pub use plan_user_udf_create::CreateUserUDFPlan; -pub use plan_user_udf_drop::DropUserUDFPlan; -pub use plan_view_alter::AlterViewPlan; -pub use plan_view_create::CreateViewPlan; -pub use plan_view_drop::DropViewPlan; pub use plan_window_func::WindowFuncPlan; diff --git a/src/query/legacy-planners/src/plan_copy.rs b/src/query/legacy-planners/src/plan_copy.rs deleted file mode 100644 index 3ae3bf1e4f67..000000000000 --- a/src/query/legacy-planners/src/plan_copy.rs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2021 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::fmt::Debug; -use std::fmt::Formatter; -use std::str::FromStr; - -use common_datavalues::DataSchemaRef; -use common_meta_types::MetaId; - -use crate::PlanNode; -use crate::ReadDataSourcePlan; -use crate::StageTableInfo; - -#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug)] -pub enum ValidationMode { - None, - ReturnNRows(u64), - ReturnErrors, - ReturnAllErrors, -} - -impl FromStr for ValidationMode { - type Err = String; - fn from_str(s: &str) -> Result { - match s.to_uppercase().as_str() { - "" => Ok(ValidationMode::None), - "RETURN_ERRORS" => Ok(ValidationMode::ReturnErrors), - "RETURN_ALL_ERRORS" => Ok(ValidationMode::ReturnAllErrors), - v => { - let rows_str = v.replace("RETURN_", "").replace("_ROWS", ""); - let rows = rows_str.parse::(); - match rows { - Ok(v) => Ok(ValidationMode::ReturnNRows(v)), - Err(_) => Err(format!( - "Unknown validation mode:{:?}, must one of {{ RETURN__ROWS | RETURN_ERRORS | RETURN_ALL_ERRORS}}", - v - )), - } - } - } - } -} - -#[derive(serde::Serialize, serde::Deserialize, PartialEq, Clone)] -pub struct CopyPlan { - pub copy_mode: CopyMode, - - pub validation_mode: ValidationMode, -} - -/// CopyPlan supports CopyIntoTable & CopyIntoStage -#[allow(clippy::large_enum_variant)] -#[derive(serde::Serialize, serde::Deserialize, PartialEq, Clone)] -pub enum CopyMode { - IntoTable { - catalog_name: String, - db_name: String, - tbl_name: String, - tbl_id: MetaId, - files: Vec, - pattern: String, - schema: DataSchemaRef, - from: ReadDataSourcePlan, - }, - - IntoStage { - stage_table_info: StageTableInfo, - query: Box, - }, -} - -impl CopyPlan { - pub fn schema(&self) -> DataSchemaRef { - match &self.copy_mode { - CopyMode::IntoTable { schema, .. } => schema.clone(), - CopyMode::IntoStage { - stage_table_info, .. - } => stage_table_info.schema.clone(), - } - } -} - -impl Debug for CopyPlan { - // Ignore the schema. - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match &self.copy_mode { - CopyMode::IntoTable { - db_name, - tbl_name, - files, - pattern, - from, - .. - } => { - write!(f, "Copy into {:}.{:}", db_name, tbl_name)?; - write!(f, ", {:?}", from)?; - if !files.is_empty() { - write!(f, " ,files:{:?}", files)?; - } - if !pattern.is_empty() { - write!(f, " ,pattern:{:?}", pattern)?; - } - write!(f, " ,validation_mode:{:?}", self.validation_mode)?; - } - CopyMode::IntoStage { - stage_table_info, - query, - } => { - write!(f, "Copy into {:?}", stage_table_info)?; - write!(f, ", query: {:?})", query)?; - } - } - Ok(()) - } -} diff --git a/src/query/legacy-planners/src/plan_show.rs b/src/query/legacy-planners/src/plan_show.rs deleted file mode 100644 index eb97de9699b0..000000000000 --- a/src/query/legacy-planners/src/plan_show.rs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::sync::Arc; - -use common_datavalues::DataSchema; -use common_datavalues::DataSchemaRef; - -use crate::plan_show_tables_status::ShowTablesStatusPlan; -use crate::ShowDatabasesPlan; -use crate::ShowEnginesPlan; -use crate::ShowFunctionsPlan; -use crate::ShowGrantsPlan; -use crate::ShowMetricsPlan; -use crate::ShowProcessListsPlan; -use crate::ShowRolesPlan; -use crate::ShowSettingsPlan; -use crate::ShowTablesPlan; -use crate::ShowUsersPlan; - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub enum PlanShowKind { - All, - - // show databases like '%xx%' - Like(String), - - // show tables where name like '%xx%' - Where(String), -} - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub enum ShowPlan { - ShowDatabases(ShowDatabasesPlan), - ShowTables(ShowTablesPlan), - ShowEngines(ShowEnginesPlan), - ShowFunctions(ShowFunctionsPlan), - ShowMetrics(ShowMetricsPlan), - ShowProcessList(ShowProcessListsPlan), - ShowSettings(ShowSettingsPlan), - ShowUsers(ShowUsersPlan), - ShowGrants(ShowGrantsPlan), - ShowRoles(ShowRolesPlan), - ShowTablesStatus(ShowTablesStatusPlan), - ShowStages, -} - -impl ShowPlan { - pub fn schema(&self) -> DataSchemaRef { - Arc::new(DataSchema::empty()) - } -} diff --git a/src/query/legacy-planners/src/plan_show_databases.rs b/src/query/legacy-planners/src/plan_show_databases.rs deleted file mode 100644 index f0d163e5d31d..000000000000 --- a/src/query/legacy-planners/src/plan_show_databases.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate::PlanShowKind; - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowDatabasesPlan { - pub kind: PlanShowKind, -} diff --git a/src/query/legacy-planners/src/plan_show_engines.rs b/src/query/legacy-planners/src/plan_show_engines.rs deleted file mode 100644 index 31253c3446e5..000000000000 --- a/src/query/legacy-planners/src/plan_show_engines.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowEnginesPlan {} diff --git a/src/query/legacy-planners/src/plan_show_functions.rs b/src/query/legacy-planners/src/plan_show_functions.rs deleted file mode 100644 index 5591627d68fd..000000000000 --- a/src/query/legacy-planners/src/plan_show_functions.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate::PlanShowKind; - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowFunctionsPlan { - pub kind: PlanShowKind, -} diff --git a/src/query/legacy-planners/src/plan_show_metrics.rs b/src/query/legacy-planners/src/plan_show_metrics.rs deleted file mode 100644 index 70d6ea8c6558..000000000000 --- a/src/query/legacy-planners/src/plan_show_metrics.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowMetricsPlan {} diff --git a/src/query/legacy-planners/src/plan_show_processlist.rs b/src/query/legacy-planners/src/plan_show_processlist.rs deleted file mode 100644 index 133a50e8d4c1..000000000000 --- a/src/query/legacy-planners/src/plan_show_processlist.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowProcessListsPlan {} diff --git a/src/query/legacy-planners/src/plan_show_roles.rs b/src/query/legacy-planners/src/plan_show_roles.rs deleted file mode 100644 index 635743b1349e..000000000000 --- a/src/query/legacy-planners/src/plan_show_roles.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2021 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug)] -pub struct ShowRolesPlan {} diff --git a/src/query/legacy-planners/src/plan_show_settings.rs b/src/query/legacy-planners/src/plan_show_settings.rs deleted file mode 100644 index db48009bd477..000000000000 --- a/src/query/legacy-planners/src/plan_show_settings.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowSettingsPlan {} diff --git a/src/query/legacy-planners/src/plan_show_tables.rs b/src/query/legacy-planners/src/plan_show_tables.rs deleted file mode 100644 index 2a5dce7f8f6a..000000000000 --- a/src/query/legacy-planners/src/plan_show_tables.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate::PlanShowKind; - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowTablesPlan { - pub kind: PlanShowKind, - pub showfull: bool, - // show tables from db1 [or in db1] - pub fromdb: Option, - // TRUE if dropped tables should be shown - pub with_history: bool, -} diff --git a/src/query/legacy-planners/src/plan_show_tables_status.rs b/src/query/legacy-planners/src/plan_show_tables_status.rs deleted file mode 100644 index f4dbaf2ec1fd..000000000000 --- a/src/query/legacy-planners/src/plan_show_tables_status.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2021 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate::PlanShowKind; - -#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug)] -pub struct ShowTablesStatusPlan { - pub kind: PlanShowKind, - // show tables from db1 [or in db1] - pub fromdb: Option, -} diff --git a/src/query/legacy-planners/src/plan_show_users.rs b/src/query/legacy-planners/src/plan_show_users.rs deleted file mode 100644 index 2403fd901458..000000000000 --- a/src/query/legacy-planners/src/plan_show_users.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct ShowUsersPlan {} diff --git a/src/query/legacy-planners/src/plan_user_stage_describe.rs b/src/query/legacy-planners/src/plan_user_stage_describe.rs deleted file mode 100644 index 26d6ed5982c9..000000000000 --- a/src/query/legacy-planners/src/plan_user_stage_describe.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use common_datavalues::prelude::*; -#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct DescribeUserStagePlan { - pub name: String, -} - -impl DescribeUserStagePlan { - pub fn schema(&self) -> DataSchemaRef { - DataSchemaRefExt::create(vec![ - DataField::new("name", Vu8::to_data_type()), - DataField::new("stage_type", Vu8::to_data_type()), - DataField::new("stage_params", Vu8::to_data_type()), - DataField::new("copy_options", Vu8::to_data_type()), - DataField::new("file_format_options", Vu8::to_data_type()), - DataField::new("comment", Vu8::to_data_type()), - ]) - } -} diff --git a/src/query/planner/Cargo.toml b/src/query/planner/Cargo.toml index 0ea063ee6c89..c39aad2e0bac 100644 --- a/src/query/planner/Cargo.toml +++ b/src/query/planner/Cargo.toml @@ -9,5 +9,8 @@ edition = "2021" [dependencies] common-catalog = { path = "../catalog" } common-datavalues = { path = "../datavalues" } +common-meta-app = { path = "../../meta/app" } +common-meta-types = { path = "../../meta/types" } parking_lot = "0.12" +serde = { version = "1", features = ["derive"] } diff --git a/src/query/planner/src/lib.rs b/src/query/planner/src/lib.rs index 7ca45609fd65..fac6a454027b 100644 --- a/src/query/planner/src/lib.rs +++ b/src/query/planner/src/lib.rs @@ -29,3 +29,6 @@ pub use metadata::Metadata; pub use metadata::MetadataRef; pub use metadata::TableEntry; pub use metadata::DUMMY_TABLE_INDEX; + +// Plan will be used publicly. +pub mod plans; diff --git a/src/query/legacy-planners/src/plan_table_alter_cluster_key.rs b/src/query/planner/src/plans/alter_table_cluster_key.rs similarity index 100% rename from src/query/legacy-planners/src/plan_table_alter_cluster_key.rs rename to src/query/planner/src/plans/alter_table_cluster_key.rs diff --git a/src/query/legacy-planners/src/plan_user_udf_alter.rs b/src/query/planner/src/plans/alter_udf.rs similarity index 91% rename from src/query/legacy-planners/src/plan_user_udf_alter.rs rename to src/query/planner/src/plans/alter_udf.rs index 6638fd8829f1..d71bde80008f 100644 --- a/src/query/legacy-planners/src/plan_user_udf_alter.rs +++ b/src/query/planner/src/plans/alter_udf.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; @@ -19,11 +18,11 @@ use common_datavalues::DataSchemaRef; use common_meta_types::UserDefinedFunction; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct AlterUserUDFPlan { +pub struct AlterUDFPlan { pub udf: UserDefinedFunction, } -impl AlterUserUDFPlan { +impl AlterUDFPlan { pub fn schema(&self) -> DataSchemaRef { Arc::new(DataSchema::empty()) } diff --git a/src/query/legacy-planners/src/plan_user_alter.rs b/src/query/planner/src/plans/alter_user.rs similarity index 97% rename from src/query/legacy-planners/src/plan_user_alter.rs rename to src/query/planner/src/plans/alter_user.rs index 779bfa116f28..470c0e1e8d76 100644 --- a/src/query/legacy-planners/src/plan_user_alter.rs +++ b/src/query/planner/src/plans/alter_user.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_view_alter.rs b/src/query/planner/src/plans/alter_view.rs similarity index 99% rename from src/query/legacy-planners/src/plan_view_alter.rs rename to src/query/planner/src/plans/alter_view.rs index 548045d3f17a..ad6b0e5721c5 100644 --- a/src/query/legacy-planners/src/plan_view_alter.rs +++ b/src/query/planner/src/plans/alter_view.rs @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_call.rs b/src/query/planner/src/plans/call.rs similarity index 96% rename from src/query/legacy-planners/src/plan_call.rs rename to src/query/planner/src/plans/call.rs index 5c064ecd94d3..8f8c57bdc144 100644 --- a/src/query/legacy-planners/src/plan_call.rs +++ b/src/query/planner/src/plans/call.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_database_create.rs b/src/query/planner/src/plans/create_database.rs similarity index 98% rename from src/query/legacy-planners/src/plan_database_create.rs rename to src/query/planner/src/plans/create_database.rs index 24137c1ce839..9fcce93cc1a5 100644 --- a/src/query/legacy-planners/src/plan_database_create.rs +++ b/src/query/planner/src/plans/create_database.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_role_create.rs b/src/query/planner/src/plans/create_role.rs similarity index 100% rename from src/query/legacy-planners/src/plan_role_create.rs rename to src/query/planner/src/plans/create_role.rs diff --git a/src/query/legacy-planners/src/plan_user_stage_create.rs b/src/query/planner/src/plans/create_stage.rs similarity index 91% rename from src/query/legacy-planners/src/plan_user_stage_create.rs rename to src/query/planner/src/plans/create_stage.rs index 98551b889517..9f501441e278 100644 --- a/src/query/legacy-planners/src/plan_user_stage_create.rs +++ b/src/query/planner/src/plans/create_stage.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; @@ -19,13 +18,13 @@ use common_datavalues::DataSchemaRef; use common_meta_types::UserStageInfo; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct CreateUserStagePlan { +pub struct CreateStagePlan { pub if_not_exists: bool, pub tenant: String, pub user_stage_info: UserStageInfo, } -impl CreateUserStagePlan { +impl CreateStagePlan { pub fn schema(&self) -> DataSchemaRef { Arc::new(DataSchema::empty()) } diff --git a/src/query/legacy-planners/src/plan_user_udf_create.rs b/src/query/planner/src/plans/create_udf.rs similarity index 91% rename from src/query/legacy-planners/src/plan_user_udf_create.rs rename to src/query/planner/src/plans/create_udf.rs index bcce8b4417a1..6ab46fec6eff 100644 --- a/src/query/legacy-planners/src/plan_user_udf_create.rs +++ b/src/query/planner/src/plans/create_udf.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,12 +19,12 @@ use common_datavalues::DataSchemaRef; use common_meta_types::UserDefinedFunction; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct CreateUserUDFPlan { +pub struct CreateUDFPlan { pub if_not_exists: bool, pub udf: UserDefinedFunction, } -impl CreateUserUDFPlan { +impl CreateUDFPlan { pub fn schema(&self) -> DataSchemaRef { Arc::new(DataSchema::empty()) } diff --git a/src/query/legacy-planners/src/plan_user_create.rs b/src/query/planner/src/plans/create_user.rs similarity index 97% rename from src/query/legacy-planners/src/plan_user_create.rs rename to src/query/planner/src/plans/create_user.rs index f696b46d0cf4..6c727561041c 100644 --- a/src/query/legacy-planners/src/plan_user_create.rs +++ b/src/query/planner/src/plans/create_user.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_view_create.rs b/src/query/planner/src/plans/create_view.rs similarity index 99% rename from src/query/legacy-planners/src/plan_view_create.rs rename to src/query/planner/src/plans/create_view.rs index c2405b2a908b..87d41fc8f11f 100644 --- a/src/query/legacy-planners/src/plan_view_create.rs +++ b/src/query/planner/src/plans/create_view.rs @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_table_describe.rs b/src/query/planner/src/plans/describe_table.rs similarity index 96% rename from src/query/legacy-planners/src/plan_table_describe.rs rename to src/query/planner/src/plans/describe_table.rs index b7859252d4e8..a59000f4be6d 100644 --- a/src/query/legacy-planners/src/plan_table_describe.rs +++ b/src/query/planner/src/plans/describe_table.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_database_drop.rs b/src/query/planner/src/plans/drop_database.rs similarity index 98% rename from src/query/legacy-planners/src/plan_database_drop.rs rename to src/query/planner/src/plans/drop_database.rs index 4356a714d486..3f0b24f19df9 100644 --- a/src/query/legacy-planners/src/plan_database_drop.rs +++ b/src/query/planner/src/plans/drop_database.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_role_drop.rs b/src/query/planner/src/plans/drop_role.rs similarity index 96% rename from src/query/legacy-planners/src/plan_role_drop.rs rename to src/query/planner/src/plans/drop_role.rs index 29416abfa50c..1190e62397ae 100644 --- a/src/query/legacy-planners/src/plan_role_drop.rs +++ b/src/query/planner/src/plans/drop_role.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_user_udf_drop.rs b/src/query/planner/src/plans/drop_stage.rs similarity index 91% rename from src/query/legacy-planners/src/plan_user_udf_drop.rs rename to src/query/planner/src/plans/drop_stage.rs index 814d611fd6d9..a7e7641bbcea 100644 --- a/src/query/legacy-planners/src/plan_user_udf_drop.rs +++ b/src/query/planner/src/plans/drop_stage.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,12 +18,12 @@ use common_datavalues::DataSchema; use common_datavalues::DataSchemaRef; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct DropUserUDFPlan { +pub struct DropStagePlan { pub if_exists: bool, pub name: String, } -impl DropUserUDFPlan { +impl DropStagePlan { pub fn schema(&self) -> DataSchemaRef { Arc::new(DataSchema::empty()) } diff --git a/src/query/legacy-planners/src/plan_table_drop.rs b/src/query/planner/src/plans/drop_table.rs similarity index 97% rename from src/query/legacy-planners/src/plan_table_drop.rs rename to src/query/planner/src/plans/drop_table.rs index d4725077014e..97671543f231 100644 --- a/src/query/legacy-planners/src/plan_table_drop.rs +++ b/src/query/planner/src/plans/drop_table.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_table_drop_cluster_key.rs b/src/query/planner/src/plans/drop_table_cluster_key.rs similarity index 99% rename from src/query/legacy-planners/src/plan_table_drop_cluster_key.rs rename to src/query/planner/src/plans/drop_table_cluster_key.rs index bacee31335df..46a5f38fd5b9 100644 --- a/src/query/legacy-planners/src/plan_table_drop_cluster_key.rs +++ b/src/query/planner/src/plans/drop_table_cluster_key.rs @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_user_stage_drop.rs b/src/query/planner/src/plans/drop_udf.rs similarity index 90% rename from src/query/legacy-planners/src/plan_user_stage_drop.rs rename to src/query/planner/src/plans/drop_udf.rs index 343b9b5eb238..620ad33b714f 100644 --- a/src/query/legacy-planners/src/plan_user_stage_drop.rs +++ b/src/query/planner/src/plans/drop_udf.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,19 +11,18 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; use common_datavalues::DataSchemaRef; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct DropUserStagePlan { +pub struct DropUDFPlan { pub if_exists: bool, pub name: String, } -impl DropUserStagePlan { +impl DropUDFPlan { pub fn schema(&self) -> DataSchemaRef { Arc::new(DataSchema::empty()) } diff --git a/src/query/legacy-planners/src/plan_user_drop.rs b/src/query/planner/src/plans/drop_user.rs similarity index 96% rename from src/query/legacy-planners/src/plan_user_drop.rs rename to src/query/planner/src/plans/drop_user.rs index 6ec90c534061..fa8a4a6b210f 100644 --- a/src/query/legacy-planners/src/plan_user_drop.rs +++ b/src/query/planner/src/plans/drop_user.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_view_drop.rs b/src/query/planner/src/plans/drop_view.rs similarity index 99% rename from src/query/legacy-planners/src/plan_view_drop.rs rename to src/query/planner/src/plans/drop_view.rs index a9b372469e38..7226209c11da 100644 --- a/src/query/legacy-planners/src/plan_view_drop.rs +++ b/src/query/planner/src/plans/drop_view.rs @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_table_exists.rs b/src/query/planner/src/plans/exists_table.rs similarity index 99% rename from src/query/legacy-planners/src/plan_table_exists.rs rename to src/query/planner/src/plans/exists_table.rs index 51bc1810da01..8ffed8c4b6c3 100644 --- a/src/query/legacy-planners/src/plan_table_exists.rs +++ b/src/query/planner/src/plans/exists_table.rs @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataField; diff --git a/src/query/legacy-planners/src/plan_privilege_grant.rs b/src/query/planner/src/plans/grant_privilege.rs similarity index 97% rename from src/query/legacy-planners/src/plan_privilege_grant.rs rename to src/query/planner/src/plans/grant_privilege.rs index e43f58b503f5..ca1984b8b5fc 100644 --- a/src/query/legacy-planners/src/plan_privilege_grant.rs +++ b/src/query/planner/src/plans/grant_privilege.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_role_grant.rs b/src/query/planner/src/plans/grant_role.rs similarity index 96% rename from src/query/legacy-planners/src/plan_role_grant.rs rename to src/query/planner/src/plans/grant_role.rs index 37b3a92273f5..08e3a49ec08a 100644 --- a/src/query/legacy-planners/src/plan_role_grant.rs +++ b/src/query/planner/src/plans/grant_role.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_kill.rs b/src/query/planner/src/plans/kill.rs similarity index 96% rename from src/query/legacy-planners/src/plan_kill.rs rename to src/query/planner/src/plans/kill.rs index 98dddbbb7e44..d42c5de5305f 100644 --- a/src/query/legacy-planners/src/plan_kill.rs +++ b/src/query/planner/src/plans/kill.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_list.rs b/src/query/planner/src/plans/list.rs similarity index 72% rename from src/query/legacy-planners/src/plan_list.rs rename to src/query/planner/src/plans/list.rs index 0eb0b3f87b6e..99fc081223c5 100644 --- a/src/query/legacy-planners/src/plan_list.rs +++ b/src/query/planner/src/plans/list.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,19 +11,12 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - -use std::fmt::Debug; -use std::fmt::Formatter; use std::sync::Arc; -use common_datavalues::prelude::ToDataType; use common_datavalues::prelude::*; -use common_datavalues::DataField; -use common_datavalues::DataSchema; -use common_datavalues::DataSchemaRef; use common_meta_types::UserStageInfo; -#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone)] +#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug)] pub struct ListPlan { pub stage: UserStageInfo, pub path: String, @@ -37,6 +30,7 @@ impl ListPlan { let md5 = DataField::new_nullable("md5", Vu8::to_data_type()); let last_modified = DataField::new("last_modified", Vu8::to_data_type()); let creator = DataField::new_nullable("creator", Vu8::to_data_type()); + Arc::new(DataSchema::new(vec![ name, size, @@ -46,14 +40,3 @@ impl ListPlan { ])) } } - -impl Debug for ListPlan { - // Ignore the schema. - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "List {:?}", self.stage)?; - if !self.pattern.is_empty() { - write!(f, " ,pattern:{:?}", self.pattern)?; - } - Ok(()) - } -} diff --git a/src/query/planner/src/plans/mod.rs b/src/query/planner/src/plans/mod.rs new file mode 100644 index 000000000000..6b81815bb3c8 --- /dev/null +++ b/src/query/planner/src/plans/mod.rs @@ -0,0 +1,94 @@ +// Copyright 2022 Datafuse Labs. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +mod alter_table_cluster_key; +mod alter_udf; +mod alter_user; +mod alter_view; +mod call; +mod create_database; +mod create_role; +mod create_stage; +mod create_udf; +mod create_user; +mod create_view; +mod describe_table; +mod drop_database; +mod drop_role; +mod drop_stage; +mod drop_table; +mod drop_table_cluster_key; +mod drop_udf; +mod drop_user; +mod drop_view; +mod exists_table; +mod grant_privilege; +mod grant_role; +mod kill; +mod list; +mod optimize_table; +mod remove_stage; +mod rename_database; +mod rename_table; +mod revoke_privilege; +mod revoke_role; +mod show_create_database; +mod show_create_table; +mod show_grants; +mod truncate_table; +mod undrop_database; +mod undrop_table; +mod use_database; + +pub use alter_table_cluster_key::AlterTableClusterKeyPlan; +pub use alter_udf::AlterUDFPlan; +pub use alter_user::AlterUserPlan; +pub use alter_view::AlterViewPlan; +pub use call::CallPlan; +pub use create_database::CreateDatabasePlan; +pub use create_role::CreateRolePlan; +pub use create_stage::CreateStagePlan; +pub use create_udf::CreateUDFPlan; +pub use create_user::CreateUserPlan; +pub use create_view::CreateViewPlan; +pub use describe_table::DescribeTablePlan; +pub use drop_database::DropDatabasePlan; +pub use drop_role::DropRolePlan; +pub use drop_stage::DropStagePlan; +pub use drop_table::DropTablePlan; +pub use drop_table_cluster_key::DropTableClusterKeyPlan; +pub use drop_udf::DropUDFPlan; +pub use drop_user::DropUserPlan; +pub use drop_view::DropViewPlan; +pub use exists_table::ExistsTablePlan; +pub use grant_privilege::GrantPrivilegePlan; +pub use grant_role::GrantRolePlan; +pub use kill::KillPlan; +pub use list::ListPlan; +pub use optimize_table::OptimizeTableAction; +pub use optimize_table::OptimizeTablePlan; +pub use remove_stage::RemoveStagePlan; +pub use rename_database::RenameDatabaseEntity; +pub use rename_database::RenameDatabasePlan; +pub use rename_table::RenameTableEntity; +pub use rename_table::RenameTablePlan; +pub use revoke_privilege::RevokePrivilegePlan; +pub use revoke_role::RevokeRolePlan; +pub use show_create_database::ShowCreateDatabasePlan; +pub use show_create_table::ShowCreateTablePlan; +pub use show_grants::ShowGrantsPlan; +pub use truncate_table::TruncateTablePlan; +pub use undrop_database::UndropDatabasePlan; +pub use undrop_table::UndropTablePlan; +pub use use_database::UseDatabasePlan; diff --git a/src/query/legacy-planners/src/plan_table_optimize.rs b/src/query/planner/src/plans/optimize_table.rs similarity index 97% rename from src/query/legacy-planners/src/plan_table_optimize.rs rename to src/query/planner/src/plans/optimize_table.rs index 4bc68d9f0dcc..06dc62968357 100644 --- a/src/query/legacy-planners/src/plan_table_optimize.rs +++ b/src/query/planner/src/plans/optimize_table.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_user_stage_remove.rs b/src/query/planner/src/plans/remove_stage.rs similarity index 94% rename from src/query/legacy-planners/src/plan_user_stage_remove.rs rename to src/query/planner/src/plans/remove_stage.rs index f632e0f04010..b290cce2bbf3 100644 --- a/src/query/legacy-planners/src/plan_user_stage_remove.rs +++ b/src/query/planner/src/plans/remove_stage.rs @@ -19,13 +19,13 @@ use common_datavalues::DataSchemaRef; use common_meta_types::UserStageInfo; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct RemoveUserStagePlan { +pub struct RemoveStagePlan { pub stage: UserStageInfo, pub path: String, pub pattern: String, } -impl RemoveUserStagePlan { +impl RemoveStagePlan { pub fn schema(&self) -> DataSchemaRef { Arc::new(DataSchema::empty()) } diff --git a/src/query/legacy-planners/src/plan_database_rename.rs b/src/query/planner/src/plans/rename_database.rs similarity index 97% rename from src/query/legacy-planners/src/plan_database_rename.rs rename to src/query/planner/src/plans/rename_database.rs index 961f5f16d7b6..be46e02fb4c9 100644 --- a/src/query/legacy-planners/src/plan_database_rename.rs +++ b/src/query/planner/src/plans/rename_database.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_table_rename.rs b/src/query/planner/src/plans/rename_table.rs similarity index 97% rename from src/query/legacy-planners/src/plan_table_rename.rs rename to src/query/planner/src/plans/rename_table.rs index ea1448156363..a4d194942f0e 100644 --- a/src/query/legacy-planners/src/plan_table_rename.rs +++ b/src/query/planner/src/plans/rename_table.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_privilege_revoke.rs b/src/query/planner/src/plans/revoke_privilege.rs similarity index 97% rename from src/query/legacy-planners/src/plan_privilege_revoke.rs rename to src/query/planner/src/plans/revoke_privilege.rs index 551824e11ef4..143296b2d908 100644 --- a/src/query/legacy-planners/src/plan_privilege_revoke.rs +++ b/src/query/planner/src/plans/revoke_privilege.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_role_revoke.rs b/src/query/planner/src/plans/revoke_role.rs similarity index 96% rename from src/query/legacy-planners/src/plan_role_revoke.rs rename to src/query/planner/src/plans/revoke_role.rs index d49c70199735..3746fa477076 100644 --- a/src/query/legacy-planners/src/plan_role_revoke.rs +++ b/src/query/planner/src/plans/revoke_role.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_database_show_create.rs b/src/query/planner/src/plans/show_create_database.rs similarity index 96% rename from src/query/legacy-planners/src/plan_database_show_create.rs rename to src/query/planner/src/plans/show_create_database.rs index 9d336698a8a0..fa9c080dc89b 100644 --- a/src/query/legacy-planners/src/plan_database_show_create.rs +++ b/src/query/planner/src/plans/show_create_database.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/query/legacy-planners/src/plan_table_show_create.rs b/src/query/planner/src/plans/show_create_table.rs similarity index 96% rename from src/query/legacy-planners/src/plan_table_show_create.rs rename to src/query/planner/src/plans/show_create_table.rs index ac27220892cf..11e9c88c5c9d 100644 --- a/src/query/legacy-planners/src/plan_table_show_create.rs +++ b/src/query/planner/src/plans/show_create_table.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use common_datavalues::DataSchemaRef; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] diff --git a/src/query/legacy-planners/src/plan_show_grants.rs b/src/query/planner/src/plans/show_grants.rs similarity index 81% rename from src/query/legacy-planners/src/plan_show_grants.rs rename to src/query/planner/src/plans/show_grants.rs index 7b498b12fad6..fd69aff4b460 100644 --- a/src/query/legacy-planners/src/plan_show_grants.rs +++ b/src/query/planner/src/plans/show_grants.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,12 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - -use common_datavalues::DataField; -use common_datavalues::DataSchemaRef; -use common_datavalues::DataSchemaRefExt; -use common_datavalues::ToDataType; -use common_datavalues::Vu8; +use common_datavalues::prelude::*; use common_meta_types::PrincipalIdentity; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)] diff --git a/src/query/legacy-planners/src/plan_table_truncate.rs b/src/query/planner/src/plans/truncate_table.rs similarity index 96% rename from src/query/legacy-planners/src/plan_table_truncate.rs rename to src/query/planner/src/plans/truncate_table.rs index 6d257402d919..7b17081eae9c 100644 --- a/src/query/legacy-planners/src/plan_table_truncate.rs +++ b/src/query/planner/src/plans/truncate_table.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_database_undrop.rs b/src/query/planner/src/plans/undrop_database.rs similarity index 97% rename from src/query/legacy-planners/src/plan_database_undrop.rs rename to src/query/planner/src/plans/undrop_database.rs index e6219c9f23c3..b3d7265eee89 100644 --- a/src/query/legacy-planners/src/plan_database_undrop.rs +++ b/src/query/planner/src/plans/undrop_database.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_table_undrop.rs b/src/query/planner/src/plans/undrop_table.rs similarity index 97% rename from src/query/legacy-planners/src/plan_table_undrop.rs rename to src/query/planner/src/plans/undrop_table.rs index 7c469339ba3d..b18a9e18e305 100644 --- a/src/query/legacy-planners/src/plan_table_undrop.rs +++ b/src/query/planner/src/plans/undrop_table.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/legacy-planners/src/plan_use_database.rs b/src/query/planner/src/plans/use_database.rs similarity index 96% rename from src/query/legacy-planners/src/plan_use_database.rs rename to src/query/planner/src/plans/use_database.rs index 74ce2b287572..0abe52f22abf 100644 --- a/src/query/legacy-planners/src/plan_use_database.rs +++ b/src/query/planner/src/plans/use_database.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Datafuse Labs. +// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - use std::sync::Arc; use common_datavalues::DataSchema; diff --git a/src/query/service/src/interpreters/interpreter_call.rs b/src/query/service/src/interpreters/interpreter_call.rs index 5c5e1580f636..bb161812fbed 100644 --- a/src/query/service/src/interpreters/interpreter_call.rs +++ b/src/query/service/src/interpreters/interpreter_call.rs @@ -17,7 +17,7 @@ use std::sync::RwLock; use common_datavalues::DataSchemaRef; use common_exception::Result; -use common_legacy_planners::CallPlan; +use common_planner::plans::CallPlan; use super::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_cluster_key_alter.rs b/src/query/service/src/interpreters/interpreter_cluster_key_alter.rs index f4f39514ea50..f459d6f3788b 100644 --- a/src/query/service/src/interpreters/interpreter_cluster_key_alter.rs +++ b/src/query/service/src/interpreters/interpreter_cluster_key_alter.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::AlterTableClusterKeyPlan; +use common_planner::plans::AlterTableClusterKeyPlan; use super::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_cluster_key_drop.rs b/src/query/service/src/interpreters/interpreter_cluster_key_drop.rs index 17a6b94d66fe..046a047de18a 100644 --- a/src/query/service/src/interpreters/interpreter_cluster_key_drop.rs +++ b/src/query/service/src/interpreters/interpreter_cluster_key_drop.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::DropTableClusterKeyPlan; +use common_planner::plans::DropTableClusterKeyPlan; use super::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_database_create.rs b/src/query/service/src/interpreters/interpreter_database_create.rs index 1a66fb611399..2a0faf2d8441 100644 --- a/src/query/service/src/interpreters/interpreter_database_create.rs +++ b/src/query/service/src/interpreters/interpreter_database_create.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::CreateDatabasePlan; +use common_planner::plans::CreateDatabasePlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_database_drop.rs b/src/query/service/src/interpreters/interpreter_database_drop.rs index 36e899a0483b..3c3218905604 100644 --- a/src/query/service/src/interpreters/interpreter_database_drop.rs +++ b/src/query/service/src/interpreters/interpreter_database_drop.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::DropDatabasePlan; +use common_planner::plans::DropDatabasePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_database_rename.rs b/src/query/service/src/interpreters/interpreter_database_rename.rs index 0029a27c111c..b59a8673414e 100644 --- a/src/query/service/src/interpreters/interpreter_database_rename.rs +++ b/src/query/service/src/interpreters/interpreter_database_rename.rs @@ -15,9 +15,9 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::RenameDatabasePlan; use common_meta_app::schema::DatabaseNameIdent; use common_meta_app::schema::RenameDatabaseReq; +use common_planner::plans::RenameDatabasePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_database_show_create.rs b/src/query/service/src/interpreters/interpreter_database_show_create.rs index 3ab47ac36387..0d67f314930c 100644 --- a/src/query/service/src/interpreters/interpreter_database_show_create.rs +++ b/src/query/service/src/interpreters/interpreter_database_show_create.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use common_datablocks::DataBlock; use common_datavalues::prelude::*; use common_exception::Result; -use common_legacy_planners::ShowCreateDatabasePlan; +use common_planner::plans::ShowCreateDatabasePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_database_undrop.rs b/src/query/service/src/interpreters/interpreter_database_undrop.rs index f142b6537ab0..af91eed16e16 100644 --- a/src/query/service/src/interpreters/interpreter_database_undrop.rs +++ b/src/query/service/src/interpreters/interpreter_database_undrop.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::UndropDatabasePlan; +use common_planner::plans::UndropDatabasePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_kill.rs b/src/query/service/src/interpreters/interpreter_kill.rs index 3b37264eb6a7..aabd6ce2e279 100644 --- a/src/query/service/src/interpreters/interpreter_kill.rs +++ b/src/query/service/src/interpreters/interpreter_kill.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::KillPlan; +use common_planner::plans::KillPlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_list.rs b/src/query/service/src/interpreters/interpreter_list.rs index 9c1da9eb6d29..e733f853e144 100644 --- a/src/query/service/src/interpreters/interpreter_list.rs +++ b/src/query/service/src/interpreters/interpreter_list.rs @@ -19,7 +19,7 @@ use common_datavalues::DataSchemaRef; use common_datavalues::Series; use common_datavalues::SeriesFrom; use common_exception::Result; -use common_legacy_planners::ListPlan; +use common_planner::plans::ListPlan; use crate::interpreters::interpreter_common::list_files; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_privilege_grant.rs b/src/query/service/src/interpreters/interpreter_privilege_grant.rs index 431e72ca0266..c93fd1863af0 100644 --- a/src/query/service/src/interpreters/interpreter_privilege_grant.rs +++ b/src/query/service/src/interpreters/interpreter_privilege_grant.rs @@ -15,10 +15,10 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::GrantPrivilegePlan; use common_meta_types::GrantObject; use common_meta_types::PrincipalIdentity; use common_meta_types::UserPrivilegeSet; +use common_planner::plans::GrantPrivilegePlan; use common_users::UserApiProvider; use crate::interpreters::interpreter_common::validate_grant_object_exists; diff --git a/src/query/service/src/interpreters/interpreter_privilege_revoke.rs b/src/query/service/src/interpreters/interpreter_privilege_revoke.rs index c832db83bcab..a47a7abd3466 100644 --- a/src/query/service/src/interpreters/interpreter_privilege_revoke.rs +++ b/src/query/service/src/interpreters/interpreter_privilege_revoke.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::RevokePrivilegePlan; use common_meta_types::PrincipalIdentity; +use common_planner::plans::RevokePrivilegePlan; use common_users::UserApiProvider; use crate::interpreters::interpreter_common::validate_grant_object_exists; diff --git a/src/query/service/src/interpreters/interpreter_role_create.rs b/src/query/service/src/interpreters/interpreter_role_create.rs index 0bbb66681595..1e28bc5ff528 100644 --- a/src/query/service/src/interpreters/interpreter_role_create.rs +++ b/src/query/service/src/interpreters/interpreter_role_create.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::CreateRolePlan; use common_meta_types::RoleInfo; +use common_planner::plans::CreateRolePlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_role_drop.rs b/src/query/service/src/interpreters/interpreter_role_drop.rs index 9d79158c60bb..21a3be6ca4d0 100644 --- a/src/query/service/src/interpreters/interpreter_role_drop.rs +++ b/src/query/service/src/interpreters/interpreter_role_drop.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::DropRolePlan; +use common_planner::plans::DropRolePlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_role_grant.rs b/src/query/service/src/interpreters/interpreter_role_grant.rs index c62420b21731..760422483a2e 100644 --- a/src/query/service/src/interpreters/interpreter_role_grant.rs +++ b/src/query/service/src/interpreters/interpreter_role_grant.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::GrantRolePlan; use common_meta_types::PrincipalIdentity; +use common_planner::plans::GrantRolePlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_role_revoke.rs b/src/query/service/src/interpreters/interpreter_role_revoke.rs index 59f860c3805e..acd9465a94b7 100644 --- a/src/query/service/src/interpreters/interpreter_role_revoke.rs +++ b/src/query/service/src/interpreters/interpreter_role_revoke.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::RevokeRolePlan; use common_meta_types::PrincipalIdentity; +use common_planner::plans::RevokeRolePlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_show_grants.rs b/src/query/service/src/interpreters/interpreter_show_grants.rs index 532714f3122d..d3db8a70783b 100644 --- a/src/query/service/src/interpreters/interpreter_show_grants.rs +++ b/src/query/service/src/interpreters/interpreter_show_grants.rs @@ -17,8 +17,8 @@ use std::sync::Arc; use common_datablocks::DataBlock; use common_datavalues::prelude::*; use common_exception::Result; -use common_legacy_planners::ShowGrantsPlan; use common_meta_types::PrincipalIdentity; +use common_planner::plans::ShowGrantsPlan; use common_users::RoleCacheManager; use common_users::UserApiProvider; diff --git a/src/query/service/src/interpreters/interpreter_table_describe.rs b/src/query/service/src/interpreters/interpreter_table_describe.rs index 50b6f72e323d..16df0072c682 100644 --- a/src/query/service/src/interpreters/interpreter_table_describe.rs +++ b/src/query/service/src/interpreters/interpreter_table_describe.rs @@ -18,7 +18,7 @@ use common_datablocks::DataBlock; use common_datavalues::prelude::*; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::DescribeTablePlan; +use common_planner::plans::DescribeTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_table_drop.rs b/src/query/service/src/interpreters/interpreter_table_drop.rs index ca3dbcda67a8..8caffbd03f0b 100644 --- a/src/query/service/src/interpreters/interpreter_table_drop.rs +++ b/src/query/service/src/interpreters/interpreter_table_drop.rs @@ -16,8 +16,7 @@ use std::sync::Arc; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::DropTablePlan; -use common_legacy_planners::TruncateTablePlan; +use common_planner::plans::DropTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; @@ -69,12 +68,7 @@ impl Interpreter for DropTableInterpreter { if self.plan.all { // errors of truncation are ignored let _ = tbl - .truncate(self.ctx.clone(), TruncateTablePlan { - catalog: self.plan.catalog.clone(), - database: self.plan.database.clone(), - table: self.plan.table.clone(), - purge: true, - }) + .truncate(self.ctx.clone(), &self.plan.catalog, true) .await; } } diff --git a/src/query/service/src/interpreters/interpreter_table_exists.rs b/src/query/service/src/interpreters/interpreter_table_exists.rs index 3bd84dc65a0c..59ad88becb5e 100644 --- a/src/query/service/src/interpreters/interpreter_table_exists.rs +++ b/src/query/service/src/interpreters/interpreter_table_exists.rs @@ -18,7 +18,7 @@ use common_datablocks::DataBlock; use common_datavalues::Series; use common_datavalues::SeriesFrom; use common_exception::Result; -use common_legacy_planners::ExistsTablePlan; +use common_planner::plans::ExistsTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_table_optimize.rs b/src/query/service/src/interpreters/interpreter_table_optimize.rs index 54fb11525163..db91e5997cd6 100644 --- a/src/query/service/src/interpreters/interpreter_table_optimize.rs +++ b/src/query/service/src/interpreters/interpreter_table_optimize.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::OptimizeTableAction; -use common_legacy_planners::OptimizeTablePlan; +use common_planner::plans::OptimizeTableAction; +use common_planner::plans::OptimizeTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::executor::ExecutorSettings; diff --git a/src/query/service/src/interpreters/interpreter_table_rename.rs b/src/query/service/src/interpreters/interpreter_table_rename.rs index 4b354451468a..af16494429d0 100644 --- a/src/query/service/src/interpreters/interpreter_table_rename.rs +++ b/src/query/service/src/interpreters/interpreter_table_rename.rs @@ -15,9 +15,9 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::RenameTablePlan; use common_meta_app::schema::RenameTableReq; use common_meta_app::schema::TableNameIdent; +use common_planner::plans::RenameTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_table_show_create.rs b/src/query/service/src/interpreters/interpreter_table_show_create.rs index 2f574fe20508..3bf4ff98d338 100644 --- a/src/query/service/src/interpreters/interpreter_table_show_create.rs +++ b/src/query/service/src/interpreters/interpreter_table_show_create.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use common_datablocks::DataBlock; use common_datavalues::prelude::*; use common_exception::Result; -use common_legacy_planners::ShowCreateTablePlan; +use common_planner::plans::ShowCreateTablePlan; use tracing::debug; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_table_truncate.rs b/src/query/service/src/interpreters/interpreter_table_truncate.rs index 374cc81b5989..0afa0137502e 100644 --- a/src/query/service/src/interpreters/interpreter_table_truncate.rs +++ b/src/query/service/src/interpreters/interpreter_table_truncate.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::TruncateTablePlan; +use common_planner::plans::TruncateTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; @@ -45,7 +45,8 @@ impl Interpreter for TruncateTableInterpreter { let tbl_name = self.plan.table.as_str(); let tbl = self.ctx.get_table(catalog_name, db_name, tbl_name).await?; - tbl.truncate(self.ctx.clone(), self.plan.clone()).await?; + tbl.truncate(self.ctx.clone(), catalog_name, self.plan.purge) + .await?; Ok(PipelineBuildResult::create()) } } diff --git a/src/query/service/src/interpreters/interpreter_table_undrop.rs b/src/query/service/src/interpreters/interpreter_table_undrop.rs index 031709aebf3e..02a9d8386901 100644 --- a/src/query/service/src/interpreters/interpreter_table_undrop.rs +++ b/src/query/service/src/interpreters/interpreter_table_undrop.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::UndropTablePlan; +use common_planner::plans::UndropTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_use_database.rs b/src/query/service/src/interpreters/interpreter_use_database.rs index 5eecdbb44485..0c65f4c016f7 100644 --- a/src/query/service/src/interpreters/interpreter_use_database.rs +++ b/src/query/service/src/interpreters/interpreter_use_database.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use common_datavalues::DataSchema; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::UseDatabasePlan; +use common_planner::plans::UseDatabasePlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_user_alter.rs b/src/query/service/src/interpreters/interpreter_user_alter.rs index 366ec0f898fa..f9f5384eb630 100644 --- a/src/query/service/src/interpreters/interpreter_user_alter.rs +++ b/src/query/service/src/interpreters/interpreter_user_alter.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::AlterUserPlan; +use common_planner::plans::AlterUserPlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_user_create.rs b/src/query/service/src/interpreters/interpreter_user_create.rs index 273d08a63df2..6990ef6c73f9 100644 --- a/src/query/service/src/interpreters/interpreter_user_create.rs +++ b/src/query/service/src/interpreters/interpreter_user_create.rs @@ -15,10 +15,10 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::CreateUserPlan; use common_meta_types::UserGrantSet; use common_meta_types::UserInfo; use common_meta_types::UserQuota; +use common_planner::plans::CreateUserPlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_user_drop.rs b/src/query/service/src/interpreters/interpreter_user_drop.rs index 31af64fdd776..a35a299db450 100644 --- a/src/query/service/src/interpreters/interpreter_user_drop.rs +++ b/src/query/service/src/interpreters/interpreter_user_drop.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::DropUserPlan; +use common_planner::plans::DropUserPlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; diff --git a/src/query/service/src/interpreters/interpreter_user_stage_create.rs b/src/query/service/src/interpreters/interpreter_user_stage_create.rs index 86e632034df7..98846ae53e89 100644 --- a/src/query/service/src/interpreters/interpreter_user_stage_create.rs +++ b/src/query/service/src/interpreters/interpreter_user_stage_create.rs @@ -16,8 +16,8 @@ use std::sync::Arc; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::CreateUserStagePlan; use common_meta_types::StageType; +use common_planner::plans::CreateStagePlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; @@ -28,11 +28,11 @@ use crate::sessions::TableContext; #[derive(Debug)] pub struct CreateUserStageInterpreter { ctx: Arc, - plan: CreateUserStagePlan, + plan: CreateStagePlan, } impl CreateUserStageInterpreter { - pub fn try_create(ctx: Arc, plan: CreateUserStagePlan) -> Result { + pub fn try_create(ctx: Arc, plan: CreateStagePlan) -> Result { Ok(CreateUserStageInterpreter { ctx, plan }) } } diff --git a/src/query/service/src/interpreters/interpreter_user_stage_drop.rs b/src/query/service/src/interpreters/interpreter_user_stage_drop.rs index 415355aac2e9..3a6bd759492c 100644 --- a/src/query/service/src/interpreters/interpreter_user_stage_drop.rs +++ b/src/query/service/src/interpreters/interpreter_user_stage_drop.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::DropUserStagePlan; use common_meta_types::StageType; +use common_planner::plans::DropStagePlan; use common_users::UserApiProvider; use tracing::info; @@ -29,11 +29,11 @@ use crate::storages::stage::StageSourceHelper; #[derive(Debug)] pub struct DropUserStageInterpreter { ctx: Arc, - plan: DropUserStagePlan, + plan: DropStagePlan, } impl DropUserStageInterpreter { - pub fn try_create(ctx: Arc, plan: DropUserStagePlan) -> Result { + pub fn try_create(ctx: Arc, plan: DropStagePlan) -> Result { Ok(DropUserStageInterpreter { ctx, plan }) } } diff --git a/src/query/service/src/interpreters/interpreter_user_stage_remove.rs b/src/query/service/src/interpreters/interpreter_user_stage_remove.rs index 1b1991a6a6f6..5dfa2f04d8ee 100644 --- a/src/query/service/src/interpreters/interpreter_user_stage_remove.rs +++ b/src/query/service/src/interpreters/interpreter_user_stage_remove.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::RemoveUserStagePlan; +use common_planner::plans::RemoveStagePlan; use crate::interpreters::interpreter_common::list_files; use crate::interpreters::Interpreter; @@ -27,11 +27,11 @@ use crate::storages::stage::StageSourceHelper; #[derive(Debug)] pub struct RemoveUserStageInterpreter { ctx: Arc, - plan: RemoveUserStagePlan, + plan: RemoveStagePlan, } impl RemoveUserStageInterpreter { - pub fn try_create(ctx: Arc, plan: RemoveUserStagePlan) -> Result { + pub fn try_create(ctx: Arc, plan: RemoveStagePlan) -> Result { Ok(RemoveUserStageInterpreter { ctx, plan }) } } diff --git a/src/query/service/src/interpreters/interpreter_user_udf_alter.rs b/src/query/service/src/interpreters/interpreter_user_udf_alter.rs index c97f01d7eb22..ba110ebfb572 100644 --- a/src/query/service/src/interpreters/interpreter_user_udf_alter.rs +++ b/src/query/service/src/interpreters/interpreter_user_udf_alter.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::AlterUserUDFPlan; +use common_planner::plans::AlterUDFPlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; @@ -26,11 +26,11 @@ use crate::sessions::TableContext; #[derive(Debug)] pub struct AlterUserUDFInterpreter { ctx: Arc, - plan: AlterUserUDFPlan, + plan: AlterUDFPlan, } impl AlterUserUDFInterpreter { - pub fn try_create(ctx: Arc, plan: AlterUserUDFPlan) -> Result { + pub fn try_create(ctx: Arc, plan: AlterUDFPlan) -> Result { Ok(AlterUserUDFInterpreter { ctx, plan }) } } diff --git a/src/query/service/src/interpreters/interpreter_user_udf_create.rs b/src/query/service/src/interpreters/interpreter_user_udf_create.rs index 4b018af3824d..e83afbe94cd9 100644 --- a/src/query/service/src/interpreters/interpreter_user_udf_create.rs +++ b/src/query/service/src/interpreters/interpreter_user_udf_create.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::CreateUserUDFPlan; +use common_planner::plans::CreateUDFPlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; @@ -26,11 +26,11 @@ use crate::sessions::TableContext; #[derive(Debug)] pub struct CreateUserUDFInterpreter { ctx: Arc, - plan: CreateUserUDFPlan, + plan: CreateUDFPlan, } impl CreateUserUDFInterpreter { - pub fn try_create(ctx: Arc, plan: CreateUserUDFPlan) -> Result { + pub fn try_create(ctx: Arc, plan: CreateUDFPlan) -> Result { Ok(CreateUserUDFInterpreter { ctx, plan }) } } diff --git a/src/query/service/src/interpreters/interpreter_user_udf_drop.rs b/src/query/service/src/interpreters/interpreter_user_udf_drop.rs index ba371bb8e387..c0e73af7bdf1 100644 --- a/src/query/service/src/interpreters/interpreter_user_udf_drop.rs +++ b/src/query/service/src/interpreters/interpreter_user_udf_drop.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use common_exception::Result; -use common_legacy_planners::DropUserUDFPlan; +use common_planner::plans::DropUDFPlan; use common_users::UserApiProvider; use crate::interpreters::Interpreter; @@ -26,11 +26,11 @@ use crate::sessions::TableContext; #[derive(Debug)] pub struct DropUserUDFInterpreter { ctx: Arc, - plan: DropUserUDFPlan, + plan: DropUDFPlan, } impl DropUserUDFInterpreter { - pub fn try_create(ctx: Arc, plan: DropUserUDFPlan) -> Result { + pub fn try_create(ctx: Arc, plan: DropUDFPlan) -> Result { Ok(DropUserUDFInterpreter { ctx, plan }) } } diff --git a/src/query/service/src/interpreters/interpreter_view_alter.rs b/src/query/service/src/interpreters/interpreter_view_alter.rs index 12a9cd064c50..af3730dcbc5b 100644 --- a/src/query/service/src/interpreters/interpreter_view_alter.rs +++ b/src/query/service/src/interpreters/interpreter_view_alter.rs @@ -17,11 +17,11 @@ use std::sync::Arc; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::AlterViewPlan; use common_meta_app::schema::CreateTableReq; use common_meta_app::schema::DropTableReq; use common_meta_app::schema::TableMeta; use common_meta_app::schema::TableNameIdent; +use common_planner::plans::AlterViewPlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_view_create.rs b/src/query/service/src/interpreters/interpreter_view_create.rs index c2b5a766b5ae..c58da219d83f 100644 --- a/src/query/service/src/interpreters/interpreter_view_create.rs +++ b/src/query/service/src/interpreters/interpreter_view_create.rs @@ -17,10 +17,10 @@ use std::sync::Arc; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::CreateViewPlan; use common_meta_app::schema::CreateTableReq; use common_meta_app::schema::TableMeta; use common_meta_app::schema::TableNameIdent; +use common_planner::plans::CreateViewPlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/interpreters/interpreter_view_drop.rs b/src/query/service/src/interpreters/interpreter_view_drop.rs index 4619e5f20f2e..11b6ed21e490 100644 --- a/src/query/service/src/interpreters/interpreter_view_drop.rs +++ b/src/query/service/src/interpreters/interpreter_view_drop.rs @@ -16,9 +16,9 @@ use std::sync::Arc; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::DropViewPlan; use common_meta_app::schema::DropTableReq; use common_meta_app::schema::TableNameIdent; +use common_planner::plans::DropViewPlan; use crate::interpreters::Interpreter; use crate::pipelines::PipelineBuildResult; diff --git a/src/query/service/src/sql/planner/binder/ddl/account.rs b/src/query/service/src/sql/planner/binder/ddl/account.rs index 7936b05ee8f3..d717a0bba5d4 100644 --- a/src/query/service/src/sql/planner/binder/ddl/account.rs +++ b/src/query/service/src/sql/planner/binder/ddl/account.rs @@ -19,16 +19,16 @@ use common_ast::ast::CreateUserStmt; use common_ast::ast::GrantStmt; use common_ast::ast::RevokeStmt; use common_exception::Result; -use common_legacy_planners::AlterUserPlan; -use common_legacy_planners::CreateUserPlan; -use common_legacy_planners::GrantPrivilegePlan; -use common_legacy_planners::GrantRolePlan; -use common_legacy_planners::RevokePrivilegePlan; -use common_legacy_planners::RevokeRolePlan; use common_meta_types::AuthInfo; use common_meta_types::GrantObject; use common_meta_types::UserOption; use common_meta_types::UserPrivilegeSet; +use common_planner::plans::AlterUserPlan; +use common_planner::plans::CreateUserPlan; +use common_planner::plans::GrantPrivilegePlan; +use common_planner::plans::GrantRolePlan; +use common_planner::plans::RevokePrivilegePlan; +use common_planner::plans::RevokeRolePlan; use common_users::UserApiProvider; use crate::sql::plans::Plan; diff --git a/src/query/service/src/sql/planner/binder/ddl/database.rs b/src/query/service/src/sql/planner/binder/ddl/database.rs index 7434736fab00..03cec15311ed 100644 --- a/src/query/service/src/sql/planner/binder/ddl/database.rs +++ b/src/query/service/src/sql/planner/binder/ddl/database.rs @@ -30,14 +30,14 @@ use common_datavalues::DataSchemaRefExt; use common_datavalues::ToDataType; use common_datavalues::Vu8; use common_exception::Result; -use common_legacy_planners::CreateDatabasePlan; -use common_legacy_planners::DropDatabasePlan; -use common_legacy_planners::RenameDatabaseEntity; -use common_legacy_planners::RenameDatabasePlan; -use common_legacy_planners::ShowCreateDatabasePlan; -use common_legacy_planners::UndropDatabasePlan; use common_meta_app::schema::DatabaseMeta; use common_meta_app::share::ShareNameIdent; +use common_planner::plans::CreateDatabasePlan; +use common_planner::plans::DropDatabasePlan; +use common_planner::plans::RenameDatabaseEntity; +use common_planner::plans::RenameDatabasePlan; +use common_planner::plans::ShowCreateDatabasePlan; +use common_planner::plans::UndropDatabasePlan; use crate::sql::binder::Binder; use crate::sql::planner::semantic::normalize_identifier; diff --git a/src/query/service/src/sql/planner/binder/ddl/stage.rs b/src/query/service/src/sql/planner/binder/ddl/stage.rs index f7ea6f42ddff..48571e5264fb 100644 --- a/src/query/service/src/sql/planner/binder/ddl/stage.rs +++ b/src/query/service/src/sql/planner/binder/ddl/stage.rs @@ -17,12 +17,12 @@ use std::str::FromStr; use common_ast::ast::CreateStageStmt; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::CreateUserStagePlan; -use common_legacy_planners::ListPlan; -use common_legacy_planners::RemoveUserStagePlan; use common_meta_types::OnErrorMode; use common_meta_types::StageType; use common_meta_types::UserStageInfo; +use common_planner::plans::CreateStagePlan; +use common_planner::plans::ListPlan; +use common_planner::plans::RemoveStagePlan; use common_storage::parse_uri_location; use common_storage::UriLocation; @@ -55,7 +55,7 @@ impl<'a> Binder { ) -> Result { let stage_name = format!("@{location}"); let (stage, path) = parse_stage_location(&self.ctx, stage_name.as_str()).await?; - let plan_node = RemoveUserStagePlan { + let plan_node = RemoveStagePlan { path, stage, pattern: pattern.to_string(), @@ -124,7 +124,7 @@ impl<'a> Binder { stage_info.copy_options.size_limit = *size_limit; } - Ok(Plan::CreateStage(Box::new(CreateUserStagePlan { + Ok(Plan::CreateStage(Box::new(CreateStagePlan { if_not_exists: *if_not_exists, tenant: self.ctx.get_tenant(), user_stage_info: stage_info, diff --git a/src/query/service/src/sql/planner/binder/ddl/table.rs b/src/query/service/src/sql/planner/binder/ddl/table.rs index 3001a5b03163..5ef923a49dc8 100644 --- a/src/query/service/src/sql/planner/binder/ddl/table.rs +++ b/src/query/service/src/sql/planner/binder/ddl/table.rs @@ -33,9 +33,20 @@ use common_datavalues::TypeFactory; use common_datavalues::Vu8; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::OptimizeTableAction; use common_legacy_planners::*; use common_meta_app::schema::TableMeta; +use common_planner::plans::AlterTableClusterKeyPlan; +use common_planner::plans::DescribeTablePlan; +use common_planner::plans::DropTableClusterKeyPlan; +use common_planner::plans::DropTablePlan; +use common_planner::plans::ExistsTablePlan; +use common_planner::plans::OptimizeTableAction; +use common_planner::plans::OptimizeTablePlan; +use common_planner::plans::RenameTableEntity; +use common_planner::plans::RenameTablePlan; +use common_planner::plans::ShowCreateTablePlan; +use common_planner::plans::TruncateTablePlan; +use common_planner::plans::UndropTablePlan; use tracing::debug; use crate::sql::binder::scalar::ScalarBinder; diff --git a/src/query/service/src/sql/planner/binder/ddl/view.rs b/src/query/service/src/sql/planner/binder/ddl/view.rs index de65c0a692c5..85347041593a 100644 --- a/src/query/service/src/sql/planner/binder/ddl/view.rs +++ b/src/query/service/src/sql/planner/binder/ddl/view.rs @@ -16,9 +16,9 @@ use common_ast::ast::AlterViewStmt; use common_ast::ast::CreateViewStmt; use common_ast::ast::DropViewStmt; use common_exception::Result; -use common_legacy_planners::AlterViewPlan; -use common_legacy_planners::CreateViewPlan; -use common_legacy_planners::DropViewPlan; +use common_planner::plans::AlterViewPlan; +use common_planner::plans::CreateViewPlan; +use common_planner::plans::DropViewPlan; use crate::sql::binder::Binder; use crate::sql::planner::semantic::normalize_identifier; diff --git a/src/query/service/src/sql/planner/binder/kill.rs b/src/query/service/src/sql/planner/binder/kill.rs index 7b9c04938791..3ee6013d211d 100644 --- a/src/query/service/src/sql/planner/binder/kill.rs +++ b/src/query/service/src/sql/planner/binder/kill.rs @@ -14,7 +14,7 @@ use common_ast::ast::KillTarget; use common_exception::Result; -use common_legacy_planners::KillPlan; +use common_planner::plans::KillPlan; use crate::sql::planner::binder::BindContext; use crate::sql::planner::binder::Binder; diff --git a/src/query/service/src/sql/planner/binder/mod.rs b/src/query/service/src/sql/planner/binder/mod.rs index 7e090aacada1..a9d056024c83 100644 --- a/src/query/service/src/sql/planner/binder/mod.rs +++ b/src/query/service/src/sql/planner/binder/mod.rs @@ -25,17 +25,17 @@ use common_ast::Dialect; use common_ast::UDFValidator; use common_datavalues::DataTypeImpl; use common_exception::Result; -use common_legacy_planners::AlterUserUDFPlan; -use common_legacy_planners::CallPlan; -use common_legacy_planners::CreateRolePlan; -use common_legacy_planners::CreateUserUDFPlan; -use common_legacy_planners::DropRolePlan; -use common_legacy_planners::DropUserPlan; -use common_legacy_planners::DropUserStagePlan; -use common_legacy_planners::DropUserUDFPlan; -use common_legacy_planners::ShowGrantsPlan; -use common_legacy_planners::UseDatabasePlan; use common_meta_types::UserDefinedFunction; +use common_planner::plans::AlterUDFPlan; +use common_planner::plans::CallPlan; +use common_planner::plans::CreateRolePlan; +use common_planner::plans::CreateUDFPlan; +use common_planner::plans::DropRolePlan; +use common_planner::plans::DropStagePlan; +use common_planner::plans::DropUDFPlan; +use common_planner::plans::DropUserPlan; +use common_planner::plans::ShowGrantsPlan; +use common_planner::plans::UseDatabasePlan; use common_planner::MetadataRef; pub use scalar::ScalarBinder; pub use scalar_common::*; @@ -220,7 +220,7 @@ impl<'a> Binder { Statement::DropStage { stage_name, if_exists, - } => Plan::DropStage(Box::new(DropUserStagePlan { + } => Plan::DropStage(Box::new(DropStagePlan { if_exists: *if_exists, name: stage_name.clone(), })), @@ -264,7 +264,7 @@ impl<'a> Binder { description: description.clone().unwrap_or_default(), }; - Plan::CreateUDF(Box::new(CreateUserUDFPlan { + Plan::CreateUDF(Box::new(CreateUDFPlan { if_not_exists: *if_not_exists, udf })) @@ -288,14 +288,14 @@ impl<'a> Binder { description: description.clone().unwrap_or_default(), }; - Plan::AlterUDF(Box::new(AlterUserUDFPlan { + Plan::AlterUDF(Box::new(AlterUDFPlan { udf, })) } Statement::DropUDF { if_exists, udf_name, - } => Plan::DropUDF(Box::new(DropUserUDFPlan { + } => Plan::DropUDF(Box::new(DropUDFPlan { if_exists: *if_exists, name: udf_name.to_string(), })), diff --git a/src/query/service/src/sql/planner/plans/mod.rs b/src/query/service/src/sql/planner/plans/mod.rs index 08bc4f76b99f..f349002b7e83 100644 --- a/src/query/service/src/sql/planner/plans/mod.rs +++ b/src/query/service/src/sql/planner/plans/mod.rs @@ -44,47 +44,47 @@ use common_datavalues::DataSchema; use common_datavalues::DataSchemaRef; use common_datavalues::DataSchemaRefExt; use common_datavalues::StringType; -use common_legacy_planners::AlterTableClusterKeyPlan; -use common_legacy_planners::AlterUserPlan; -use common_legacy_planners::AlterUserUDFPlan; -use common_legacy_planners::AlterViewPlan; -use common_legacy_planners::CallPlan; -use common_legacy_planners::CreateDatabasePlan; -use common_legacy_planners::CreateRolePlan; -use common_legacy_planners::CreateUserPlan; -use common_legacy_planners::CreateUserStagePlan; -use common_legacy_planners::CreateUserUDFPlan; -use common_legacy_planners::CreateViewPlan; use common_legacy_planners::DeletePlan; -use common_legacy_planners::DescribeTablePlan; -use common_legacy_planners::DropDatabasePlan; -use common_legacy_planners::DropRolePlan; -use common_legacy_planners::DropTableClusterKeyPlan; -use common_legacy_planners::DropTablePlan; -use common_legacy_planners::DropUserPlan; -use common_legacy_planners::DropUserStagePlan; -use common_legacy_planners::DropUserUDFPlan; -use common_legacy_planners::DropViewPlan; -use common_legacy_planners::ExistsTablePlan; -use common_legacy_planners::GrantPrivilegePlan; -use common_legacy_planners::GrantRolePlan; -use common_legacy_planners::KillPlan; -use common_legacy_planners::ListPlan; -use common_legacy_planners::OptimizeTablePlan; use common_legacy_planners::ReclusterTablePlan; -use common_legacy_planners::RemoveUserStagePlan; -use common_legacy_planners::RenameDatabasePlan; -use common_legacy_planners::RenameTablePlan; -use common_legacy_planners::RevokePrivilegePlan; -use common_legacy_planners::RevokeRolePlan; use common_legacy_planners::SettingPlan; -use common_legacy_planners::ShowCreateDatabasePlan; -use common_legacy_planners::ShowCreateTablePlan; -use common_legacy_planners::ShowGrantsPlan; -use common_legacy_planners::TruncateTablePlan; -use common_legacy_planners::UndropDatabasePlan; -use common_legacy_planners::UndropTablePlan; -use common_legacy_planners::UseDatabasePlan; +use common_planner::plans::AlterTableClusterKeyPlan; +use common_planner::plans::AlterUDFPlan; +use common_planner::plans::AlterUserPlan; +use common_planner::plans::AlterViewPlan; +use common_planner::plans::CallPlan; +use common_planner::plans::CreateDatabasePlan; +use common_planner::plans::CreateRolePlan; +use common_planner::plans::CreateStagePlan; +use common_planner::plans::CreateUDFPlan; +use common_planner::plans::CreateUserPlan; +use common_planner::plans::CreateViewPlan; +use common_planner::plans::DescribeTablePlan; +use common_planner::plans::DropDatabasePlan; +use common_planner::plans::DropRolePlan; +use common_planner::plans::DropStagePlan; +use common_planner::plans::DropTableClusterKeyPlan; +use common_planner::plans::DropTablePlan; +use common_planner::plans::DropUDFPlan; +use common_planner::plans::DropUserPlan; +use common_planner::plans::DropViewPlan; +use common_planner::plans::ExistsTablePlan; +use common_planner::plans::GrantPrivilegePlan; +use common_planner::plans::GrantRolePlan; +use common_planner::plans::KillPlan; +use common_planner::plans::ListPlan; +use common_planner::plans::OptimizeTablePlan; +use common_planner::plans::RemoveStagePlan; +use common_planner::plans::RenameDatabasePlan; +use common_planner::plans::RenameTablePlan; +use common_planner::plans::RevokePrivilegePlan; +use common_planner::plans::RevokeRolePlan; +use common_planner::plans::ShowCreateDatabasePlan; +use common_planner::plans::ShowCreateTablePlan; +use common_planner::plans::ShowGrantsPlan; +use common_planner::plans::TruncateTablePlan; +use common_planner::plans::UndropDatabasePlan; +use common_planner::plans::UndropTablePlan; +use common_planner::plans::UseDatabasePlan; use common_planner::MetadataRef; pub use copy_v2::CopyPlanV2; pub use copy_v2::ValidationMode; @@ -182,9 +182,9 @@ pub enum Plan { DropUser(Box), // UDF - CreateUDF(Box), - AlterUDF(Box), - DropUDF(Box), + CreateUDF(Box), + AlterUDF(Box), + DropUDF(Box), // Role CreateRole(Box), @@ -197,9 +197,9 @@ pub enum Plan { // Stages ListStage(Box), - CreateStage(Box), - DropStage(Box), - RemoveStage(Box), + CreateStage(Box), + DropStage(Box), + RemoveStage(Box), // Presign Presign(Box), diff --git a/src/query/service/src/storages/stage/stage_table.rs b/src/query/service/src/storages/stage/stage_table.rs index 764ba20c7409..9ab72b8d067a 100644 --- a/src/query/service/src/storages/stage/stage_table.rs +++ b/src/query/service/src/storages/stage/stage_table.rs @@ -26,7 +26,6 @@ use common_legacy_planners::Partitions; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::StageTableInfo; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableInfo; use common_pipeline_core::processors::port::InputPort; use common_pipeline_core::SinkPipeBuilder; @@ -201,11 +200,7 @@ impl Table for StageTable { } // Truncate the stage file. - async fn truncate( - &self, - _ctx: Arc, - _truncate_plan: TruncateTablePlan, - ) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: &str, _: bool) -> Result<()> { Err(ErrorCode::UnImplement( "S3 external table truncate() unimplemented yet!", )) diff --git a/src/query/service/tests/it/storages/fuse/operations/navigate.rs b/src/query/service/tests/it/storages/fuse/operations/navigate.rs index b1a800ae54c4..61152b22d4e8 100644 --- a/src/query/service/tests/it/storages/fuse/operations/navigate.rs +++ b/src/query/service/tests/it/storages/fuse/operations/navigate.rs @@ -20,7 +20,6 @@ use common_base::base::tokio; use common_datablocks::DataBlock; use common_exception::ErrorCode; use common_exception::Result; -use common_legacy_planners::TruncateTablePlan; use common_storages_fuse::io::SnapshotHistoryReader; use databend_query::pipelines::Pipeline; use databend_query::storages::fuse::io::MetaReaders; @@ -168,15 +167,7 @@ async fn test_fuse_historical_table_is_read_only() -> Result<()> { assert_not_writable(res, "append2"); // check truncate - let res = tbl - .truncate(ctx.clone(), TruncateTablePlan { - // values do not matter - catalog: "".to_string(), - database: db, - table: "".to_string(), - purge: false, - }) - .await; + let res = tbl.truncate(ctx.clone(), "", false).await; assert_not_writable(res, "truncate"); Ok(()) diff --git a/src/query/service/tests/it/storages/fuse/table.rs b/src/query/service/tests/it/storages/fuse/table.rs index a14505affd7b..a60fa519f683 100644 --- a/src/query/service/tests/it/storages/fuse/table.rs +++ b/src/query/service/tests/it/storages/fuse/table.rs @@ -16,13 +16,12 @@ use std::default::Default; use common_base::base::tokio; use common_exception::Result; -use common_legacy_planners::AlterTableClusterKeyPlan; -use common_legacy_planners::DropTableClusterKeyPlan; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::SourceInfo; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableInfo; use common_meta_app::schema::TableMeta; +use common_planner::plans::AlterTableClusterKeyPlan; +use common_planner::plans::DropTableClusterKeyPlan; use databend_query::interpreters::AlterTableClusterKeyInterpreter; use databend_query::interpreters::CreateTableInterpreterV2; use databend_query::interpreters::DropTableClusterKeyInterpreter; @@ -178,16 +177,12 @@ async fn test_fuse_table_truncate() -> Result<()> { interpreter.execute(ctx.clone()).await?; let table = fixture.latest_default_table().await?; - let truncate_plan = TruncateTablePlan { - catalog: fixture.default_catalog_name(), - database: fixture.default_db_name(), - table: fixture.default_table_name(), - purge: false, - }; // 1. truncate empty table let prev_version = table.get_table_info().ident.seq; - let r = table.truncate(ctx.clone(), truncate_plan.clone()).await; + let r = table + .truncate(ctx.clone(), &fixture.default_catalog_name(), false) + .await; let table = fixture.latest_default_table().await?; // no side effects assert_eq!(prev_version, table.get_table_info().ident.seq); @@ -219,7 +214,9 @@ async fn test_fuse_table_truncate() -> Result<()> { assert_eq!(stats.read_rows, (num_blocks * rows_per_block) as usize); // truncate - let r = table.truncate(ctx.clone(), truncate_plan).await; + let r = table + .truncate(ctx.clone(), &fixture.default_catalog_name(), false) + .await; assert!(r.is_ok()); // get the latest tbl diff --git a/src/query/service/tests/it/storages/fuse/table_test_fixture.rs b/src/query/service/tests/it/storages/fuse/table_test_fixture.rs index 29f72aea83c7..01526eedb041 100644 --- a/src/query/service/tests/it/storages/fuse/table_test_fixture.rs +++ b/src/query/service/tests/it/storages/fuse/table_test_fixture.rs @@ -20,13 +20,13 @@ use common_datablocks::assert_blocks_sorted_eq_with_name; use common_datablocks::DataBlock; use common_datavalues::prelude::*; use common_exception::Result; -use common_legacy_planners::CreateDatabasePlan; use common_legacy_planners::Expression; use common_legacy_planners::Extras; use common_meta_app::schema::DatabaseMeta; use common_meta_app::schema::TableMeta; use common_pipeline_core::processors::port::OutputPort; use common_pipeline_core::SourcePipeBuilder; +use common_planner::plans::CreateDatabasePlan; use common_storage::StorageFsConfig; use common_storage::StorageParams; use common_streams::SendableDataBlockStream; diff --git a/src/query/service/tests/it/storages/memory.rs b/src/query/service/tests/it/storages/memory.rs index ea08982488f7..c329b444c04b 100644 --- a/src/query/service/tests/it/storages/memory.rs +++ b/src/query/service/tests/it/storages/memory.rs @@ -194,13 +194,7 @@ async fn test_memorytable() -> Result<()> { // truncate. { - let truncate_plan = TruncateTablePlan { - catalog: "default".to_string(), - database: "default".to_string(), - table: "a".to_string(), - purge: false, - }; - table.truncate(ctx.clone(), truncate_plan).await?; + table.truncate(ctx.clone(), "default", false).await?; let source_plan = table.read_plan(ctx.clone(), None).await?; let stream = table.read(ctx, &source_plan).await?; diff --git a/src/query/service/tests/it/storages/null.rs b/src/query/service/tests/it/storages/null.rs index 7554f514e6ee..8bd9c7213633 100644 --- a/src/query/service/tests/it/storages/null.rs +++ b/src/query/service/tests/it/storages/null.rs @@ -15,7 +15,6 @@ use common_base::base::tokio; use common_datavalues::prelude::*; use common_exception::Result; -use common_legacy_planners::*; use common_meta_app::schema::TableInfo; use common_meta_app::schema::TableMeta; use databend_query::sql::plans::create_table_v2::TableOptions; @@ -54,13 +53,7 @@ async fn test_null_table() -> Result<()> { // truncate. { - let truncate_plan = TruncateTablePlan { - catalog: "default".to_string(), - database: "default".to_string(), - table: "a".to_string(), - purge: false, - }; - table.truncate(ctx, truncate_plan).await?; + table.truncate(ctx, "default", false).await?; } Ok(()) diff --git a/src/query/storages/fuse/src/fuse_table.rs b/src/query/storages/fuse/src/fuse_table.rs index c645b1e6edde..96348021b736 100644 --- a/src/query/storages/fuse/src/fuse_table.rs +++ b/src/query/storages/fuse/src/fuse_table.rs @@ -33,7 +33,6 @@ use common_legacy_planners::Extras; use common_legacy_planners::Partitions; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableInfo; use common_storages_util::storage_context::StorageContext; use common_storages_util::table_storage_prefix::table_storage_prefix; @@ -357,11 +356,11 @@ impl Table for FuseTable { async fn truncate( &self, ctx: Arc, - truncate_plan: TruncateTablePlan, + catalog_name: &str, + purge: bool, ) -> Result<()> { self.check_mutable()?; - self.do_truncate(ctx, truncate_plan.purge, truncate_plan.catalog.as_str()) - .await + self.do_truncate(ctx, purge, catalog_name).await } #[tracing::instrument(level = "debug", name = "fuse_table_optimize", skip(self, ctx), fields(ctx.id = ctx.get_id().as_str()))] diff --git a/src/query/storages/hive/src/hive_table.rs b/src/query/storages/hive/src/hive_table.rs index 042be86c69ce..c6ae2b7a56a6 100644 --- a/src/query/storages/hive/src/hive_table.rs +++ b/src/query/storages/hive/src/hive_table.rs @@ -35,7 +35,6 @@ use common_legacy_planners::Projection; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::RequireColumnsVisitor; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableInfo; use common_pipeline_core::processors::port::OutputPort; use common_pipeline_core::processors::processor::ProcessorPtr; @@ -407,11 +406,7 @@ impl Table for HiveTable { ))) } - async fn truncate( - &self, - _ctx: Arc, - _truncate_plan: TruncateTablePlan, - ) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: &str, _: bool) -> Result<()> { Err(ErrorCode::UnImplement(format!( "truncate for table {} is not implemented", self.name() diff --git a/src/query/storages/preludes/src/memory/memory_table.rs b/src/query/storages/preludes/src/memory/memory_table.rs index f17861d91843..35f33c1ba927 100644 --- a/src/query/storages/preludes/src/memory/memory_table.rs +++ b/src/query/storages/preludes/src/memory/memory_table.rs @@ -30,7 +30,6 @@ use common_legacy_planners::Partitions; use common_legacy_planners::Projection; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableInfo; use parking_lot::Mutex; use parking_lot::RwLock; @@ -252,11 +251,7 @@ impl Table for MemoryTable { Ok(()) } - async fn truncate( - &self, - _ctx: Arc, - _truncate_plan: TruncateTablePlan, - ) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: &str, _: bool) -> Result<()> { let mut blocks = self.blocks.write(); blocks.clear(); Ok(()) diff --git a/src/query/storages/preludes/src/null/null_table.rs b/src/query/storages/preludes/src/null/null_table.rs index c2f3ce7478ae..e27373f22f34 100644 --- a/src/query/storages/preludes/src/null/null_table.rs +++ b/src/query/storages/preludes/src/null/null_table.rs @@ -22,7 +22,6 @@ use common_legacy_planners::Extras; use common_legacy_planners::Partitions; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableInfo; use crate::pipelines::processors::port::InputPort; @@ -102,11 +101,7 @@ impl Table for NullTable { Ok(()) } - async fn truncate( - &self, - _ctx: Arc, - _truncate_plan: TruncateTablePlan, - ) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: &str, _: bool) -> Result<()> { Ok(()) } } diff --git a/src/query/storages/preludes/src/system/clustering_history_table.rs b/src/query/storages/preludes/src/system/clustering_history_table.rs index 374e73618f6e..e0b624c5e17a 100644 --- a/src/query/storages/preludes/src/system/clustering_history_table.rs +++ b/src/query/storages/preludes/src/system/clustering_history_table.rs @@ -23,7 +23,6 @@ use common_legacy_planners::Extras; use common_legacy_planners::Partitions; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableIdent; use common_meta_app::schema::TableInfo; use common_meta_app::schema::TableMeta; @@ -133,11 +132,7 @@ impl Table for ClusteringHistoryTable { Ok(()) } - async fn truncate( - &self, - _ctx: Arc, - _truncate_plan: TruncateTablePlan, - ) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: &str, _: bool) -> Result<()> { let mut data = self.data.write(); *data = VecDeque::new(); Ok(()) diff --git a/src/query/storages/preludes/src/system/query_log_table.rs b/src/query/storages/preludes/src/system/query_log_table.rs index 25772b105822..12a343c8e204 100644 --- a/src/query/storages/preludes/src/system/query_log_table.rs +++ b/src/query/storages/preludes/src/system/query_log_table.rs @@ -23,7 +23,6 @@ use common_legacy_planners::Extras; use common_legacy_planners::Partitions; use common_legacy_planners::ReadDataSourcePlan; use common_legacy_planners::Statistics; -use common_legacy_planners::TruncateTablePlan; use common_meta_app::schema::TableIdent; use common_meta_app::schema::TableInfo; use common_meta_app::schema::TableMeta; @@ -177,11 +176,7 @@ impl Table for QueryLogTable { Ok(()) } - async fn truncate( - &self, - _ctx: Arc, - _truncate_plan: TruncateTablePlan, - ) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: &str, _: bool) -> Result<()> { let mut data = self.data.write(); *data = VecDeque::new(); Ok(())