Skip to content

Commit

Permalink
Merge pull request #10291 from TCeason/refactor_v2
Browse files Browse the repository at this point in the history
refactor(query): Remove the v2 suffix of structs
  • Loading branch information
BohuTANG authored Mar 2, 2023
2 parents 0c88c00 + 6dfb34d commit 6b1efac
Show file tree
Hide file tree
Showing 36 changed files with 93 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ use tracing::info;

use crate::interpreters::common::append2table;
use crate::interpreters::Interpreter;
use crate::interpreters::SelectInterpreterV2;
use crate::interpreters::SelectInterpreter;
use crate::pipelines::processors::TransformLimit;
use crate::pipelines::PipelineBuildResult;
use crate::sessions::QueryContext;
use crate::sessions::TableContext;
use crate::sql::plans::CopyPlanV2;
use crate::sql::plans::CopyPlan;
use crate::sql::plans::Plan;

const MAX_QUERY_COPIED_FILES_NUM: usize = 50;

pub struct CopyInterpreterV2 {
pub struct CopyInterpreter {
ctx: Arc<QueryContext>,
plan: CopyPlanV2,
plan: CopyPlan,
}

impl CopyInterpreterV2 {
/// Create a CopyInterpreterV2 with context and [`CopyPlanV2`].
pub fn try_create(ctx: Arc<QueryContext>, plan: CopyPlanV2) -> Result<Self> {
Ok(CopyInterpreterV2 { ctx, plan })
impl CopyInterpreter {
/// Create a CopyInterpreter with context and [`CopyPlan`].
pub fn try_create(ctx: Arc<QueryContext>, plan: CopyPlan) -> Result<Self> {
Ok(CopyInterpreter { ctx, plan })
}

async fn build_copy_into_stage_pipeline(
Expand All @@ -79,7 +79,7 @@ impl CopyInterpreterV2 {
v => unreachable!("Input plan must be Query, but it's {}", v),
};

let select_interpreter = SelectInterpreterV2::try_create(
let select_interpreter = SelectInterpreter::try_create(
self.ctx.clone(),
*(bind_context.clone()),
*s_expr.clone(),
Expand Down Expand Up @@ -166,7 +166,7 @@ impl CopyInterpreterV2 {
for (file_name, file_info) in copy_stage_files {
do_copy_stage_files.insert(file_name.clone(), file_info);
if do_copy_stage_files.len() > MAX_QUERY_COPIED_FILES_NUM {
CopyInterpreterV2::do_upsert_copied_files_info_to_meta(
CopyInterpreter::do_upsert_copied_files_info_to_meta(
Some(expire_at),
tenant.clone(),
database_name.clone(),
Expand All @@ -178,7 +178,7 @@ impl CopyInterpreterV2 {
}
}
if !do_copy_stage_files.is_empty() {
CopyInterpreterV2::do_upsert_copied_files_info_to_meta(
CopyInterpreter::do_upsert_copied_files_info_to_meta(
Some(expire_at),
tenant.clone(),
database_name.clone(),
Expand Down Expand Up @@ -284,7 +284,7 @@ impl CopyInterpreterV2 {
let mut all_source_file_infos = StageTable::list_files(&stage_table_info).await?;

if !force {
all_source_file_infos = CopyInterpreterV2::color_copied_files(
all_source_file_infos = CopyInterpreter::color_copied_files(
&table_ctx,
catalog_name,
database_name,
Expand Down Expand Up @@ -409,7 +409,7 @@ impl CopyInterpreterV2 {
all_source_files.len(),
start.elapsed().as_secs()
);
CopyInterpreterV2::try_purge_files(
CopyInterpreter::try_purge_files(
ctx.clone(),
&stage_info,
&all_source_files,
Expand All @@ -423,7 +423,7 @@ impl CopyInterpreterV2 {
copied_files.len(),
start.elapsed().as_secs()
);
CopyInterpreterV2::upsert_copied_files_info_to_meta(
CopyInterpreter::upsert_copied_files_info_to_meta(
&ctx,
tenant,
database_name,
Expand Down Expand Up @@ -462,15 +462,15 @@ impl CopyInterpreterV2 {
}

#[async_trait::async_trait]
impl Interpreter for CopyInterpreterV2 {
impl Interpreter for CopyInterpreter {
fn name(&self) -> &str {
"CopyInterpreterV2"
}

#[tracing::instrument(level = "debug", name = "copy_interpreter_execute_v2", skip(self), fields(ctx.id = self.ctx.get_id().as_str()))]
async fn execute2(&self) -> Result<PipelineBuildResult> {
match &self.plan {
CopyPlanV2::IntoTable {
CopyPlan::IntoTable {
catalog_name,
database_name,
table_name,
Expand All @@ -493,7 +493,7 @@ impl Interpreter for CopyInterpreterV2 {
other
))),
},
CopyPlanV2::IntoStage {
CopyPlan::IntoStage {
stage, from, path, ..
} => self.build_copy_into_stage_pipeline(stage, path, from).await,
}
Expand Down
12 changes: 6 additions & 6 deletions src/query/service/src/interpreters/interpreter_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ use super::interpreter_user_stage_drop::DropUserStageInterpreter;
use super::*;
use crate::interpreters::access::Accessor;
use crate::interpreters::interpreter_catalog_drop::DropCatalogInterpreter;
use crate::interpreters::interpreter_copy_v2::CopyInterpreterV2;
use crate::interpreters::interpreter_copy::CopyInterpreter;
use crate::interpreters::interpreter_file_format_create::CreateFileFormatInterpreter;
use crate::interpreters::interpreter_file_format_drop::DropFileFormatInterpreter;
use crate::interpreters::interpreter_file_format_show::ShowFileFormatsInterpreter;
use crate::interpreters::interpreter_presign::PresignInterpreter;
use crate::interpreters::interpreter_role_show::ShowRolesInterpreter;
use crate::interpreters::interpreter_table_create_v2::CreateTableInterpreterV2;
use crate::interpreters::interpreter_table_create::CreateTableInterpreter;
use crate::interpreters::interpreter_table_revert::RevertTableInterpreter;
use crate::interpreters::AlterUserInterpreter;
use crate::interpreters::CreateShareInterpreter;
Expand Down Expand Up @@ -80,7 +80,7 @@ impl InterpreterFactory {
ignore_result,
formatted_ast,
..
} => Ok(Arc::new(SelectInterpreterV2::try_create(
} => Ok(Arc::new(SelectInterpreter::try_create(
ctx,
*bind_context.clone(),
*s_expr.clone(),
Expand Down Expand Up @@ -111,7 +111,7 @@ impl InterpreterFactory {

Plan::Call(plan) => Ok(Arc::new(CallInterpreter::try_create(ctx, *plan.clone())?)),

Plan::Copy(copy_plan) => Ok(Arc::new(CopyInterpreterV2::try_create(
Plan::Copy(copy_plan) => Ok(Arc::new(CopyInterpreter::try_create(
ctx,
*copy_plan.clone(),
)?)),
Expand Down Expand Up @@ -152,7 +152,7 @@ impl InterpreterFactory {
Plan::DescribeTable(describe_table) => Ok(Arc::new(
DescribeTableInterpreter::try_create(ctx, *describe_table.clone())?,
)),
Plan::CreateTable(create_table) => Ok(Arc::new(CreateTableInterpreterV2::try_create(
Plan::CreateTable(create_table) => Ok(Arc::new(CreateTableInterpreter::try_create(
ctx,
*create_table.clone(),
)?)),
Expand Down Expand Up @@ -226,7 +226,7 @@ impl InterpreterFactory {
*alter_user.clone(),
)?)),

Plan::Insert(insert) => InsertInterpreterV2::try_create(ctx, *insert.clone(), false),
Plan::Insert(insert) => InsertInterpreter::try_create(ctx, *insert.clone(), false),

Plan::Delete(delete) => Ok(Arc::new(DeleteInterpreter::try_create(
ctx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,20 @@ use crate::schedulers::build_query_pipeline;
use crate::sessions::QueryContext;
use crate::sessions::TableContext;

pub struct InsertInterpreterV2 {
pub struct InsertInterpreter {
ctx: Arc<QueryContext>,
plan: Insert,
source_pipe_builder: Mutex<Option<SourcePipeBuilder>>,
async_insert: bool,
}

impl InsertInterpreterV2 {
impl InsertInterpreter {
pub fn try_create(
ctx: Arc<QueryContext>,
plan: Insert,
async_insert: bool,
) -> Result<InterpreterPtr> {
Ok(Arc::new(InsertInterpreterV2 {
Ok(Arc::new(InsertInterpreter {
ctx,
plan,
source_pipe_builder: Mutex::new(None),
Expand Down Expand Up @@ -345,7 +345,7 @@ impl InsertInterpreterV2 {
}

#[async_trait::async_trait]
impl Interpreter for InsertInterpreterV2 {
impl Interpreter for InsertInterpreter {
fn name(&self) -> &str {
"InsertIntoInterpreter"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::sql::optimizer::SExpr;
use crate::sql::BindContext;

/// Interpret SQL query with ne&w SQL planner
pub struct SelectInterpreterV2 {
pub struct SelectInterpreter {
ctx: Arc<QueryContext>,
s_expr: SExpr,
bind_context: BindContext,
Expand All @@ -53,7 +53,7 @@ pub struct SelectInterpreterV2 {
ignore_result: bool,
}

impl SelectInterpreterV2 {
impl SelectInterpreter {
pub fn try_create(
ctx: Arc<QueryContext>,
bind_context: BindContext,
Expand All @@ -62,7 +62,7 @@ impl SelectInterpreterV2 {
formatted_ast: Option<String>,
ignore_result: bool,
) -> Result<Self> {
Ok(SelectInterpreterV2 {
Ok(SelectInterpreter {
ctx,
s_expr,
bind_context,
Expand Down Expand Up @@ -187,7 +187,7 @@ impl SelectInterpreterV2 {
}

#[async_trait::async_trait]
impl Interpreter for SelectInterpreterV2 {
impl Interpreter for SelectInterpreter {
fn name(&self) -> &str {
"SelectInterpreterV2"
}
Expand All @@ -198,7 +198,7 @@ impl Interpreter for SelectInterpreterV2 {

/// This method will create a new pipeline
/// The QueryPipelineBuilder will use the optimized plan to generate a Pipeline
#[tracing::instrument(level = "debug", name = "select_interpreter_v2_execute", skip(self), fields(ctx.id = self.ctx.get_id().as_str()))]
#[tracing::instrument(level = "debug", name = "select_interpreter_execute", skip(self), fields(ctx.id = self.ctx.get_id().as_str()))]
async fn execute2(&self) -> Result<PipelineBuildResult> {
// 0. Need to build pipeline first to get the partitions.
let mut build_res = self.build_pipeline().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ use common_meta_app::schema::TableMeta;
use common_meta_app::schema::TableNameIdent;
use common_meta_types::MatchSeq;
use common_sql::field_default_value;
use common_sql::plans::CreateTablePlanV2;
use common_sql::plans::CreateTablePlan;
use common_users::UserApiProvider;

use crate::interpreters::InsertInterpreterV2;
use crate::interpreters::InsertInterpreter;
use crate::interpreters::Interpreter;
use crate::pipelines::PipelineBuildResult;
use crate::sessions::QueryContext;
Expand All @@ -36,19 +36,19 @@ use crate::sql::plans::insert::InsertInputSource;
use crate::sql::plans::Plan;
use crate::storages::StorageDescription;

pub struct CreateTableInterpreterV2 {
pub struct CreateTableInterpreter {
ctx: Arc<QueryContext>,
plan: CreateTablePlanV2,
plan: CreateTablePlan,
}

impl CreateTableInterpreterV2 {
pub fn try_create(ctx: Arc<QueryContext>, plan: CreateTablePlanV2) -> Result<Self> {
Ok(CreateTableInterpreterV2 { ctx, plan })
impl CreateTableInterpreter {
pub fn try_create(ctx: Arc<QueryContext>, plan: CreateTablePlan) -> Result<Self> {
Ok(CreateTableInterpreter { ctx, plan })
}
}

#[async_trait::async_trait]
impl Interpreter for CreateTableInterpreterV2 {
impl Interpreter for CreateTableInterpreter {
fn name(&self) -> &str {
"CreateTableInterpreterV2"
}
Expand Down Expand Up @@ -108,7 +108,7 @@ impl Interpreter for CreateTableInterpreterV2 {
}
}

impl CreateTableInterpreterV2 {
impl CreateTableInterpreter {
async fn create_table_as_select(&self, select_plan: Box<Plan>) -> Result<PipelineBuildResult> {
let tenant = self.ctx.get_tenant();
let catalog = self.ctx.get_catalog(&self.plan.catalog)?;
Expand Down Expand Up @@ -138,7 +138,7 @@ impl CreateTableInterpreterV2 {
source: InsertInputSource::SelectPlan(select_plan),
};

InsertInterpreterV2::try_create(self.ctx.clone(), insert_plan, false)?
InsertInterpreter::try_create(self.ctx.clone(), insert_plan, false)?
.execute2()
.await
}
Expand Down
18 changes: 9 additions & 9 deletions src/query/service/src/interpreters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ mod interpreter_catalog_drop;
mod interpreter_cluster_key_alter;
mod interpreter_cluster_key_drop;
mod interpreter_clustering_history;
mod interpreter_copy_v2;
mod interpreter_copy;
mod interpreter_database_create;
mod interpreter_database_drop;
mod interpreter_database_rename;
mod interpreter_database_show_create;
mod interpreter_database_undrop;
mod interpreter_delete;
mod interpreter_explain_v2;
mod interpreter_explain;
mod interpreter_factory;
mod interpreter_file_format_create;
mod interpreter_file_format_drop;
mod interpreter_file_format_show;
mod interpreter_insert_v2;
mod interpreter_insert;
mod interpreter_kill;
mod interpreter_list;
mod interpreter_metrics;
Expand All @@ -48,7 +48,7 @@ mod interpreter_role_grant;
mod interpreter_role_revoke;
mod interpreter_role_set;
mod interpreter_role_show;
mod interpreter_select_v2;
mod interpreter_select;
mod interpreter_setting;
mod interpreter_share_alter_tenants;
mod interpreter_share_create;
Expand All @@ -62,7 +62,7 @@ mod interpreter_show_grants;
mod interpreter_show_object_grant_privileges;
mod interpreter_table_add_column;
mod interpreter_table_analyze;
mod interpreter_table_create_v2;
mod interpreter_table_create;
mod interpreter_table_describe;
mod interpreter_table_drop;
mod interpreter_table_drop_column;
Expand Down Expand Up @@ -104,9 +104,9 @@ pub use interpreter_database_rename::RenameDatabaseInterpreter;
pub use interpreter_database_show_create::ShowCreateDatabaseInterpreter;
pub use interpreter_database_undrop::UndropDatabaseInterpreter;
pub use interpreter_delete::DeleteInterpreter;
pub use interpreter_explain_v2::ExplainInterpreter;
pub use interpreter_explain::ExplainInterpreter;
pub use interpreter_factory::InterpreterFactory;
pub use interpreter_insert_v2::InsertInterpreterV2;
pub use interpreter_insert::InsertInterpreter;
pub use interpreter_kill::KillInterpreter;
pub use interpreter_list::ListInterpreter;
pub use interpreter_metrics::InterpreterMetrics;
Expand All @@ -118,7 +118,7 @@ pub use interpreter_role_drop::DropRoleInterpreter;
pub use interpreter_role_grant::GrantRoleInterpreter;
pub use interpreter_role_revoke::RevokeRoleInterpreter;
pub use interpreter_role_set::SetRoleInterpreter;
pub use interpreter_select_v2::SelectInterpreterV2;
pub use interpreter_select::SelectInterpreter;
pub use interpreter_setting::SettingInterpreter;
pub use interpreter_share_alter_tenants::AlterShareTenantsInterpreter;
pub use interpreter_share_create::CreateShareInterpreter;
Expand All @@ -131,7 +131,7 @@ pub use interpreter_show_grants::ShowGrantsInterpreter;
pub use interpreter_show_object_grant_privileges::ShowObjectGrantPrivilegesInterpreter;
pub use interpreter_table_add_column::AddTableColumnInterpreter;
pub use interpreter_table_analyze::AnalyzeTableInterpreter;
pub use interpreter_table_create_v2::CreateTableInterpreterV2;
pub use interpreter_table_create::CreateTableInterpreter;
pub use interpreter_table_describe::DescribeTableInterpreter;
pub use interpreter_table_drop::DropTableInterpreter;
pub use interpreter_table_drop_column::DropTableColumnInterpreter;
Expand Down
4 changes: 2 additions & 2 deletions src/query/service/src/procedures/systems/search_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use common_storages_system::TablesTableWithoutHistory;
use futures::TryStreamExt;

use crate::interpreters::Interpreter;
use crate::interpreters::SelectInterpreterV2;
use crate::interpreters::SelectInterpreter;
use crate::procedures::OneBlockProcedure;
use crate::procedures::Procedure;
use crate::procedures::ProcedureFeatures;
Expand Down Expand Up @@ -65,7 +65,7 @@ impl OneBlockProcedure for SearchTablesProcedure {
..
} = plan
{
let interpreter = SelectInterpreterV2::try_create(
let interpreter = SelectInterpreter::try_create(
ctx.clone(),
*bind_context,
*s_expr,
Expand Down
Loading

1 comment on commit 6b1efac

@vercel
Copy link

@vercel vercel bot commented on 6b1efac Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend.vercel.app
databend-databend.vercel.app
databend.rs
databend-git-main-databend.vercel.app

Please sign in to comment.