mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-09 21:42:05 +00:00
Added support for CREATE DOMAIN
(#1830)
This commit is contained in:
parent
a497358c3a
commit
ac1c339666
5 changed files with 183 additions and 6 deletions
|
@ -4625,6 +4625,8 @@ impl<'a> Parser<'a> {
|
|||
self.parse_create_external_table(or_replace)
|
||||
} else if self.parse_keyword(Keyword::FUNCTION) {
|
||||
self.parse_create_function(or_alter, or_replace, temporary)
|
||||
} else if self.parse_keyword(Keyword::DOMAIN) {
|
||||
self.parse_create_domain()
|
||||
} else if self.parse_keyword(Keyword::TRIGGER) {
|
||||
self.parse_create_trigger(or_alter, or_replace, false)
|
||||
} else if self.parse_keywords(&[Keyword::CONSTRAINT, Keyword::TRIGGER]) {
|
||||
|
@ -5974,6 +5976,35 @@ impl<'a> Parser<'a> {
|
|||
Ok(owner)
|
||||
}
|
||||
|
||||
/// Parses a [Statement::CreateDomain] statement.
|
||||
fn parse_create_domain(&mut self) -> Result<Statement, ParserError> {
|
||||
let name = self.parse_object_name(false)?;
|
||||
self.expect_keyword_is(Keyword::AS)?;
|
||||
let data_type = self.parse_data_type()?;
|
||||
let collation = if self.parse_keyword(Keyword::COLLATE) {
|
||||
Some(self.parse_identifier()?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let default = if self.parse_keyword(Keyword::DEFAULT) {
|
||||
Some(self.parse_expr()?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut constraints = Vec::new();
|
||||
while let Some(constraint) = self.parse_optional_table_constraint()? {
|
||||
constraints.push(constraint);
|
||||
}
|
||||
|
||||
Ok(Statement::CreateDomain(CreateDomain {
|
||||
name,
|
||||
data_type,
|
||||
collation,
|
||||
default,
|
||||
constraints,
|
||||
}))
|
||||
}
|
||||
|
||||
/// ```sql
|
||||
/// CREATE POLICY name ON table_name [ AS { PERMISSIVE | RESTRICTIVE } ]
|
||||
/// [ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue