Skip to content

Commit b01e9ec

Browse files
committed
Fix review comments
1 parent 85e4b6f commit b01e9ec

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
@@ -2164,7 +2164,7 @@ pub enum Statement {
21642164
location: Option<HiveSetLocation>,
21652165
/// ClickHouse dialect supports `ON CLUSTER` clause for ALTER TABLE
21662166
/// For example: `ALTER TABLE table_name ON CLUSTER cluster_name ADD COLUMN c UInt32`
2167-
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter)
2167+
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter/update)
21682168
on_cluster: Option<String>,
21692169
},
21702170
/// ```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() {
@@ -1092,27 +1091,6 @@ fn parse_create_table_on_commit_and_as_query() {
10921091
}
10931092
}
10941093

1095-
#[test]
1096-
fn test_alter_table_with_on_cluster() {
1097-
let sql = "ALTER TABLE t ON CLUSTER 'cluster' ADD CONSTRAINT bar PRIMARY KEY (baz)";
1098-
match clickhouse_and_generic().verified_stmt(sql) {
1099-
Statement::AlterTable {
1100-
name, on_cluster, ..
1101-
} => {
1102-
assert_eq!(name.to_string(), "t");
1103-
assert_eq!(on_cluster, Some("'cluster'".to_string()));
1104-
}
1105-
_ => unreachable!(),
1106-
}
1107-
1108-
let res = clickhouse_and_generic()
1109-
.parse_sql_statements("ALTER TABLE t ON CLUSTER 123 ADD CONSTRAINT bar PRIMARY KEY (baz)");
1110-
assert_eq!(
1111-
res.unwrap_err(),
1112-
ParserError("Expected: identifier or cluster literal, found: 123".to_string())
1113-
)
1114-
}
1115-
11161094
fn clickhouse() -> TestedDialects {
11171095
TestedDialects {
11181096
dialects: vec![Box::new(ClickHouseDialect {})],

tests/sqlparser_common.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,6 +3822,27 @@ fn parse_alter_table() {
38223822
}
38233823
}
38243824

3825+
#[test]
3826+
fn test_alter_table_with_on_cluster() {
3827+
let sql = "ALTER TABLE t ON CLUSTER 'cluster' ADD CONSTRAINT bar PRIMARY KEY (baz)";
3828+
match all_dialects().verified_stmt(sql) {
3829+
Statement::AlterTable {
3830+
name, on_cluster, ..
3831+
} => {
3832+
std::assert_eq!(name.to_string(), "t");
3833+
std::assert_eq!(on_cluster, Some("'cluster'".to_string()));
3834+
}
3835+
_ => unreachable!(),
3836+
}
3837+
3838+
let res = all_dialects()
3839+
.parse_sql_statements("ALTER TABLE t ON CLUSTER 123 ADD CONSTRAINT bar PRIMARY KEY (baz)");
3840+
std::assert_eq!(
3841+
res.unwrap_err(),
3842+
ParserError::ParserError("Expected: identifier or cluster literal, found: 123".to_string())
3843+
)
3844+
}
3845+
38253846
#[test]
38263847
fn parse_alter_index() {
38273848
let rename_index = "ALTER INDEX idx RENAME TO new_idx";

0 commit comments

Comments
 (0)