Skip to content

Commit 2b43a96

Browse files
committed
Fix review comments
1 parent e69a978 commit 2b43a96

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

src/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ pub enum Statement {
21212121
location: Option<HiveSetLocation>,
21222122
/// ClickHouse dialect supports `ON CLUSTER` clause for ALTER TABLE
21232123
/// For example: `ALTER TABLE table_name ON CLUSTER cluster_name ADD COLUMN c UInt32`
2124-
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter)
2124+
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter/update)
21252125
on_cluster: Option<String>,
21262126
},
21272127
/// ```sql

tests/sqlparser_clickhouse.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use sqlparser::ast::Value::Number;
2525
use sqlparser::ast::*;
2626
use sqlparser::dialect::ClickHouseDialect;
2727
use sqlparser::dialect::GenericDialect;
28-
use sqlparser::parser::ParserError::ParserError;
2928

3029
#[test]
3130
fn parse_map_access_expr() {
@@ -827,27 +826,6 @@ fn parse_create_table_on_commit_and_as_query() {
827826
}
828827
}
829828

830-
#[test]
831-
fn test_alter_table_with_on_cluster() {
832-
let sql = "ALTER TABLE t ON CLUSTER 'cluster' ADD CONSTRAINT bar PRIMARY KEY (baz)";
833-
match clickhouse_and_generic().verified_stmt(sql) {
834-
Statement::AlterTable {
835-
name, on_cluster, ..
836-
} => {
837-
assert_eq!(name.to_string(), "t");
838-
assert_eq!(on_cluster, Some("'cluster'".to_string()));
839-
}
840-
_ => unreachable!(),
841-
}
842-
843-
let res = clickhouse_and_generic()
844-
.parse_sql_statements("ALTER TABLE t ON CLUSTER 123 ADD CONSTRAINT bar PRIMARY KEY (baz)");
845-
assert_eq!(
846-
res.unwrap_err(),
847-
ParserError("Expected: identifier or cluster literal, found: 123".to_string())
848-
)
849-
}
850-
851829
fn clickhouse() -> TestedDialects {
852830
TestedDialects {
853831
dialects: vec![Box::new(ClickHouseDialect {})],

tests/sqlparser_common.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,6 +3811,27 @@ fn parse_alter_table() {
38113811
}
38123812
}
38133813

3814+
#[test]
3815+
fn test_alter_table_with_on_cluster() {
3816+
let sql = "ALTER TABLE t ON CLUSTER 'cluster' ADD CONSTRAINT bar PRIMARY KEY (baz)";
3817+
match all_dialects().verified_stmt(sql) {
3818+
Statement::AlterTable {
3819+
name, on_cluster, ..
3820+
} => {
3821+
std::assert_eq!(name.to_string(), "t");
3822+
std::assert_eq!(on_cluster, Some("'cluster'".to_string()));
3823+
}
3824+
_ => unreachable!(),
3825+
}
3826+
3827+
let res = all_dialects()
3828+
.parse_sql_statements("ALTER TABLE t ON CLUSTER 123 ADD CONSTRAINT bar PRIMARY KEY (baz)");
3829+
std::assert_eq!(
3830+
res.unwrap_err(),
3831+
ParserError::ParserError("Expected: identifier or cluster literal, found: 123".to_string())
3832+
)
3833+
}
3834+
38143835
#[test]
38153836
fn parse_alter_index() {
38163837
let rename_index = "ALTER INDEX idx RENAME TO new_idx";

0 commit comments

Comments
 (0)