Fix CREATE FUNCTION round trip for Hive dialect (#1693)

This commit is contained in:
Ifeanyi Ubah 2025-01-30 23:45:31 +01:00 committed by GitHub
parent a7e984099f
commit 9c384a9194
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 11 deletions

View file

@ -2011,8 +2011,6 @@ impl fmt::Display for CreateFunction {
)?;
if let Some(args) = &self.args {
write!(f, "({})", display_comma_separated(args))?;
} else {
write!(f, "()")?;
}
if let Some(return_type) = &self.return_type {
write!(f, " RETURNS {return_type}")?;

View file

@ -4553,14 +4553,13 @@ impl<'a> Parser<'a> {
temporary: bool,
) -> Result<Statement, ParserError> {
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)?;
let return_type = if self.parse_keyword(Keyword::RETURNS) {
@ -4656,7 +4655,7 @@ impl<'a> Parser<'a> {
or_replace,
temporary,
name,
args,
args: Some(args),
return_type,
behavior: body.behavior,
called_on_null: body.called_on_null,

View file

@ -5147,7 +5147,7 @@ fn parse_trigger_related_functions() {
temporary: false,
if_not_exists: false,
name: ObjectName::from(vec![Ident::new("emp_stamp")]),
args: None,
args: Some(vec![]),
return_type: Some(DataType::Trigger),
function_body: Some(
CreateFunctionBody::AsBeforeOptions(