mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-26 08:54:06 +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.
|
/// Note: this is a MySQL-specific statement.
|
||||||
SetNamesDefault {},
|
SetNamesDefault {},
|
||||||
|
/// SHOW FUNCTIONS
|
||||||
|
///
|
||||||
|
/// Note: this is a Presto-specific statement.
|
||||||
|
ShowFunctions { filter: Option<ShowStatementFilter> },
|
||||||
/// SHOW <variable>
|
/// SHOW <variable>
|
||||||
///
|
///
|
||||||
/// Note: this is a PostgreSQL-specific statement.
|
/// Note: this is a PostgreSQL-specific statement.
|
||||||
|
@ -2033,6 +2037,13 @@ impl fmt::Display for Statement {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Statement::ShowFunctions { filter } => {
|
||||||
|
write!(f, "SHOW FUNCTIONS")?;
|
||||||
|
if let Some(filter) = filter {
|
||||||
|
write!(f, " {}", filter)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Statement::Use { db_name } => {
|
Statement::Use { db_name } => {
|
||||||
write!(f, "USE {}", db_name)?;
|
write!(f, "USE {}", db_name)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -250,6 +250,7 @@ define_keywords!(
|
||||||
FROM,
|
FROM,
|
||||||
FULL,
|
FULL,
|
||||||
FUNCTION,
|
FUNCTION,
|
||||||
|
FUNCTIONS,
|
||||||
FUSION,
|
FUSION,
|
||||||
GET,
|
GET,
|
||||||
GLOBAL,
|
GLOBAL,
|
||||||
|
|
|
@ -3854,6 +3854,8 @@ impl<'a> Parser<'a> {
|
||||||
Ok(self.parse_show_columns(extended, full)?)
|
Ok(self.parse_show_columns(extended, full)?)
|
||||||
} else if self.parse_keyword(Keyword::TABLES) {
|
} else if self.parse_keyword(Keyword::TABLES) {
|
||||||
Ok(self.parse_show_tables(extended, full)?)
|
Ok(self.parse_show_tables(extended, full)?)
|
||||||
|
} else if self.parse_keyword(Keyword::FUNCTIONS) {
|
||||||
|
Ok(self.parse_show_functions()?)
|
||||||
} else if extended || full {
|
} else if extended || full {
|
||||||
Err(ParserError::ParserError(
|
Err(ParserError::ParserError(
|
||||||
"EXTENDED/FULL are not supported with this type of SHOW query".to_string(),
|
"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> {
|
pub fn parse_show_collation(&mut self) -> Result<Statement, ParserError> {
|
||||||
let filter = self.parse_show_statement_filter()?;
|
let filter = self.parse_show_statement_filter()?;
|
||||||
Ok(Statement::ShowCollation { filter })
|
Ok(Statement::ShowCollation { filter })
|
||||||
|
|
|
@ -5569,3 +5569,13 @@ fn parse_cursor() {
|
||||||
_ => unreachable!(),
|
_ => 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