Skip to content

Commit e0796f2

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

File tree

10 files changed

+36
-38
lines changed

10 files changed

+36
-38
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ mod plan_sink;
5555
mod plan_sort;
5656
mod plan_subqueries_set;
5757
mod plan_table_recluster;
58-
mod plan_user_udf_alter;
59-
mod plan_user_udf_create;
60-
mod plan_user_udf_drop;
6158
mod plan_view_alter;
6259
mod plan_view_create;
6360
mod plan_view_drop;
@@ -145,9 +142,6 @@ pub use plan_sink::SINK_SCHEMA;
145142
pub use plan_sort::SortPlan;
146143
pub use plan_subqueries_set::SubQueriesSetPlan;
147144
pub use plan_table_recluster::ReclusterTablePlan;
148-
pub use plan_user_udf_alter::AlterUserUDFPlan;
149-
pub use plan_user_udf_create::CreateUserUDFPlan;
150-
pub use plan_user_udf_drop::DropUserUDFPlan;
151145
pub use plan_view_alter::AlterViewPlan;
152146
pub use plan_view_create::CreateViewPlan;
153147
pub use plan_view_drop::DropViewPlan;

src/query/legacy-planners/src/plan_user_udf_alter.rs renamed to src/query/planner/src/plans/alter_udf.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,19 +11,18 @@
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::UserDefinedFunction;
2019

