@@ -1016,6 +1016,44 @@ fn test_select_wildcard_with_rename() {
10161016 assert_eq ! ( expected, select. projection[ 0 ] ) ;
10171017}
10181018
1019+ #[ test]
1020+ fn test_select_wildcard_with_replace_and_rename ( ) {
1021+ let select = snowflake_and_generic ( ) . verified_only_select (
1022+ "SELECT * REPLACE (col_z || col_z AS col_z) RENAME (col_z AS col_zz) FROM data" ,
1023+ ) ;
1024+ let expected = SelectItem :: Wildcard ( WildcardAdditionalOptions {
1025+ opt_replace : Some ( ReplaceSelectItem {
1026+ items : vec ! [ Box :: new( ReplaceSelectElement {
1027+ expr: Expr :: BinaryOp {
1028+ left: Box :: new( Expr :: Identifier ( Ident :: new( "col_z" ) ) ) ,
1029+ op: BinaryOperator :: StringConcat ,
1030+ right: Box :: new( Expr :: Identifier ( Ident :: new( "col_z" ) ) ) ,
1031+ } ,
1032+ column_name: Ident :: new( "col_z" ) ,
1033+ as_keyword: true ,
1034+ } ) ] ,
1035+ } ) ,
1036+ opt_rename : Some ( RenameSelectItem :: Multiple ( vec ! [ IdentWithAlias {
1037+ ident: Ident :: new( "col_z" ) ,
1038+ alias: Ident :: new( "col_zz" ) ,
1039+ } ] ) ) ,
1040+ ..Default :: default ( )
1041+ } ) ;
1042+ assert_eq ! ( expected, select. projection[ 0 ] ) ;
1043+
1044+ // rename cannot precede replace
1045+ // https://docs.snowflake.com/en/sql-reference/sql/select#parameters
1046+ assert_eq ! (
1047+ snowflake_and_generic( )
1048+ . parse_sql_statements(
1049+ "SELECT * RENAME (col_z AS col_zz) REPLACE (col_z || col_z AS col_z) FROM data"
1050+ )
1051+ . unwrap_err( )
1052+ . to_string( ) ,
1053+ "sql parser error: Expected: end of statement, found: REPLACE"
1054+ ) ;
1055+ }
1056+
10191057#[ test]
10201058fn test_select_wildcard_with_exclude_and_rename ( ) {
10211059 let select = snowflake_and_generic ( )
@@ -1031,6 +1069,7 @@ fn test_select_wildcard_with_exclude_and_rename() {
10311069 assert_eq ! ( expected, select. projection[ 0 ] ) ;
10321070
10331071 // rename cannot precede exclude
1072+ // https://docs.snowflake.com/en/sql-reference/sql/select#parameters
10341073 assert_eq ! (
10351074 snowflake_and_generic( )
10361075 . parse_sql_statements( "SELECT * RENAME col_a AS col_b EXCLUDE col_z FROM data" )
0 commit comments