@@ -2989,12 +2989,23 @@ impl From<Set> for Statement {
2989
2989
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
2990
2990
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
2991
2991
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
2992
- pub struct Exception {
2992
+ pub struct ExceptionClause {
2993
+ /// When represents each `WHEN` case
2993
2994
pub when : Vec < ExceptionWhen > ,
2995
+ /// The exception that is being raised or the current exception being handled if `None`.
2996
+ ///
2997
+ /// Example
2998
+ /// RAISE;
2999
+ /// RAISE MY_EXCEPTION;
3000
+ /// RAISE USING MESSAGE = "Some error";
3001
+ ///
3002
+ /// BigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#raise
3003
+ /// Snowflake: <https://docs.snowflake.com/en/sql-reference/snowflake-scripting/raise>
3004
+ // pub raises: Option<Option<Ident>>,
2994
3005
pub raises : Option < Box < Statement > > ,
2995
3006
}
2996
3007
2997
- impl Display for Exception {
3008
+ impl Display for ExceptionClause {
2998
3009
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2999
3010
write ! ( f, " EXCEPTION" ) ?;
3000
3011
for w in & self . when {
@@ -3011,6 +3022,9 @@ impl Display for Exception {
3011
3022
3012
3023
/// A representation of a `WHEN` arm with all the identifiers catched and the statements to execute
3013
3024
/// for the arm.
3025
+ ///
3026
+ /// Snowflake: <https://docs.snowflake.com/en/sql-reference/snowflake-scripting/exception>
3027
+ /// BigQuery: <https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#beginexceptionend>
3014
3028
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
3015
3029
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
3016
3030
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -3021,14 +3035,11 @@ pub struct ExceptionWhen {
3021
3035
3022
3036
impl Display for ExceptionWhen {
3023
3037
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
3024
- let idents = self
3025
- . idents
3026
- . iter ( )
3027
- . map ( ToString :: to_string)
3028
- . collect :: < Vec < _ > > ( )
3029
- . join ( " OR " ) ;
3030
-
3031
- write ! ( f, " WHEN {idents} THEN" , idents = idents) ?;
3038
+ write ! (
3039
+ f,
3040
+ " WHEN {idents} THEN" ,
3041
+ idents = display_separated( & self . idents, " OR " )
3042
+ ) ?;
3032
3043
3033
3044
if !self . statements . is_empty ( ) {
3034
3045
write ! ( f, " " ) ?;
@@ -3744,7 +3755,7 @@ pub enum Statement {
3744
3755
/// ```
3745
3756
/// <https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#beginexceptionend>
3746
3757
/// <https://docs.snowflake.com/en/sql-reference/snowflake-scripting/exception>
3747
- exception : Option < Exception > ,
3758
+ exception : Option < ExceptionClause > ,
3748
3759
/// TRUE if the statement has an `END` keyword.
3749
3760
has_end_keyword : bool ,
3750
3761
} ,
0 commit comments