From c5ceabf2dbc778af49b36c15900faef682e672bd Mon Sep 17 00:00:00 2001 From: ShiKaiWi Date: Fri, 14 Oct 2022 17:14:11 +0800 Subject: [PATCH] chore: adjust the orgnization of creator/dropper files --- interpreters/src/{create.rs => create/mod.rs} | 4 +++- .../{ => create}/table_creator/catalog_based.rs | 4 ++-- .../src/{ => create}/table_creator/meta_based.rs | 6 +++++- interpreters/src/{ => create}/table_creator/mod.rs | 0 interpreters/src/{drop.rs => drop/mod.rs} | 4 +++- .../src/{ => drop}/table_dropper/catalog_based.rs | 6 ++++-- .../src/{ => drop}/table_dropper/meta_based.rs | 6 +++++- interpreters/src/{ => drop}/table_dropper/mod.rs | 0 interpreters/src/factory.rs | 14 ++++++++++---- interpreters/src/lib.rs | 2 -- interpreters/src/tests.rs | 4 ++-- server/src/instance.rs | 2 +- server/src/server.rs | 2 +- 13 files changed, 36 insertions(+), 18 deletions(-) rename interpreters/src/{create.rs => create/mod.rs} (97%) rename interpreters/src/{ => create}/table_creator/catalog_based.rs (94%) rename interpreters/src/{ => create}/table_creator/meta_based.rs (79%) rename interpreters/src/{ => create}/table_creator/mod.rs (100%) rename interpreters/src/{drop.rs => drop/mod.rs} (97%) rename interpreters/src/{ => drop}/table_dropper/catalog_based.rs (93%) rename interpreters/src/{ => drop}/table_dropper/meta_based.rs (79%) rename interpreters/src/{ => drop}/table_dropper/mod.rs (100%) diff --git a/interpreters/src/create.rs b/interpreters/src/create/mod.rs similarity index 97% rename from interpreters/src/create.rs rename to interpreters/src/create/mod.rs index b015a48308..86c0887dbe 100644 --- a/interpreters/src/create.rs +++ b/interpreters/src/create/mod.rs @@ -9,10 +9,12 @@ use table_engine::engine::TableEngineRef; use crate::{ context::Context, + create::table_creator::TableCreatorRef, interpreter::{Create, Interpreter, InterpreterPtr, Output, Result as InterpreterResult}, - table_creator::TableCreatorRef, }; +pub mod table_creator; + #[derive(Debug, Snafu)] #[snafu(visibility(pub(crate)))] pub enum Error { diff --git a/interpreters/src/table_creator/catalog_based.rs b/interpreters/src/create/table_creator/catalog_based.rs similarity index 94% rename from interpreters/src/table_creator/catalog_based.rs rename to interpreters/src/create/table_creator/catalog_based.rs index d24e9005c5..2fa9cf3f7f 100644 --- a/interpreters/src/table_creator/catalog_based.rs +++ b/interpreters/src/create/table_creator/catalog_based.rs @@ -12,10 +12,10 @@ use table_engine::engine::{TableEngineRef, TableState}; use crate::{ context::Context, create::{ - CatalogNotExists, FindCatalog, FindSchema, Result, SchemaCreateTable, SchemaNotExists, + table_creator::TableCreator, CatalogNotExists, FindCatalog, FindSchema, Result, + SchemaCreateTable, SchemaNotExists, }, interpreter::Output, - table_creator::TableCreator, }; pub struct TableCreatorImpl { diff --git a/interpreters/src/table_creator/meta_based.rs b/interpreters/src/create/table_creator/meta_based.rs similarity index 79% rename from interpreters/src/table_creator/meta_based.rs rename to interpreters/src/create/table_creator/meta_based.rs index 5fae1fbe41..18ca4a3c24 100644 --- a/interpreters/src/table_creator/meta_based.rs +++ b/interpreters/src/create/table_creator/meta_based.rs @@ -4,7 +4,11 @@ use async_trait::async_trait; use sql::plan::CreateTablePlan; use table_engine::engine::TableEngineRef; -use crate::{context::Context, create::Result, interpreter::Output, table_creator::TableCreator}; +use crate::{ + context::Context, + create::{table_creator::TableCreator, Result}, + interpreter::Output, +}; pub struct TableCreatorImpl {} diff --git a/interpreters/src/table_creator/mod.rs b/interpreters/src/create/table_creator/mod.rs similarity index 100% rename from interpreters/src/table_creator/mod.rs rename to interpreters/src/create/table_creator/mod.rs diff --git a/interpreters/src/drop.rs b/interpreters/src/drop/mod.rs similarity index 97% rename from interpreters/src/drop.rs rename to interpreters/src/drop/mod.rs index d5848e13c2..24a31ee64f 100644 --- a/interpreters/src/drop.rs +++ b/interpreters/src/drop/mod.rs @@ -9,10 +9,12 @@ use table_engine::engine::TableEngineRef; use crate::{ context::Context, + drop::table_dropper::TableDropperRef, interpreter::{Drop, Interpreter, InterpreterPtr, Output, Result as InterpreterResult}, - table_dropper::TableDropperRef, }; +pub mod table_dropper; + #[derive(Debug, Snafu)] #[snafu(visibility(pub(crate)))] pub enum Error { diff --git a/interpreters/src/table_dropper/catalog_based.rs b/interpreters/src/drop/table_dropper/catalog_based.rs similarity index 93% rename from interpreters/src/table_dropper/catalog_based.rs rename to interpreters/src/drop/table_dropper/catalog_based.rs index a9e3349619..bc15465e3c 100644 --- a/interpreters/src/table_dropper/catalog_based.rs +++ b/interpreters/src/drop/table_dropper/catalog_based.rs @@ -12,9 +12,11 @@ use table_engine::engine::TableEngineRef; use crate::{ context::Context, - drop::{CatalogNotExists, FindCatalog, FindSchema, Result, SchemaDropTable, SchemaNotExists}, + drop::{ + table_dropper::TableDropper, CatalogNotExists, FindCatalog, FindSchema, Result, + SchemaDropTable, SchemaNotExists, + }, interpreter::Output, - table_dropper::TableDropper, }; pub struct TableDropperImpl { diff --git a/interpreters/src/table_dropper/meta_based.rs b/interpreters/src/drop/table_dropper/meta_based.rs similarity index 79% rename from interpreters/src/table_dropper/meta_based.rs rename to interpreters/src/drop/table_dropper/meta_based.rs index c535b5a3d9..5f006391e8 100644 --- a/interpreters/src/table_dropper/meta_based.rs +++ b/interpreters/src/drop/table_dropper/meta_based.rs @@ -4,7 +4,11 @@ use async_trait::async_trait; use sql::plan::DropTablePlan; use table_engine::engine::TableEngineRef; -use crate::{context::Context, drop::Result, interpreter::Output, table_dropper::TableDropper}; +use crate::{ + context::Context, + drop::{table_dropper::TableDropper, Result}, + interpreter::Output, +}; pub struct TableDropperImpl {} diff --git a/interpreters/src/table_dropper/mod.rs b/interpreters/src/drop/table_dropper/mod.rs similarity index 100% rename from interpreters/src/table_dropper/mod.rs rename to interpreters/src/drop/table_dropper/mod.rs diff --git a/interpreters/src/factory.rs b/interpreters/src/factory.rs index 42f2c1a8bb..7525148fcd 100644 --- a/interpreters/src/factory.rs +++ b/interpreters/src/factory.rs @@ -8,10 +8,16 @@ use sql::plan::Plan; use table_engine::engine::TableEngineRef; use crate::{ - alter_table::AlterTableInterpreter, context::Context, create::CreateInterpreter, - describe::DescribeInterpreter, drop::DropInterpreter, exists::ExistsInterpreter, - insert::InsertInterpreter, interpreter::InterpreterPtr, select::SelectInterpreter, - show::ShowInterpreter, table_creator::TableCreatorRef, table_dropper::TableDropperRef, + alter_table::AlterTableInterpreter, + context::Context, + create::{table_creator::TableCreatorRef, CreateInterpreter}, + describe::DescribeInterpreter, + drop::{table_dropper::TableDropperRef, DropInterpreter}, + exists::ExistsInterpreter, + insert::InsertInterpreter, + interpreter::InterpreterPtr, + select::SelectInterpreter, + show::ShowInterpreter, }; /// A factory to create interpreters diff --git a/interpreters/src/lib.rs b/interpreters/src/lib.rs index 450be8532a..2d5147ff8f 100644 --- a/interpreters/src/lib.rs +++ b/interpreters/src/lib.rs @@ -18,8 +18,6 @@ pub mod insert; pub mod interpreter; pub mod select; pub mod show; -pub mod table_creator; -pub mod table_dropper; mod show_create; diff --git a/interpreters/src/tests.rs b/interpreters/src/tests.rs index 33b0de67ce..58f3e93925 100644 --- a/interpreters/src/tests.rs +++ b/interpreters/src/tests.rs @@ -17,10 +17,10 @@ use table_engine::engine::TableEngineRef; use crate::{ context::Context, + create::table_creator::catalog_based::TableCreatorImpl, + drop::table_dropper::catalog_based::TableDropperImpl, factory::Factory, interpreter::{Output, Result}, - table_creator::catalog_based::TableCreatorImpl, - table_dropper::catalog_based::TableDropperImpl, }; async fn build_catalog_manager(analytic: TableEngineRef) -> TableBasedManager { diff --git a/server/src/instance.rs b/server/src/instance.rs index 810c09ce1e..f65ea90fa3 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use catalog::manager::ManagerRef; use df_operator::registry::FunctionRegistryRef; -use interpreters::{table_creator::TableCreatorRef, table_dropper::TableDropperRef}; +use interpreters::{create::table_creator::TableCreatorRef, drop::table_dropper::TableDropperRef}; use table_engine::engine::TableEngineRef; use crate::limiter::Limiter; diff --git a/server/src/server.rs b/server/src/server.rs index 268d2b7075..b85b374210 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use catalog::manager::ManagerRef; use cluster::ClusterRef; use df_operator::registry::FunctionRegistryRef; -use interpreters::{table_creator, table_dropper}; +use interpreters::{create::table_creator, drop::table_dropper}; use log::warn; use query_engine::executor::Executor as QueryExecutor; use snafu::{Backtrace, OptionExt, ResultExt, Snafu};