@@ -47,7 +47,7 @@ pub use self::dcl::{AlterRoleOperation, ResetConfig, RoleOption, SetConfigValue,
47
47
pub use self :: ddl:: {
48
48
AlterColumnOperation , AlterIndexOperation , AlterPolicyOperation , AlterTableOperation ,
49
49
ClusteredBy , ColumnDef , ColumnOption , ColumnOptionDef , ColumnPolicy , ColumnPolicyProperty ,
50
- ConstraintCharacteristics , Deduplicate , DeferrableInitial , GeneratedAs ,
50
+ ConstraintCharacteristics , CreateFunction , Deduplicate , DeferrableInitial , GeneratedAs ,
51
51
GeneratedExpressionMode , IdentityParameters , IdentityProperty , IdentityPropertyFormatKind ,
52
52
IdentityPropertyKind , IdentityPropertyOrder , IndexOption , IndexType , KeyOrIndexDisplay , Owner ,
53
53
Partition , ProcedureParam , ReferentialAction , TableConstraint , TagsColumnOption ,
@@ -897,7 +897,7 @@ pub enum Expr {
897
897
/// Example:
898
898
///
899
899
/// ```sql
900
- /// SELECT (SELECT ',' + name FROM sys.objects FOR XML PATH(''), TYPE).value('.','NVARCHAR(MAX)')
900
+ /// SELECT (SELECT ',' + name FROM sys.objects FOR XML PATH(''), TYPE).value('.','NVARCHAR(MAX)')
901
901
/// SELECT CONVERT(XML,'<Book>abc</Book>').value('.','NVARCHAR(MAX)').value('.','NVARCHAR(MAX)')
902
902
/// ```
903
903
///
@@ -3003,64 +3003,7 @@ pub enum Statement {
3003
3003
/// 1. [Hive](https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl#LanguageManualDDL-Create/Drop/ReloadFunction)
3004
3004
/// 2. [Postgres](https://www.postgresql.org/docs/15/sql-createfunction.html)
3005
3005
/// 3. [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_function_statement)
3006
- CreateFunction {
3007
- or_replace : bool ,
3008
- temporary : bool ,
3009
- if_not_exists : bool ,
3010
- name : ObjectName ,
3011
- args : Option < Vec < OperateFunctionArg > > ,
3012
- return_type : Option < DataType > ,
3013
- /// The expression that defines the function.
3014
- ///
3015
- /// Examples:
3016
- /// ```sql
3017
- /// AS ((SELECT 1))
3018
- /// AS "console.log();"
3019
- /// ```
3020
- function_body : Option < CreateFunctionBody > ,
3021
- /// Behavior attribute for the function
3022
- ///
3023
- /// IMMUTABLE | STABLE | VOLATILE
3024
- ///
3025
- /// [Postgres](https://www.postgresql.org/docs/current/sql-createfunction.html)
3026
- behavior : Option < FunctionBehavior > ,
3027
- /// CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
3028
- ///
3029
- /// [Postgres](https://www.postgresql.org/docs/current/sql-createfunction.html)
3030
- called_on_null : Option < FunctionCalledOnNull > ,
3031
- /// PARALLEL { UNSAFE | RESTRICTED | SAFE }
3032
- ///
3033
- /// [Postgres](https://www.postgresql.org/docs/current/sql-createfunction.html)
3034
- parallel : Option < FunctionParallel > ,
3035
- /// USING ... (Hive only)
3036
- using : Option < CreateFunctionUsing > ,
3037
- /// Language used in a UDF definition.
3038
- ///
3039
- /// Example:
3040
- /// ```sql
3041
- /// CREATE FUNCTION foo() LANGUAGE js AS "console.log();"
3042
- /// ```
3043
- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_a_javascript_udf)
3044
- language : Option < Ident > ,
3045
- /// Determinism keyword used for non-sql UDF definitions.
3046
- ///
3047
- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_11)
3048
- determinism_specifier : Option < FunctionDeterminismSpecifier > ,
3049
- /// List of options for creating the function.
3050
- ///
3051
- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_11)
3052
- options : Option < Vec < SqlOption > > ,
3053
- /// Connection resource for a remote function.
3054
- ///
3055
- /// Example:
3056
- /// ```sql
3057
- /// CREATE FUNCTION foo()
3058
- /// RETURNS FLOAT64
3059
- /// REMOTE WITH CONNECTION us.myconnection
3060
- /// ```
3061
- /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_a_remote_function)
3062
- remote_connection : Option < ObjectName > ,
3063
- } ,
3006
+ CreateFunction ( CreateFunction ) ,
3064
3007
/// CREATE TRIGGER
3065
3008
///
3066
3009
/// Examples:
@@ -3826,75 +3769,7 @@ impl fmt::Display for Statement {
3826
3769
}
3827
3770
Ok ( ( ) )
3828
3771
}
3829
- Statement :: CreateFunction {
3830
- or_replace,
3831
- temporary,
3832
- if_not_exists,
3833
- name,
3834
- args,
3835
- return_type,
3836
- function_body,
3837
- language,
3838
- behavior,
3839
- called_on_null,
3840
- parallel,
3841
- using,
3842
- determinism_specifier,
3843
- options,
3844
- remote_connection,
3845
- } => {
3846
- write ! (
3847
- f,
3848
- "CREATE {or_replace}{temp}FUNCTION {if_not_exists}{name}" ,
3849
- temp = if * temporary { "TEMPORARY " } else { "" } ,
3850
- or_replace = if * or_replace { "OR REPLACE " } else { "" } ,
3851
- if_not_exists = if * if_not_exists { "IF NOT EXISTS " } else { "" } ,
3852
- ) ?;
3853
- if let Some ( args) = args {
3854
- write ! ( f, "({})" , display_comma_separated( args) ) ?;
3855
- }
3856
- if let Some ( return_type) = return_type {
3857
- write ! ( f, " RETURNS {return_type}" ) ?;
3858
- }
3859
- if let Some ( determinism_specifier) = determinism_specifier {
3860
- write ! ( f, " {determinism_specifier}" ) ?;
3861
- }
3862
- if let Some ( language) = language {
3863
- write ! ( f, " LANGUAGE {language}" ) ?;
3864
- }
3865
- if let Some ( behavior) = behavior {
3866
- write ! ( f, " {behavior}" ) ?;
3867
- }
3868
- if let Some ( called_on_null) = called_on_null {
3869
- write ! ( f, " {called_on_null}" ) ?;
3870
- }
3871
- if let Some ( parallel) = parallel {
3872
- write ! ( f, " {parallel}" ) ?;
3873
- }
3874
- if let Some ( remote_connection) = remote_connection {
3875
- write ! ( f, " REMOTE WITH CONNECTION {remote_connection}" ) ?;
3876
- }
3877
- if let Some ( CreateFunctionBody :: AsBeforeOptions ( function_body) ) = function_body {
3878
- write ! ( f, " AS {function_body}" ) ?;
3879
- }
3880
- if let Some ( CreateFunctionBody :: Return ( function_body) ) = function_body {
3881
- write ! ( f, " RETURN {function_body}" ) ?;
3882
- }
3883
- if let Some ( using) = using {
3884
- write ! ( f, " {using}" ) ?;
3885
- }
3886
- if let Some ( options) = options {
3887
- write ! (
3888
- f,
3889
- " OPTIONS({})" ,
3890
- display_comma_separated( options. as_slice( ) )
3891
- ) ?;
3892
- }
3893
- if let Some ( CreateFunctionBody :: AsAfterOptions ( function_body) ) = function_body {
3894
- write ! ( f, " AS {function_body}" ) ?;
3895
- }
3896
- Ok ( ( ) )
3897
- }
3772
+ Statement :: CreateFunction ( create_function) => create_function. fmt ( f) ,
3898
3773
Statement :: CreateTrigger {
3899
3774
or_replace,
3900
3775
is_constraint,
0 commit comments