mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-26 00:44:12 +00:00
Support SHOW FUNCTIONS
(#620)
* support SHOW FUNCTIONS * Update keywords.rs * Update mod.rs * Update sqlparser_common.rs * Fix CI issues
This commit is contained in:
parent
fccae77c5e
commit
495ab59aad
4 changed files with 29 additions and 0 deletions
|
@ -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<ShowStatementFilter> },
|
||||
/// SHOW <variable>
|
||||
///
|
||||
/// 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(())
|
||||
|
|
|
@ -250,6 +250,7 @@ define_keywords!(
|
|||
FROM,
|
||||
FULL,
|
||||
FUNCTION,
|
||||
FUNCTIONS,
|
||||
FUSION,
|
||||
GET,
|
||||
GLOBAL,
|
||||
|
|
|
@ -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<Statement, ParserError> {
|
||||
let filter = self.parse_show_statement_filter()?;
|
||||
Ok(Statement::ShowFunctions { filter })
|
||||
}
|
||||
|
||||
pub fn parse_show_collation(&mut self) -> Result<Statement, ParserError> {
|
||||
let filter = self.parse_show_statement_filter()?;
|
||||
Ok(Statement::ShowCollation { filter })
|
||||
|
|
|
@ -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())),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue