1515use std:: sync:: Arc ;
1616
1717use databend_common_catalog:: table_context:: TableContext ;
18+ use databend_common_cloud_control:: task_utils;
1819use databend_common_config:: GlobalConfig ;
19- #[ cfg( not( feature = "cloud-control" ) ) ]
20- use databend_common_exception:: ErrorCode ;
2120use databend_common_exception:: Result ;
2221use databend_common_license:: license:: Feature ;
2322use databend_common_license:: license_manager:: LicenseManagerSwitch ;
@@ -27,14 +26,11 @@ use databend_common_sql::plans::DescribeTaskPlan;
2726use databend_common_sql:: plans:: DropTaskPlan ;
2827use databend_common_sql:: plans:: ExecuteTaskPlan ;
2928use databend_common_sql:: plans:: ShowTasksPlan ;
30- use databend_common_storages_system:: TaskRecord ;
3129
32- #[ cfg( feature = "cloud-control" ) ]
3330use crate :: interpreters:: task:: cloud:: CloudTaskInterpreter ;
3431use crate :: interpreters:: task:: private:: PrivateTaskInterpreter ;
3532use crate :: sessions:: QueryContext ;
3633
37- #[ cfg( feature = "cloud-control" ) ]
3834mod cloud;
3935mod private;
4036
@@ -47,22 +43,11 @@ impl TaskInterpreterManager {
4743 . check_enterprise_enabled ( ctx. get_license_key ( ) , Feature :: PrivateTask ) ?;
4844 return Ok ( TaskInterpreterImpl :: Private ( PrivateTaskInterpreter ) ) ;
4945 }
50- #[ cfg( feature = "cloud-control" ) ]
51- {
52- return Ok ( TaskInterpreterImpl :: Cloud ( CloudTaskInterpreter ) ) ;
53- }
54-
55- #[ cfg( not( feature = "cloud-control" ) ) ]
56- {
57- Err ( ErrorCode :: Unimplemented (
58- "Cloud task support is disabled, rebuild with cargo feature 'cloud-control'" ,
59- ) )
60- }
46+ Ok ( TaskInterpreterImpl :: Cloud ( CloudTaskInterpreter ) )
6147 }
6248}
6349
6450pub ( crate ) enum TaskInterpreterImpl {
65- #[ cfg( feature = "cloud-control" ) ]
6651 Cloud ( CloudTaskInterpreter ) ,
6752 Private ( PrivateTaskInterpreter ) ,
6853}
@@ -78,37 +63,34 @@ pub(crate) trait TaskInterpreter {
7863 & self ,
7964 ctx : & Arc < QueryContext > ,
8065 plan : & DescribeTaskPlan ,
81- ) -> Result < Option < TaskRecord > > ;
66+ ) -> Result < Option < task_utils :: Task > > ;
8267
8368 async fn drop_task ( & self , ctx : & Arc < QueryContext > , plan : & DropTaskPlan ) -> Result < ( ) > ;
8469
8570 async fn show_tasks (
8671 & self ,
8772 ctx : & Arc < QueryContext > ,
8873 plan : & ShowTasksPlan ,
89- ) -> Result < Vec < TaskRecord > > ;
74+ ) -> Result < Vec < task_utils :: Task > > ;
9075}
9176
9277impl TaskInterpreter for TaskInterpreterImpl {
9378 async fn create_task ( & self , ctx : & Arc < QueryContext > , plan : & CreateTaskPlan ) -> Result < ( ) > {
9479 match self {
95- #[ cfg( feature = "cloud-control" ) ]
9680 TaskInterpreterImpl :: Cloud ( interpreter) => interpreter. create_task ( ctx, plan) . await ,
9781 TaskInterpreterImpl :: Private ( interpreter) => interpreter. create_task ( ctx, plan) . await ,
9882 }
9983 }
10084
10185 async fn execute_task ( & self , ctx : & Arc < QueryContext > , plan : & ExecuteTaskPlan ) -> Result < ( ) > {
10286 match self {
103- #[ cfg( feature = "cloud-control" ) ]
10487 TaskInterpreterImpl :: Cloud ( interpreter) => interpreter. execute_task ( ctx, plan) . await ,
10588 TaskInterpreterImpl :: Private ( interpreter) => interpreter. execute_task ( ctx, plan) . await ,
10689 }
10790 }
10891
10992 async fn alter_task ( & self , ctx : & Arc < QueryContext > , plan : & AlterTaskPlan ) -> Result < ( ) > {
11093 match self {
111- #[ cfg( feature = "cloud-control" ) ]
11294 TaskInterpreterImpl :: Cloud ( interpreter) => interpreter. alter_task ( ctx, plan) . await ,
11395 TaskInterpreterImpl :: Private ( interpreter) => interpreter. alter_task ( ctx, plan) . await ,
11496 }
@@ -118,17 +100,15 @@ impl TaskInterpreter for TaskInterpreterImpl {
118100 & self ,
119101 ctx : & Arc < QueryContext > ,
120102 plan : & DescribeTaskPlan ,
121- ) -> Result < Option < TaskRecord > > {
103+ ) -> Result < Option < task_utils :: Task > > {
122104 match self {
123- #[ cfg( feature = "cloud-control" ) ]
124105 TaskInterpreterImpl :: Cloud ( interpreter) => interpreter. describe_task ( ctx, plan) . await ,
125106 TaskInterpreterImpl :: Private ( interpreter) => interpreter. describe_task ( ctx, plan) . await ,
126107 }
127108 }
128109
129110 async fn drop_task ( & self , ctx : & Arc < QueryContext > , plan : & DropTaskPlan ) -> Result < ( ) > {
130111 match self {
131- #[ cfg( feature = "cloud-control" ) ]
132112 TaskInterpreterImpl :: Cloud ( interpreter) => interpreter. drop_task ( ctx, plan) . await ,
133113 TaskInterpreterImpl :: Private ( interpreter) => interpreter. drop_task ( ctx, plan) . await ,
134114 }
@@ -138,9 +118,8 @@ impl TaskInterpreter for TaskInterpreterImpl {
138118 & self ,
139119 ctx : & Arc < QueryContext > ,
140120 plan : & ShowTasksPlan ,
141- ) -> Result < Vec < TaskRecord > > {
121+ ) -> Result < Vec < task_utils :: Task > > {
142122 match self {
143- #[ cfg( feature = "cloud-control" ) ]
144123 TaskInterpreterImpl :: Cloud ( interpreter) => interpreter. show_tasks ( ctx, plan) . await ,
145124 TaskInterpreterImpl :: Private ( interpreter) => interpreter. show_tasks ( ctx, plan) . await ,
146125 }
0 commit comments