@@ -30,10 +30,10 @@ use sqlparser_derive::{Visit, VisitMut};
3030
3131use crate :: ast:: value:: escape_single_quote_string;
3232use crate :: ast:: {
33- display_comma_separated, display_separated, CreateFunctionBody , CreateFunctionUsing , DataType ,
34- Expr , FunctionBehavior , FunctionCalledOnNull , FunctionDeterminismSpecifier , FunctionParallel ,
35- Ident , MySQLColumnPosition , ObjectName , OperateFunctionArg , OrderByExpr , ProjectionSelect ,
36- SequenceOptions , SqlOption , Tag , Value ,
33+ display_comma_separated, display_separated, CommentDef , CreateFunctionBody ,
34+ CreateFunctionUsing , DataType , Expr , FunctionBehavior , FunctionCalledOnNull ,
35+ FunctionDeterminismSpecifier , FunctionParallel , Ident , MySQLColumnPosition , ObjectName ,
36+ OperateFunctionArg , OrderByExpr , ProjectionSelect , SequenceOptions , SqlOption , Tag , Value ,
3737} ;
3838use crate :: keywords:: Keyword ;
3939use crate :: tokenizer:: Token ;
@@ -338,6 +338,23 @@ impl fmt::Display for Owner {
338338 }
339339}
340340
341+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
342+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
343+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
344+ pub enum AlterConnectorOwner {
345+ User ( Ident ) ,
346+ Role ( Ident ) ,
347+ }
348+
349+ impl fmt:: Display for AlterConnectorOwner {
350+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
351+ match self {
352+ AlterConnectorOwner :: User ( ident) => write ! ( f, "USER {ident}" ) ,
353+ AlterConnectorOwner :: Role ( ident) => write ! ( f, "ROLE {ident}" ) ,
354+ }
355+ }
356+ }
357+
341358#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
342359#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
343360#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -2055,3 +2072,61 @@ impl fmt::Display for CreateFunction {
20552072 Ok ( ( ) )
20562073 }
20572074}
2075+
2076+ /// ```sql
2077+ /// CREATE CONNECTOR [IF NOT EXISTS] connector_name
2078+ /// [TYPE datasource_type]
2079+ /// [URL datasource_url]
2080+ /// [COMMENT connector_comment]
2081+ /// [WITH DCPROPERTIES(property_name=property_value, ...)]
2082+ /// ```
2083+ ///
2084+ /// [Hive](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27362034#LanguageManualDDL-CreateDataConnectorCreateConnector)
2085+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
2086+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
2087+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
2088+ pub struct CreateConnector {
2089+ pub name : Ident ,
2090+ pub if_not_exists : bool ,
2091+ pub connector_type : Option < String > ,
2092+ pub url : Option < String > ,
2093+ pub comment : Option < CommentDef > ,
2094+ pub with_dcproperties : Option < Vec < SqlOption > > ,
2095+ }
2096+
2097+ impl fmt:: Display for CreateConnector {
2098+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2099+ write ! (
2100+ f,
2101+ "CREATE CONNECTOR {if_not_exists}{name}" ,
2102+ if_not_exists = if self . if_not_exists {
2103+ "IF NOT EXISTS "
2104+ } else {
2105+ ""
2106+ } ,
2107+ name = self . name,
2108+ ) ?;
2109+
2110+ if let Some ( connector_type) = & self . connector_type {
2111+ write ! ( f, " TYPE '{connector_type}'" ) ?;
2112+ }
2113+
2114+ if let Some ( url) = & self . url {
2115+ write ! ( f, " URL '{url}'" ) ?;
2116+ }
2117+
2118+ if let Some ( comment) = & self . comment {
2119+ write ! ( f, " COMMENT = '{comment}'" ) ?;
2120+ }
2121+
2122+ if let Some ( with_dcproperties) = & self . with_dcproperties {
2123+ write ! (
2124+ f,
2125+ " WITH DCPROPERTIES({})" ,
2126+ display_comma_separated( with_dcproperties)
2127+ ) ?;
2128+ }
2129+
2130+ Ok ( ( ) )
2131+ }
2132+ }
0 commit comments