mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 15:04:04 +00:00
Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax
Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax
This commit is contained in:
parent
cbd3c6b1a1
commit
17f2930885
5 changed files with 156 additions and 11 deletions
|
@ -131,6 +131,7 @@ impl<'a> Parser<'a> {
|
|||
pub fn parse_statement(&mut self) -> Result<Statement, ParserError> {
|
||||
match self.next_token() {
|
||||
Token::Word(w) => match w.keyword {
|
||||
Keyword::EXPLAIN => Ok(self.parse_explain()?),
|
||||
Keyword::SELECT | Keyword::WITH | Keyword::VALUES => {
|
||||
self.prev_token();
|
||||
Ok(Statement::Query(Box::new(self.parse_query()?)))
|
||||
|
@ -1790,6 +1791,19 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn parse_explain(&mut self) -> Result<Statement, ParserError> {
|
||||
let analyze = self.parse_keyword(Keyword::ANALYZE);
|
||||
let verbose = self.parse_keyword(Keyword::VERBOSE);
|
||||
|
||||
let statement = Box::new(self.parse_statement()?);
|
||||
|
||||
Ok(Statement::Explain {
|
||||
analyze,
|
||||
verbose,
|
||||
statement,
|
||||
})
|
||||
}
|
||||
|
||||
/// Parse a query expression, i.e. a `SELECT` statement optionally
|
||||
/// preceeded with some `WITH` CTE declarations and optionally followed
|
||||
/// by `ORDER BY`. Unlike some other parse_... methods, this one doesn't
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue