mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-27 13:46:10 +00:00
Add support of EXPLAIN QUERY PLAN syntax for SQLite dialect (#1458)
This commit is contained in:
parent
ac956dc963
commit
7905fb4905
4 changed files with 46 additions and 0 deletions
|
|
@ -3111,6 +3111,11 @@ pub enum Statement {
|
|||
analyze: bool,
|
||||
// Display additional information regarding the plan.
|
||||
verbose: bool,
|
||||
/// `EXPLAIN QUERY PLAN`
|
||||
/// Display the query plan without running the query.
|
||||
///
|
||||
/// [SQLite](https://sqlite.org/lang_explain.html)
|
||||
query_plan: bool,
|
||||
/// A SQL query that specifies what to explain
|
||||
statement: Box<Statement>,
|
||||
/// Optional output format of explain
|
||||
|
|
@ -3302,12 +3307,16 @@ impl fmt::Display for Statement {
|
|||
describe_alias,
|
||||
verbose,
|
||||
analyze,
|
||||
query_plan,
|
||||
statement,
|
||||
format,
|
||||
options,
|
||||
} => {
|
||||
write!(f, "{describe_alias} ")?;
|
||||
|
||||
if *query_plan {
|
||||
write!(f, "QUERY PLAN ")?;
|
||||
}
|
||||
if *analyze {
|
||||
write!(f, "ANALYZE ")?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -572,6 +572,7 @@ define_keywords!(
|
|||
PERSISTENT,
|
||||
PIVOT,
|
||||
PLACING,
|
||||
PLAN,
|
||||
PLANS,
|
||||
POLICY,
|
||||
PORTION,
|
||||
|
|
|
|||
|
|
@ -8662,6 +8662,7 @@ impl<'a> Parser<'a> {
|
|||
) -> Result<Statement, ParserError> {
|
||||
let mut analyze = false;
|
||||
let mut verbose = false;
|
||||
let mut query_plan = false;
|
||||
let mut format = None;
|
||||
let mut options = None;
|
||||
|
||||
|
|
@ -8672,6 +8673,8 @@ impl<'a> Parser<'a> {
|
|||
&& self.peek_token().token == Token::LParen
|
||||
{
|
||||
options = Some(self.parse_utility_options()?)
|
||||
} else if self.parse_keywords(&[Keyword::QUERY, Keyword::PLAN]) {
|
||||
query_plan = true;
|
||||
} else {
|
||||
analyze = self.parse_keyword(Keyword::ANALYZE);
|
||||
verbose = self.parse_keyword(Keyword::VERBOSE);
|
||||
|
|
@ -8688,6 +8691,7 @@ impl<'a> Parser<'a> {
|
|||
describe_alias,
|
||||
analyze,
|
||||
verbose,
|
||||
query_plan,
|
||||
statement: Box::new(statement),
|
||||
format,
|
||||
options,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue