@@ -2369,7 +2369,7 @@ fn test_copy_into_with_transformations() {
23692369 StageLoadSelectItemKind :: StageLoadSelectItem ( StageLoadSelectItem {
23702370 alias: Some ( Ident :: new( "t1" ) ) ,
23712371 file_col_num: 1 ,
2372- element: Some ( Ident :: new( "st" ) ) ,
2372+ element: Some ( vec! [ Ident :: new( "st" ) ] ) ,
23732373 item_as: Some ( Ident :: new( "st" ) )
23742374 } )
23752375 ) ;
@@ -2378,7 +2378,7 @@ fn test_copy_into_with_transformations() {
23782378 StageLoadSelectItemKind :: StageLoadSelectItem ( StageLoadSelectItem {
23792379 alias: None ,
23802380 file_col_num: 1 ,
2381- element: Some ( Ident :: new( "index" ) ) ,
2381+ element: Some ( vec! [ Ident :: new( "index" ) ] ) ,
23822382 item_as: None
23832383 } )
23842384 ) ;
@@ -2640,6 +2640,70 @@ fn test_snowflake_copy_into_stage_name_ends_with_parens() {
26402640 }
26412641}
26422642
2643+ #[ test]
2644+ fn test_copy_into_with_nested_colon_path ( ) {
2645+ // Nested colon path with explicit AS alias
2646+ let sql = "COPY INTO tbl (col) FROM (SELECT $1:a:b AS col FROM @stage)" ;
2647+ match snowflake ( ) . verified_stmt ( sql) {
2648+ Statement :: CopyIntoSnowflake {
2649+ from_transformations,
2650+ ..
2651+ } => {
2652+ assert_eq ! (
2653+ from_transformations. as_ref( ) . unwrap( ) [ 0 ] ,
2654+ StageLoadSelectItemKind :: StageLoadSelectItem ( StageLoadSelectItem {
2655+ alias: None ,
2656+ file_col_num: 1 ,
2657+ element: Some ( vec![ Ident :: new( "a" ) , Ident :: new( "b" ) ] ) ,
2658+ item_as: Some ( Ident :: new( "col" ) )
2659+ } )
2660+ ) ;
2661+ }
2662+ _ => unreachable ! ( ) ,
2663+ }
2664+
2665+ // Nested colon path with implicit alias (no AS keyword)
2666+ let sql = "COPY INTO tbl (col) FROM (SELECT $1:a:b col FROM @stage)" ;
2667+ let stmts = snowflake ( ) . parse_sql_statements ( sql) . unwrap ( ) ;
2668+ match & stmts[ 0 ] {
2669+ Statement :: CopyIntoSnowflake {
2670+ from_transformations,
2671+ ..
2672+ } => {
2673+ assert_eq ! (
2674+ from_transformations. as_ref( ) . unwrap( ) [ 0 ] ,
2675+ StageLoadSelectItemKind :: StageLoadSelectItem ( StageLoadSelectItem {
2676+ alias: None ,
2677+ file_col_num: 1 ,
2678+ element: Some ( vec![ Ident :: new( "a" ) , Ident :: new( "b" ) ] ) ,
2679+ item_as: Some ( Ident :: new( "col" ) )
2680+ } )
2681+ ) ;
2682+ }
2683+ _ => unreachable ! ( ) ,
2684+ }
2685+
2686+ // Nested colon path with no alias
2687+ let sql = "COPY INTO tbl FROM (SELECT $1:a:b FROM @stage)" ;
2688+ match snowflake ( ) . verified_stmt ( sql) {
2689+ Statement :: CopyIntoSnowflake {
2690+ from_transformations,
2691+ ..
2692+ } => {
2693+ assert_eq ! (
2694+ from_transformations. as_ref( ) . unwrap( ) [ 0 ] ,
2695+ StageLoadSelectItemKind :: StageLoadSelectItem ( StageLoadSelectItem {
2696+ alias: None ,
2697+ file_col_num: 1 ,
2698+ element: Some ( vec![ Ident :: new( "a" ) , Ident :: new( "b" ) ] ) ,
2699+ item_as: None
2700+ } )
2701+ ) ;
2702+ }
2703+ _ => unreachable ! ( ) ,
2704+ }
2705+ }
2706+
26432707#[ test]
26442708fn test_snowflake_trim ( ) {
26452709 let real_sql = r#"SELECT customer_id, TRIM(sub_items.value:item_price_id, '"', "a") AS item_price_id FROM models_staging.subscriptions"# ;
0 commit comments