@@ -3506,7 +3506,7 @@ fn parse_create_table_on_cluster() {
35063506 let sql = "CREATE TABLE t ON CLUSTER '{cluster}' (a INT, b INT)" ;
35073507 match generic. verified_stmt ( sql) {
35083508 Statement :: CreateTable ( CreateTable { on_cluster, .. } ) => {
3509- assert_eq ! ( on_cluster. unwrap( ) , "{cluster}" . to_string( ) ) ;
3509+ assert_eq ! ( on_cluster. unwrap( ) . to_string ( ) , "' {cluster}' " . to_string( ) ) ;
35103510 }
35113511 _ => unreachable ! ( ) ,
35123512 }
@@ -3515,7 +3515,7 @@ fn parse_create_table_on_cluster() {
35153515 let sql = "CREATE TABLE t ON CLUSTER my_cluster (a INT, b INT)" ;
35163516 match generic. verified_stmt ( sql) {
35173517 Statement :: CreateTable ( CreateTable { on_cluster, .. } ) => {
3518- assert_eq ! ( on_cluster. unwrap( ) , "my_cluster" . to_string( ) ) ;
3518+ assert_eq ! ( on_cluster. unwrap( ) . to_string ( ) , "my_cluster" . to_string( ) ) ;
35193519 }
35203520 _ => unreachable ! ( ) ,
35213521 }
@@ -3822,6 +3822,40 @@ fn parse_alter_table() {
38223822 }
38233823}
38243824
3825+ #[ test]
3826+ fn test_alter_table_with_on_cluster ( ) {
3827+ match all_dialects ( )
3828+ . verified_stmt ( "ALTER TABLE t ON CLUSTER 'cluster' ADD CONSTRAINT bar PRIMARY KEY (baz)" )
3829+ {
3830+ Statement :: AlterTable {
3831+ name, on_cluster, ..
3832+ } => {
3833+ std:: assert_eq!( name. to_string( ) , "t" ) ;
3834+ std:: assert_eq!( on_cluster, Some ( Ident :: with_quote( '\'' , "cluster" ) ) ) ;
3835+ }
3836+ _ => unreachable ! ( ) ,
3837+ }
3838+
3839+ match all_dialects ( )
3840+ . verified_stmt ( "ALTER TABLE t ON CLUSTER cluster_name ADD CONSTRAINT bar PRIMARY KEY (baz)" )
3841+ {
3842+ Statement :: AlterTable {
3843+ name, on_cluster, ..
3844+ } => {
3845+ std:: assert_eq!( name. to_string( ) , "t" ) ;
3846+ std:: assert_eq!( on_cluster, Some ( Ident :: new( "cluster_name" ) ) ) ;
3847+ }
3848+ _ => unreachable ! ( ) ,
3849+ }
3850+
3851+ let res = all_dialects ( )
3852+ . parse_sql_statements ( "ALTER TABLE t ON CLUSTER 123 ADD CONSTRAINT bar PRIMARY KEY (baz)" ) ;
3853+ std:: assert_eq!(
3854+ res. unwrap_err( ) ,
3855+ ParserError :: ParserError ( "Expected: identifier, found: 123" . to_string( ) )
3856+ )
3857+ }
3858+
38253859#[ test]
38263860fn parse_alter_index ( ) {
38273861 let rename_index = "ALTER INDEX idx RENAME TO new_idx" ;
0 commit comments