@@ -3861,6 +3861,71 @@ fn parse_ls_and_rm() {
38613861 . unwrap ( ) ;
38623862}
38633863
3864+ #[ test]
3865+ fn test_put ( ) {
3866+ let sql = "PUT 'file:///tmp/data.csv' @my_stage" ;
3867+ match snowflake ( ) . verified_stmt ( sql) {
3868+ Statement :: Put {
3869+ source,
3870+ stage,
3871+ options,
3872+ } => {
3873+ assert_eq ! ( "file:///tmp/data.csv" , source) ;
3874+ assert_eq ! ( ObjectName :: from( vec![ "@my_stage" . into( ) ] ) , stage) ;
3875+ assert ! ( options. options. is_empty( ) ) ;
3876+ }
3877+ _ => unreachable ! ( ) ,
3878+ } ;
3879+ assert_eq ! ( snowflake( ) . verified_stmt( sql) . to_string( ) , sql) ;
3880+ }
3881+
3882+ #[ test]
3883+ fn test_put_with_quoted_stage ( ) {
3884+ // Stage names can be quoted (e.g. Snowflake driver `write_pandas`)
3885+ let sql = r#"PUT 'file:///tmp/data.csv' @"my stage" PARALLEL=4"# ;
3886+ match snowflake ( ) . verified_stmt ( sql) {
3887+ Statement :: Put { stage, .. } => {
3888+ assert_eq ! ( ObjectName :: from( vec![ r#"@"my stage""# . into( ) ] ) , stage) ;
3889+ }
3890+ _ => unreachable ! ( ) ,
3891+ } ;
3892+ assert_eq ! ( snowflake( ) . verified_stmt( sql) . to_string( ) , sql) ;
3893+ }
3894+
3895+ #[ test]
3896+ fn test_put_with_options ( ) {
3897+ let sql = concat ! (
3898+ "PUT 'file:///tmp/data.csv' @my_stage " ,
3899+ "PARALLEL=8 AUTO_COMPRESS=true SOURCE_COMPRESSION=GZIP OVERWRITE=false"
3900+ ) ;
3901+ match snowflake ( ) . verified_stmt ( sql) {
3902+ Statement :: Put { options, .. } => {
3903+ assert ! ( options. options. contains( & KeyValueOption {
3904+ option_name: "PARALLEL" . to_string( ) ,
3905+ option_value: KeyValueOptionKind :: Single (
3906+ Value :: Number ( "8" . parse( ) . unwrap( ) , false ) . with_empty_span( )
3907+ ) ,
3908+ } ) ) ;
3909+ assert ! ( options. options. contains( & KeyValueOption {
3910+ option_name: "AUTO_COMPRESS" . to_string( ) ,
3911+ option_value: KeyValueOptionKind :: Single ( Value :: Boolean ( true ) . with_empty_span( ) ) ,
3912+ } ) ) ;
3913+ assert ! ( options. options. contains( & KeyValueOption {
3914+ option_name: "SOURCE_COMPRESSION" . to_string( ) ,
3915+ option_value: KeyValueOptionKind :: Single (
3916+ Value :: Placeholder ( "GZIP" . to_string( ) ) . with_empty_span( )
3917+ ) ,
3918+ } ) ) ;
3919+ assert ! ( options. options. contains( & KeyValueOption {
3920+ option_name: "OVERWRITE" . to_string( ) ,
3921+ option_value: KeyValueOptionKind :: Single ( Value :: Boolean ( false ) . with_empty_span( ) ) ,
3922+ } ) ) ;
3923+ }
3924+ _ => unreachable ! ( ) ,
3925+ } ;
3926+ assert_eq ! ( snowflake( ) . verified_stmt( sql) . to_string( ) , sql) ;
3927+ }
3928+
38643929#[ test]
38653930fn test_sql_keywords_as_select_item_ident ( ) {
38663931 // Some keywords that should be parsed as an alias
0 commit comments