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 {
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
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ use sqlparser::ast::Value::Number;
2525use sqlparser:: ast:: * ;
2626use sqlparser:: dialect:: ClickHouseDialect ;
2727use sqlparser:: dialect:: GenericDialect ;
28- use sqlparser:: parser:: ParserError :: ParserError ;
2928
3029#[ test]
3130fn 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-
851829fn clickhouse ( ) -> TestedDialects {
852830 TestedDialects {
853831 dialects : vec ! [ Box :: new( ClickHouseDialect { } ) ] ,
Original file line number Diff line number Diff 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]
38153836fn parse_alter_index ( ) {
38163837 let rename_index = "ALTER INDEX idx RENAME TO new_idx" ;
You can’t perform that action at this time.
0 commit comments