Skip to content

Commit 3a89abe

Browse files
committed
Move all stage related plans
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent bcd92f3 commit 3a89abe

File tree

12 files changed

+35
-70
lines changed

12 files changed

+35
-70
lines changed

src/query/legacy-planners/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ mod plan_sink;
5555
mod plan_sort;
5656
mod plan_subqueries_set;
5757
mod plan_table_recluster;
58-
mod plan_user_stage_create;
59-
mod plan_user_stage_describe;
60-
mod plan_user_stage_drop;
61-
mod plan_user_stage_remove;
6258
mod plan_user_udf_alter;
6359
mod plan_user_udf_create;
6460
mod plan_user_udf_drop;
@@ -149,10 +145,6 @@ pub use plan_sink::SINK_SCHEMA;
149145
pub use plan_sort::SortPlan;
150146
pub use plan_subqueries_set::SubQueriesSetPlan;
151147
pub use plan_table_recluster::ReclusterTablePlan;
152-
pub use plan_user_stage_create::CreateUserStagePlan;
153-
pub use plan_user_stage_describe::DescribeUserStagePlan;
154-
pub use plan_user_stage_drop::DropUserStagePlan;
155-
pub use plan_user_stage_remove::RemoveUserStagePlan;
156148
pub use plan_user_udf_alter::AlterUserUDFPlan;
157149
pub use plan_user_udf_create::CreateUserUDFPlan;
158150
pub use plan_user_udf_drop::DropUserUDFPlan;

src/query/legacy-planners/src/plan_user_stage_describe.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/query/legacy-planners/src/plan_user_stage_create.rs renamed to src/query/planner/src/plans/create_stage.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Datafuse Labs.
1+
// Copyright 2022 Datafuse Labs.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -11,21 +11,20 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
1514
use std::sync::Arc;
1615

1716
use common_datavalues::DataSchema;
1817
use common_datavalues::DataSchemaRef;
1918
use common_meta_types::UserStageInfo;
2019