2120
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
22-
pub struct AlterUserUDFPlan {
21+
pub struct AlterUDFPlan {
2322
pub udf: UserDefinedFunction,
2423
}
2524

26-
impl AlterUserUDFPlan {
25+
impl AlterUDFPlan {
2726
pub fn schema(&self) -> DataSchemaRef {
2827
Arc::new(DataSchema::empty())
2928
}

src/query/legacy-planners/src/plan_user_udf_create.rs renamed to src/query/planner/src/plans/create_udf.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.
@@ -19,12 +19,12 @@ use common_datavalues::DataSchemaRef;
1919
use common_meta_types::UserDefinedFunction;
2020

2121
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
22-
pub struct CreateUserUDFPlan {
22+
pub struct CreateUDFPlan {
2323
pub if_not_exists: bool,
2424
pub udf: UserDefinedFunction,
2525
}
2626

27-
impl CreateUserUDFPlan {
27+
impl CreateUDFPlan {
2828
pub fn schema(&self) -> DataSchemaRef {
2929
Arc::new(DataSchema::empty())
3030
}

src/query/legacy-planners/src/plan_user_udf_drop.rs renamed to src/query/planner/src/plans/drop_udf.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,19 +11,18 @@
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

2019
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
21-
pub struct DropUserUDFPlan {
20+
pub struct DropUDFPlan {
2221
pub if_exists: bool,
2322
pub name: String,
2423
}
2524

26-
impl DropUserUDFPlan {
25+
impl DropUDFPlan {
2726
pub fn schema(&self) -> DataSchemaRef {
2827
Arc::new(DataSchema::empty())
2928
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
// limitations under the License.
1414

1515
mod alter_table_cluster_key;
16+
mod alter_udf;
1617
mod alter_user;
1718
mod call;
1819
mod create_database;
1920
mod create_role;
2021
mod create_stage;
22+
mod create_udf;
2123
mod create_user;
2224
mod describe_table;
2325
mod drop_database;
2426
mod drop_role;
2527
mod drop_stage;
2628
mod drop_table;
2729
mod drop_table_cluster_key;
30+
mod drop_udf;
2831
mod drop_user;
2932
mod exists_table;
3033
mod grant_privilege;
@@ -46,18 +49,21 @@ mod undrop_table;
4649
mod use_database;
4750

4851
pub use alter_table_cluster_key::AlterTableClusterKeyPlan;
52+
pub use alter_udf::AlterUDFPlan;
4953
pub use alter_user::AlterUserPlan;
5054
pub use call::CallPlan;
5155
pub use create_database::CreateDatabasePlan;
5256
pub use create_role::CreateRolePlan;
5357
pub use create_stage::CreateStagePlan;
58+
pub use create_udf::CreateUDFPlan;
5459
pub use create_user::CreateUserPlan;
5560
pub use describe_table::DescribeTablePlan;
5661
pub use drop_database::DropDatabasePlan;
5762
pub use drop_role::DropRolePlan;
5863
pub use drop_stage::DropStagePlan;
5964
pub use drop_table::DropTablePlan;
6065
pub use drop_table_cluster_key::DropTableClusterKeyPlan;
66+
pub use drop_udf::DropUDFPlan;
6167
pub use drop_user::DropUserPlan;
6268
pub use exists_table::ExistsTablePlan;
6369
pub use grant_privilege::GrantPrivilegePlan;

src/query/service/src/interpreters/interpreter_user_udf_alter.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::AlterUserUDFPlan;
18+
use common_planner::plans::AlterUDFPlan;
1919
use common_users::UserApiProvider;
2020

2121
use crate::interpreters::Interpreter;
@@ -26,11 +26,11 @@ use crate::sessions::TableContext;
2626
#[derive(Debug)]
2727
pub struct AlterUserUDFInterpreter {
2828
ctx: Arc<QueryContext>,
29-
plan: AlterUserUDFPlan,
29+
plan: AlterUDFPlan,
3030
}
3131

3232
impl AlterUserUDFInterpreter {
33-
pub fn try_create(ctx: Arc<QueryContext>, plan: AlterUserUDFPlan) -> Result<Self> {
33+
pub fn try_create(ctx: Arc<QueryContext>, plan: AlterUDFPlan) -> Result<Self> {
3434
Ok(AlterUserUDFInterpreter { ctx, plan })
3535
}
3636
}

src/query/service/src/interpreters/interpreter_user_udf_create.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::CreateUserUDFPlan;
18+
use common_planner::plans::CreateUDFPlan;
1919
use common_users::UserApiProvider;
2020

2121
use crate::interpreters::Interpreter;
@@ -26,11 +26,11 @@ use crate::sessions::TableContext;
2626
#[derive(Debug)]
2727
pub struct CreateUserUDFInterpreter {
2828
ctx: Arc<QueryContext>,
29-
plan: CreateUserUDFPlan,
29+
plan: CreateUDFPlan,
3030
}
3131

3232
impl CreateUserUDFInterpreter {
33-
pub fn try_create(ctx: Arc<QueryContext>, plan: CreateUserUDFPlan) -> Result<Self> {
33+
pub fn try_create(ctx: Arc<QueryContext>, plan: CreateUDFPlan) -> Result<Self> {
3434
Ok(CreateUserUDFInterpreter { ctx, plan })
3535
}
3636
}

src/query/service/src/interpreters/interpreter_user_udf_drop.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::DropUserUDFPlan;
18+
use common_planner::plans::DropUDFPlan;
1919
use common_users::UserApiProvider;
2020

2121
use crate::interpreters::Interpreter;
@@ -26,11 +26,11 @@ use crate::sessions::TableContext;
2626
#[derive(Debug)]
2727
pub struct DropUserUDFInterpreter {
2828
ctx: Arc<QueryContext>,
29-
plan: DropUserUDFPlan,
29+
plan: DropUDFPlan,
3030
}
3131

3232
impl DropUserUDFInterpreter {
33-
pub fn try_create(ctx: Arc<QueryContext>, plan: DropUserUDFPlan) -> Result<Self> {
33+
pub fn try_create(ctx: Arc<QueryContext>, plan: DropUDFPlan) -> Result<Self> {
3434
Ok(DropUserUDFInterpreter { ctx, plan })
3535
}
3636
}

src/query/service/src/sql/planner/binder/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ use common_ast::Dialect;
2525
use common_ast::UDFValidator;
2626
use common_datavalues::DataTypeImpl;
2727
use common_exception::Result;
28-
use common_legacy_planners::AlterUserUDFPlan;
29-
use common_legacy_planners::CreateUserUDFPlan;
30-
use common_legacy_planners::DropUserUDFPlan;
3128
use common_meta_types::UserDefinedFunction;
29+
use common_planner::plans::AlterUDFPlan;
3230
use common_planner::plans::CallPlan;
3331
use common_planner::plans::CreateRolePlan;
32+
use common_planner::plans::CreateUDFPlan;
3433
use common_planner::plans::DropRolePlan;
3534
use common_planner::plans::DropStagePlan;
35+
use common_planner::plans::DropUDFPlan;
3636
use common_planner::plans::DropUserPlan;
3737
use common_planner::plans::ShowGrantsPlan;
3838
use common_planner::plans::UseDatabasePlan;
@@ -264,7 +264,7 @@ impl<'a> Binder {
264264
description: description.clone().unwrap_or_default(),
265265
};
266266

267-
Plan::CreateUDF(Box::new(CreateUserUDFPlan {
267+
Plan::CreateUDF(Box::new(CreateUDFPlan {
268268
if_not_exists: *if_not_exists,
269269
udf
270270
}))
@@ -288,14 +288,14 @@ impl<'a> Binder {
288288
description: description.clone().unwrap_or_default(),
289289
};
290290

291-
Plan::AlterUDF(Box::new(AlterUserUDFPlan {
291+
Plan::AlterUDF(Box::new(AlterUDFPlan {
292292
udf,
293293
}))
294294
}
295295
Statement::DropUDF {
296296
if_exists,
297297
udf_name,
298-
} => Plan::DropUDF(Box::new(DropUserUDFPlan {
298+
} => Plan::DropUDF(Box::new(DropUDFPlan {
299299
if_exists: *if_exists,
300300
name: udf_name.to_string(),
301301
})),

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,28 @@ use common_datavalues::DataSchema;
4444
use common_datavalues::DataSchemaRef;
4545
use common_datavalues::DataSchemaRefExt;
4646
use common_datavalues::StringType;
47-
use common_legacy_planners::AlterUserUDFPlan;
4847
use common_legacy_planners::AlterViewPlan;
49-
use common_legacy_planners::CreateUserUDFPlan;
5048
use common_legacy_planners::CreateViewPlan;
5149
use common_legacy_planners::DeletePlan;
52-
use common_legacy_planners::DropUserUDFPlan;
5350
use common_legacy_planners::DropViewPlan;
5451
use common_legacy_planners::ReclusterTablePlan;
5552
use common_legacy_planners::SettingPlan;
5653
use common_planner::plans::AlterTableClusterKeyPlan;
54+
use common_planner::plans::AlterUDFPlan;
5755
use common_planner::plans::AlterUserPlan;
5856
use common_planner::plans::CallPlan;
5957
use common_planner::plans::CreateDatabasePlan;
6058
use common_planner::plans::CreateRolePlan;
6159
use common_planner::plans::CreateStagePlan;
60+
use common_planner::plans::CreateUDFPlan;
6261
use common_planner::plans::CreateUserPlan;
6362
use common_planner::plans::DescribeTablePlan;
6463
use common_planner::plans::DropDatabasePlan;
6564
use common_planner::plans::DropRolePlan;
6665
use common_planner::plans::DropStagePlan;
6766
use common_planner::plans::DropTableClusterKeyPlan;
6867
use common_planner::plans::DropTablePlan;
68+
use common_planner::plans::DropUDFPlan;
6969
use common_planner::plans::DropUserPlan;
7070
use common_planner::plans::ExistsTablePlan;
7171
use common_planner::plans::GrantPrivilegePlan;
@@ -182,9 +182,9 @@ pub enum Plan {
182182
DropUser(Box<DropUserPlan>),
183183

184184
// UDF
185-
CreateUDF(Box<CreateUserUDFPlan>),
186-
AlterUDF(Box<AlterUserUDFPlan>),
187-
DropUDF(Box<DropUserUDFPlan>),
185+
CreateUDF(Box<CreateUDFPlan>),
186+
AlterUDF(Box<AlterUDFPlan>),
187+
DropUDF(Box<DropUDFPlan>),
188188

189189
// Role
190190
CreateRole(Box<CreateRolePlan>),

0 commit comments

Comments
 (0)