mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
Fix CREATE FUNCTION
round trip for Hive dialect (#1693)
This commit is contained in:
parent
a7e984099f
commit
9c384a9194
3 changed files with 8 additions and 11 deletions
|
@ -2011,8 +2011,6 @@ impl fmt::Display for CreateFunction {
|
||||||
)?;
|
)?;
|
||||||
if let Some(args) = &self.args {
|
if let Some(args) = &self.args {
|
||||||
write!(f, "({})", display_comma_separated(args))?;
|
write!(f, "({})", display_comma_separated(args))?;
|
||||||
} else {
|
|
||||||
write!(f, "()")?;
|
|
||||||
}
|
}
|
||||||
if let Some(return_type) = &self.return_type {
|
if let Some(return_type) = &self.return_type {
|
||||||
write!(f, " RETURNS {return_type}")?;
|
write!(f, " RETURNS {return_type}")?;
|
||||||
|
|
|
@ -4553,14 +4553,13 @@ impl<'a> Parser<'a> {
|
||||||
temporary: bool,
|
temporary: bool,
|
||||||
) -> Result<Statement, ParserError> {
|
) -> Result<Statement, ParserError> {
|
||||||
let name = self.parse_object_name(false)?;
|
let name = self.parse_object_name(false)?;
|
||||||
self.expect_token(&Token::LParen)?;
|
|
||||||
let args = if self.consume_token(&Token::RParen) {
|
|
||||||
self.prev_token();
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(self.parse_comma_separated(Parser::parse_function_arg)?)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
self.expect_token(&Token::LParen)?;
|
||||||
|
let args = if Token::RParen != self.peek_token_ref().token {
|
||||||
|
self.parse_comma_separated(Parser::parse_function_arg)?
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
self.expect_token(&Token::RParen)?;
|
self.expect_token(&Token::RParen)?;
|
||||||
|
|
||||||
let return_type = if self.parse_keyword(Keyword::RETURNS) {
|
let return_type = if self.parse_keyword(Keyword::RETURNS) {
|
||||||
|
@ -4656,7 +4655,7 @@ impl<'a> Parser<'a> {
|
||||||
or_replace,
|
or_replace,
|
||||||
temporary,
|
temporary,
|
||||||
name,
|
name,
|
||||||
args,
|
args: Some(args),
|
||||||
return_type,
|
return_type,
|
||||||
behavior: body.behavior,
|
behavior: body.behavior,
|
||||||
called_on_null: body.called_on_null,
|
called_on_null: body.called_on_null,
|
||||||
|
|
|
@ -5147,7 +5147,7 @@ fn parse_trigger_related_functions() {
|
||||||
temporary: false,
|
temporary: false,
|
||||||
if_not_exists: false,
|
if_not_exists: false,
|
||||||
name: ObjectName::from(vec![Ident::new("emp_stamp")]),
|
name: ObjectName::from(vec![Ident::new("emp_stamp")]),
|
||||||
args: None,
|
args: Some(vec![]),
|
||||||
return_type: Some(DataType::Trigger),
|
return_type: Some(DataType::Trigger),
|
||||||
function_body: Some(
|
function_body: Some(
|
||||||
CreateFunctionBody::AsBeforeOptions(
|
CreateFunctionBody::AsBeforeOptions(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue