Skip to content

Commit

Permalink
Rename AddClusterKey to AlterClusterKey
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyass committed Jun 5, 2022
1 parent 95fb701 commit 2388060
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions common/ast/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pub enum AlterDatabaseAction<'a> {
#[derive(Debug, Clone, PartialEq)]
pub enum AlterTableAction<'a> {
RenameTable { new_table: Identifier<'a> },
AddClusterKey { cluster_by: Vec<Expr<'a>> },
AlterClusterKey { cluster_by: Vec<Expr<'a>> },
// TODO(wuzhiguo): AddColumn etc
}

Expand Down Expand Up @@ -580,7 +580,7 @@ impl<'a> Display for Statement<'a> {
AlterTableAction::RenameTable { new_table } => {
write!(f, " RENAME TO {new_table}")?;
}
AlterTableAction::AddClusterKey { cluster_by } => {
AlterTableAction::AlterClusterKey { cluster_by } => {
write!(f, " CLUSTER BY ")?;
write_comma_separated_list(f, cluster_by)?;
}
Expand Down
2 changes: 1 addition & 1 deletion common/ast/src/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ pub fn alter_table_action(i: Input) -> IResult<AlterTableAction> {
rule! {
CLUSTER ~ ^BY ~ ^"(" ~ ^#comma_separated_list1(expr) ~ ^")"
},
|(_, _, _, cluster_by, _)| AlterTableAction::AddClusterKey { cluster_by },
|(_, _, _, cluster_by, _)| AlterTableAction::AlterClusterKey { cluster_by },
);

rule!(
Expand Down
2 changes: 1 addition & 1 deletion query/src/interpreters/interpreter_factory_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl InterpreterFactoryV2 {
ExplainInterpreterV2::try_create(ctx, *plan.clone(), kind.clone())
}
Plan::CreateTable(create_table) => {
CreateTableInterpreter::try_create(ctx, create_table.clone())
CreateTableInterpreter::try_create(ctx, *create_table.clone())
}
}?;
Ok(inner)
Expand Down
2 changes: 1 addition & 1 deletion query/src/sql/parsers/parser_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl<'a> DfParser<'a> {
let cluster_by = DfAlterTable {
if_exists,
table_name,
action: AlterTableAction::AddClusterKey(cluster_keys),
action: AlterTableAction::AlterClusterKey(cluster_keys),
};

Ok(DfStatement::AlterTable(cluster_by))
Expand Down
2 changes: 1 addition & 1 deletion query/src/sql/planner/binder/ddl/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,6 @@ impl<'a> Binder {
None
},
};
Ok(Plan::CreateTable(plan))
Ok(Plan::CreateTable(Box::new(plan)))
}
}
2 changes: 1 addition & 1 deletion query/src/sql/planner/plans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ pub enum Plan {
},

// DDL
CreateTable(CreateTablePlan),
CreateTable(Box<CreateTablePlan>),
}
4 changes: 2 additions & 2 deletions query/src/sql/statements/statement_alter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct DfAlterTable {
#[derive(Clone, Debug, PartialEq)]
pub enum AlterTableAction {
RenameTable(ObjectName),
AddClusterKey(Vec<Expr>),
AlterClusterKey(Vec<Expr>),
// TODO AddColumn etc.
}

Expand Down Expand Up @@ -70,7 +70,7 @@ impl AnalyzableStatement for DfAlterTable {
PlanNode::RenameTable(RenameTablePlan { tenant, entities }),
)))
}
AlterTableAction::AddClusterKey(exprs) => {
AlterTableAction::AlterClusterKey(exprs) => {
let expression_analyzer = ExpressionAnalyzer::create(ctx);
let cluster_keys = exprs.iter().try_fold(vec![], |mut acc, k| {
let expr = expression_analyzer.analyze_sync(k)?;
Expand Down
2 changes: 1 addition & 1 deletion query/tests/it/sql/parsers/parser_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn alter_cluster_key() -> Result<()> {
let expected = DfStatement::AlterTable(DfAlterTable {
if_exists: false,
table_name: ObjectName(vec![Ident::new("t1")]),
action: AlterTableAction::AddClusterKey(vec![
action: AlterTableAction::AlterClusterKey(vec![
Expr::Identifier(Ident::new("a")),
Expr::Identifier(Ident::new("b")),
]),
Expand Down
1 change: 1 addition & 0 deletions query/tests/it/storages/fuse/table_test_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl TestFixture {
(OPT_KEY_DATABASE_ID.to_owned(), "1".to_owned()),
]
.into(),
cluster_key: Some("(id)".to_string()),
cluster_keys: vec!["(id)".to_string()],
default_cluster_key_id: Some(0),
..Default::default()
Expand Down

0 comments on commit 2388060

Please sign in to comment.