Skip to content

Commit 0903a27

Browse files
authored
Merge branch 'main' into DanCodedThis/show-objects-statement
2 parents 0a4fcd2 + 443f492 commit 0903a27

File tree

14 files changed

+928
-206
lines changed

14 files changed

+928
-206
lines changed

src/ast/ddl.rs

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ use sqlparser_derive::{Visit, VisitMut};
3030

3131
use crate::ast::value::escape_single_quote_string;
3232
use 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
};
3838
use crate::keywords::Keyword;
3939
use 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+
}

src/ast/helpers/stmt_data_loading.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub enum DataLoadingOptionType {
5858
STRING,
5959
BOOLEAN,
6060
ENUM,
61+
NUMBER,
6162
}
6263

6364
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -128,12 +129,9 @@ impl fmt::Display for DataLoadingOption {
128129
DataLoadingOptionType::STRING => {
129130
write!(f, "{}='{}'", self.option_name, self.value)?;
130131
}
131-
DataLoadingOptionType::ENUM => {
132-
// single quote is omitted
133-
write!(f, "{}={}", self.option_name, self.value)?;
134-
}
135-
DataLoadingOptionType::BOOLEAN => {
136-
// single quote is omitted
132+
DataLoadingOptionType::ENUM
133+
| DataLoadingOptionType::BOOLEAN
134+
| DataLoadingOptionType::NUMBER => {
137135
write!(f, "{}={}", self.option_name, self.value)?;
138136
}
139137
}

0 commit comments

Comments
 (0)