@@ -47,7 +47,7 @@ pub use self::dcl::{AlterRoleOperation, ResetConfig, RoleOption, SetConfigValue,
4747pub use self :: ddl:: {
4848 AlterColumnOperation , AlterIndexOperation , AlterPolicyOperation , AlterTableOperation ,
4949 ClusteredBy , ColumnDef , ColumnOption , ColumnOptionDef , ColumnPolicy , ColumnPolicyProperty ,
50- ConstraintCharacteristics , Deduplicate , DeferrableInitial , GeneratedAs ,
50+ ConstraintCharacteristics , CreateFunction , Deduplicate , DeferrableInitial , GeneratedAs ,
5151 GeneratedExpressionMode , IdentityParameters , IdentityProperty , IdentityPropertyFormatKind ,
5252 IdentityPropertyKind , IdentityPropertyOrder , IndexOption , IndexType , KeyOrIndexDisplay , Owner ,
5353 Partition , ProcedureParam , ReferentialAction , TableConstraint , TagsColumnOption ,
@@ -885,7 +885,7 @@ pub enum Expr {
885885 /// Example:
886886 ///
887887 /// ```sql
888- /// SELECT (SELECT ',' + name FROM sys.objects FOR XML PATH(''), TYPE).value('.','NVARCHAR(MAX)')
888+ /// SELECT (SELECT ',' + name FROM sys.objects FOR XML PATH(''), TYPE).value('.','NVARCHAR(MAX)')
889889 /// SELECT CONVERT(XML,'<Book>abc</Book>').value('.','NVARCHAR(MAX)').value('.','NVARCHAR(MAX)')
890890 /// ```
891891 ///
@@ -2989,64 +2989,7 @@ pub enum Statement {
29892989 /// 1. [Hive](https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl#LanguageManualDDL-Create/Drop/ReloadFunction)
29902990 /// 2. [Postgres](https://www.postgresql.org/docs/15/sql-createfunction.html)
29912991 /// 3. [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_function_statement)
2992- CreateFunction {
2993- or_replace : bool ,
2994- temporary : bool ,
2995- if_not_exists : bool ,
2996- name : ObjectName ,
2997- args : Option < Vec < OperateFunctionArg > > ,
2998- return_type : Option < DataType > ,
2999- /// The expression that defines the function.
3000- ///
3001- /// Examples:
3002- /// ```sql
3003- /// AS ((SELECT 1))
3004- /// AS "console.log();"
3005- /// ```
3006- function_body : Option < CreateFunctionBody > ,
3007- /// Behavior attribute for the function
3008- ///
3009- /// IMMUTABLE | STABLE | VOLATILE
3010- ///
3011- /// [Postgres](https://www.postgresql.org/docs/current/sql-createfunction.html)
3012- behavior : Option < FunctionBehavior > ,
3013- /// CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
3014- ///
3015- /// [Postgres](https://www.postgresql.org/docs/current/sql-createfunction.html)
3016- called_on_null : Option < FunctionCalledOnNull > ,
3017- /// PARALLEL { UNSAFE | RESTRICTED | SAFE }
3018- ///
3019- /// [Postgres](https://www.postgresql.org/docs/current/sql-createfunction.html)
3020- parallel : Option < FunctionParallel > ,
3021- /// USING ... (Hive only)
3022- using : Option < CreateFunctionUsing > ,
3023- /// Language used in a UDF definition.
3024- ///
3025- /// Example:
3026- /// ```sql
3027- /// CREATE FUNCTION foo() LANGUAGE js AS "console.log();"
3028- /// ```
3029- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_a_javascript_udf)
3030- language : Option < Ident > ,
3031- /// Determinism keyword used for non-sql UDF definitions.
3032- ///
3033- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_11)
3034- determinism_specifier : Option < FunctionDeterminismSpecifier > ,
3035- /// List of options for creating the function.
3036- ///
3037- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_11)
3038- options : Option < Vec < SqlOption > > ,
3039- /// Connection resource for a remote function.
3040- ///
3041- /// Example:
3042- /// ```sql
3043- /// CREATE FUNCTION foo()
3044- /// RETURNS FLOAT64
3045- /// REMOTE WITH CONNECTION us.myconnection
3046- /// ```
3047- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_a_remote_function)
3048- remote_connection : Option < ObjectName > ,
3049- } ,
2992+ CreateFunction ( CreateFunction ) ,
30502993 /// CREATE TRIGGER
30512994 ///
30522995 /// Examples:
@@ -3812,75 +3755,7 @@ impl fmt::Display for Statement {
38123755 }
38133756 Ok ( ( ) )
38143757 }
3815- Statement :: CreateFunction {
3816- or_replace,
3817- temporary,
3818- if_not_exists,
3819- name,
3820- args,
3821- return_type,
3822- function_body,
3823- language,
3824- behavior,
3825- called_on_null,
3826- parallel,
3827- using,
3828- determinism_specifier,
3829- options,
3830- remote_connection,
3831- } => {
3832- write ! (
3833- f,
3834- "CREATE {or_replace}{temp}FUNCTION {if_not_exists}{name}" ,
3835- temp = if * temporary { "TEMPORARY " } else { "" } ,
3836- or_replace = if * or_replace { "OR REPLACE " } else { "" } ,
3837- if_not_exists = if * if_not_exists { "IF NOT EXISTS " } else { "" } ,
3838- ) ?;
3839- if let Some ( args) = args {
3840- write ! ( f, "({})" , display_comma_separated( args) ) ?;
3841- }
3842- if let Some ( return_type) = return_type {
3843- write ! ( f, " RETURNS {return_type}" ) ?;
3844- }
3845- if let Some ( determinism_specifier) = determinism_specifier {
3846- write ! ( f, " {determinism_specifier}" ) ?;
3847- }
3848- if let Some ( language) = language {
3849- write ! ( f, " LANGUAGE {language}" ) ?;
3850- }
3851- if let Some ( behavior) = behavior {
3852- write ! ( f, " {behavior}" ) ?;
3853- }
3854- if let Some ( called_on_null) = called_on_null {
3855- write ! ( f, " {called_on_null}" ) ?;
3856- }
3857- if let Some ( parallel) = parallel {
3858- write ! ( f, " {parallel}" ) ?;
3859- }
3860- if let Some ( remote_connection) = remote_connection {
3861- write ! ( f, " REMOTE WITH CONNECTION {remote_connection}" ) ?;
3862- }
3863- if let Some ( CreateFunctionBody :: AsBeforeOptions ( function_body) ) = function_body {
3864- write ! ( f, " AS {function_body}" ) ?;
3865- }
3866- if let Some ( CreateFunctionBody :: Return ( function_body) ) = function_body {
3867- write ! ( f, " RETURN {function_body}" ) ?;
3868- }
3869- if let Some ( using) = using {
3870- write ! ( f, " {using}" ) ?;
3871- }
3872- if let Some ( options) = options {
3873- write ! (
3874- f,
3875- " OPTIONS({})" ,
3876- display_comma_separated( options. as_slice( ) )
3877- ) ?;
3878- }
3879- if let Some ( CreateFunctionBody :: AsAfterOptions ( function_body) ) = function_body {
3880- write ! ( f, " AS {function_body}" ) ?;
3881- }
3882- Ok ( ( ) )
3883- }
3758+ Statement :: CreateFunction ( create_function) => create_function. fmt ( f) ,
38843759 Statement :: CreateTrigger {
38853760 or_replace,
38863761 is_constraint,
0 commit comments