@@ -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 ,
@@ -885,7 +885,7 @@ pub enum Expr {
885
885
/// Example:
886
886
///
887
887
/// ```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)')
889
889
/// SELECT CONVERT(XML,'<Book>abc</Book>').value('.','NVARCHAR(MAX)').value('.','NVARCHAR(MAX)')
890
890
/// ```
891
891
///
@@ -2989,64 +2989,7 @@ pub enum Statement {
2989
2989
/// 1. [Hive](https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl#LanguageManualDDL-Create/Drop/ReloadFunction)
2990
2990
/// 2. [Postgres](https://www.postgresql.org/docs/15/sql-createfunction.html)
2991
2991
/// 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 ) ,
3050
2993
/// CREATE TRIGGER
3051
2994
///
3052
2995
/// Examples:
@@ -3812,75 +3755,7 @@ impl fmt::Display for Statement {
3812
3755
}
3813
3756
Ok ( ( ) )
3814
3757
}
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) ,
3884
3759
Statement :: CreateTrigger {
3885
3760
or_replace,
3886
3761
is_constraint,
0 commit comments