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