diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 6c279518e..a6654be0e 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -1144,6 +1144,10 @@ pub enum Statement { /// /// Note: this is a MySQL-specific statement. SetNamesDefault {}, + /// SHOW FUNCTIONS + /// + /// Note: this is a Presto-specific statement. + ShowFunctions { filter: Option }, /// SHOW /// /// Note: this is a PostgreSQL-specific statement. @@ -2033,6 +2037,13 @@ impl fmt::Display for Statement { } Ok(()) } + Statement::ShowFunctions { filter } => { + write!(f, "SHOW FUNCTIONS")?; + if let Some(filter) = filter { + write!(f, " {}", filter)?; + } + Ok(()) + } Statement::Use { db_name } => { write!(f, "USE {}", db_name)?; Ok(()) diff --git a/src/keywords.rs b/src/keywords.rs index 30ec735f7..2fa79855b 100644 --- a/src/keywords.rs +++ b/src/keywords.rs @@ -250,6 +250,7 @@ define_keywords!( FROM, FULL, FUNCTION, + FUNCTIONS, FUSION, GET, GLOBAL, diff --git a/src/parser.rs b/src/parser.rs index 968b1a5dd..a9ee5b0e4 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -3854,6 +3854,8 @@ impl<'a> Parser<'a> { Ok(self.parse_show_columns(extended, full)?) } else if self.parse_keyword(Keyword::TABLES) { Ok(self.parse_show_tables(extended, full)?) + } else if self.parse_keyword(Keyword::FUNCTIONS) { + Ok(self.parse_show_functions()?) } else if extended || full { Err(ParserError::ParserError( "EXTENDED/FULL are not supported with this type of SHOW query".to_string(), @@ -3945,6 +3947,11 @@ impl<'a> Parser<'a> { }) } + pub fn parse_show_functions(&mut self) -> Result { + let filter = self.parse_show_statement_filter()?; + Ok(Statement::ShowFunctions { filter }) + } + pub fn parse_show_collation(&mut self) -> Result { let filter = self.parse_show_statement_filter()?; Ok(Statement::ShowCollation { filter }) diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index d2d2646cd..7fb71ea94 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -5569,3 +5569,13 @@ fn parse_cursor() { _ => unreachable!(), } } + +#[test] +fn parse_show_functions() { + assert_eq!( + verified_stmt("SHOW FUNCTIONS LIKE 'pattern'"), + Statement::ShowFunctions { + filter: Some(ShowStatementFilter::Like("pattern".into())), + } + ); +}