File tree Expand file tree Collapse file tree 3 files changed +22
-23
lines changed Expand file tree Collapse file tree 3 files changed +22
-23
lines changed Original file line number Diff line number Diff line change @@ -2121,7 +2121,7 @@ pub enum Statement {
2121
2121
location : Option < HiveSetLocation > ,
2122
2122
/// ClickHouse dialect supports `ON CLUSTER` clause for ALTER TABLE
2123
2123
/// 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 )
2125
2125
on_cluster : Option < String > ,
2126
2126
} ,
2127
2127
/// ```sql
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ use sqlparser::ast::Value::Number;
25
25
use sqlparser:: ast:: * ;
26
26
use sqlparser:: dialect:: ClickHouseDialect ;
27
27
use sqlparser:: dialect:: GenericDialect ;
28
- use sqlparser:: parser:: ParserError :: ParserError ;
29
28
30
29
#[ test]
31
30
fn parse_map_access_expr ( ) {
@@ -827,27 +826,6 @@ fn parse_create_table_on_commit_and_as_query() {
827
826
}
828
827
}
829
828
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
-
851
829
fn clickhouse ( ) -> TestedDialects {
852
830
TestedDialects {
853
831
dialects : vec ! [ Box :: new( ClickHouseDialect { } ) ] ,
Original file line number Diff line number Diff line change @@ -3811,6 +3811,27 @@ fn parse_alter_table() {
3811
3811
}
3812
3812
}
3813
3813
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
+
3814
3835
#[ test]
3815
3836
fn parse_alter_index ( ) {
3816
3837
let rename_index = "ALTER INDEX idx RENAME TO new_idx" ;
You can’t perform that action at this time.
0 commit comments