2120
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
22-
pub struct CreateUserStagePlan {
21+
pub struct CreateStagePlan {
2322
pub if_not_exists: bool,
2423
pub tenant: String,
2524
pub user_stage_info: UserStageInfo,
2625
}
2726

28-
impl CreateUserStagePlan {
27+
impl CreateStagePlan {
2928
pub fn schema(&self) -> DataSchemaRef {
3029
Arc::new(DataSchema::empty())
3130
}

src/query/legacy-planners/src/plan_user_stage_drop.rs renamed to src/query/planner/src/plans/drop_stage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Datafuse Labs.
1+
// Copyright 2022 Datafuse Labs.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,12 +18,12 @@ use common_datavalues::DataSchema;
1818
use common_datavalues::DataSchemaRef;
1919

2020
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
21-
pub struct DropUserStagePlan {
21+
pub struct DropStagePlan {
2222
pub if_exists: bool,
2323
pub name: String,
2424
}
2525

26-
impl DropUserStagePlan {
26+
impl DropStagePlan {
2727
pub fn schema(&self) -> DataSchemaRef {
2828
Arc::new(DataSchema::empty())
2929
}

src/query/planner/src/plans/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ mod alter_user;
1717
mod call;
1818
mod create_database;
1919
mod create_role;
20+
mod create_stage;
2021
mod create_user;
2122
mod describe_table;
2223
mod drop_database;
2324
mod drop_role;
25+
mod drop_stage;
2426
mod drop_table;
2527
mod drop_table_cluster_key;
2628
mod drop_user;
@@ -30,6 +32,7 @@ mod grant_role;
3032
mod kill;
3133
mod list;
3234
mod optimize_table;
35+
mod remove_stage;
3336
mod rename_database;
3437
mod rename_table;
3538
mod revoke_privilege;
@@ -47,10 +50,12 @@ pub use alter_user::AlterUserPlan;
4750
pub use call::CallPlan;
4851
pub use create_database::CreateDatabasePlan;
4952
pub use create_role::CreateRolePlan;
53+
pub use create_stage::CreateStagePlan;
5054
pub use create_user::CreateUserPlan;
5155
pub use describe_table::DescribeTablePlan;
5256
pub use drop_database::DropDatabasePlan;
5357
pub use drop_role::DropRolePlan;
58+
pub use drop_stage::DropStagePlan;
5459
pub use drop_table::DropTablePlan;
5560
pub use drop_table_cluster_key::DropTableClusterKeyPlan;
5661
pub use drop_user::DropUserPlan;
@@ -61,6 +66,7 @@ pub use kill::KillPlan;
6166
pub use list::ListPlan;
6267
pub use optimize_table::OptimizeTableAction;
6368
pub use optimize_table::OptimizeTablePlan;
69+
pub use remove_stage::RemoveStagePlan;
6470
pub use rename_database::RenameDatabaseEntity;
6571
pub use rename_database::RenameDatabasePlan;
6672
pub use rename_table::RenameTableEntity;

src/query/legacy-planners/src/plan_user_stage_remove.rs renamed to src/query/planner/src/plans/remove_stage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ use common_datavalues::DataSchemaRef;
1919
use common_meta_types::UserStageInfo;
2020

2121
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
22-
pub struct RemoveUserStagePlan {
22+
pub struct RemoveStagePlan {
2323
pub stage: UserStageInfo,
2424
pub path: String,
2525
pub pattern: String,
2626
}
2727

28-
impl RemoveUserStagePlan {
28+
impl RemoveStagePlan {
2929
pub fn schema(&self) -> DataSchemaRef {
3030
Arc::new(DataSchema::empty())
3131
}

src/query/service/src/interpreters/interpreter_user_stage_create.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use std::sync::Arc;
1616

1717
use common_exception::ErrorCode;
1818
use common_exception::Result;
19-
use common_legacy_planners::CreateUserStagePlan;
2019
use common_meta_types::StageType;
20+
use common_planner::plans::CreateStagePlan;
2121
use common_users::UserApiProvider;
2222

2323
use crate::interpreters::Interpreter;
@@ -28,11 +28,11 @@ use crate::sessions::TableContext;
2828
#[derive(Debug)]
2929
pub struct CreateUserStageInterpreter {
3030
ctx: Arc<QueryContext>,
31-
plan: CreateUserStagePlan,
31+
plan: CreateStagePlan,
3232
}
3333

3434
impl CreateUserStageInterpreter {
35-
pub fn try_create(ctx: Arc<QueryContext>, plan: CreateUserStagePlan) -> Result<Self> {
35+
pub fn try_create(ctx: Arc<QueryContext>, plan: CreateStagePlan) -> Result<Self> {
3636
Ok(CreateUserStageInterpreter { ctx, plan })
3737
}
3838
}

src/query/service/src/interpreters/interpreter_user_stage_drop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use std::sync::Arc;
1616

1717
use common_exception::Result;
18-
use common_legacy_planners::DropUserStagePlan;
1918
use common_meta_types::StageType;
19+
use common_planner::plans::DropStagePlan;
2020
use common_users::UserApiProvider;
2121
use tracing::info;
2222

@@ -29,11 +29,11 @@ use crate::storages::stage::StageSourceHelper;
2929
#[derive(Debug)]
3030
pub struct DropUserStageInterpreter {
3131
ctx: Arc<QueryContext>,
32-
plan: DropUserStagePlan,
32+
plan: DropStagePlan,
3333
}
3434

3535
impl DropUserStageInterpreter {
36-
pub fn try_create(ctx: Arc<QueryContext>, plan: DropUserStagePlan) -> Result<Self> {
36+
pub fn try_create(ctx: Arc<QueryContext>, plan: DropStagePlan) -> Result<Self> {
3737
Ok(DropUserStageInterpreter { ctx, plan })
3838
}
3939
}

src/query/service/src/interpreters/interpreter_user_stage_remove.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use std::sync::Arc;
1616

1717
use common_exception::Result;
18-
use common_legacy_planners::RemoveUserStagePlan;
18+
use common_planner::plans::RemoveStagePlan;
1919

2020
use crate::interpreters::interpreter_common::list_files;
2121
use crate::interpreters::Interpreter;
@@ -27,11 +27,11 @@ use crate::storages::stage::StageSourceHelper;
2727
#[derive(Debug)]
2828
pub struct RemoveUserStageInterpreter {
2929
ctx: Arc<QueryContext>,
30-
plan: RemoveUserStagePlan,
30+
plan: RemoveStagePlan,
3131
}
3232

3333
impl RemoveUserStageInterpreter {
34-
pub fn try_create(ctx: Arc<QueryContext>, plan: RemoveUserStagePlan) -> Result<Self> {
34+
pub fn try_create(ctx: Arc<QueryContext>, plan: RemoveStagePlan) -> Result<Self> {
3535
Ok(RemoveUserStageInterpreter { ctx, plan })
3636
}
3737
}

src/query/service/src/sql/planner/binder/ddl/stage.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ use std::str::FromStr;
1717
use common_ast::ast::CreateStageStmt;
1818
use common_exception::ErrorCode;
1919
use common_exception::Result;
20-
use common_legacy_planners::CreateUserStagePlan;
21-
use common_legacy_planners::RemoveUserStagePlan;
2220
use common_meta_types::OnErrorMode;
2321
use common_meta_types::StageType;
2422
use common_meta_types::UserStageInfo;
23+
use common_planner::plans::CreateStagePlan;
2524
use common_planner::plans::ListPlan;
25+
use common_planner::plans::RemoveStagePlan;
2626
use common_storage::parse_uri_location;
2727
use common_storage::UriLocation;
2828

@@ -55,7 +55,7 @@ impl<'a> Binder {
5555
) -> Result<Plan> {
5656
let stage_name = format!("@{location}");
5757
let (stage, path) = parse_stage_location(&self.ctx, stage_name.as_str()).await?;
58-
let plan_node = RemoveUserStagePlan {
58+
let plan_node = RemoveStagePlan {
5959
path,
6060
stage,
6161
pattern: pattern.to_string(),
@@ -124,7 +124,7 @@ impl<'a> Binder {
124124
stage_info.copy_options.size_limit = *size_limit;
125125
}
126126

127-
Ok(Plan::CreateStage(Box::new(CreateUserStagePlan {
127+
Ok(Plan::CreateStage(Box::new(CreateStagePlan {
128128
if_not_exists: *if_not_exists,
129129
tenant: self.ctx.get_tenant(),
130130
user_stage_info: stage_info,

0 commit comments

Comments
 (0)