-
Notifications
You must be signed in to change notification settings - Fork 605
feat: support explain options #1426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Update my code. Please review again @iffyio Thank you. |
src/parser/mod.rs
Outdated
@@ -1274,6 +1274,29 @@ impl<'a> Parser<'a> { | |||
} | |||
} | |||
|
|||
pub fn parse_utility_option_list(&mut self) -> Result<Vec<UtilityOption>, ParserError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn parse_utility_option_list(&mut self) -> Result<Vec<UtilityOption>, ParserError> { | |
pub fn parse_utility_options(&mut self) -> Result<Vec<UtilityOption>, ParserError> { |
src/parser/mod.rs
Outdated
// Note: DuckDB is compatible with PostgreSQL syntax for this statement, | ||
// although not all features may be implemented. | ||
if describe_alias == DescribeAlias::Explain | ||
&& dialect_of!(self is PostgreSqlDialect | DuckDbDialect | GenericDialect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& dialect_of!(self is PostgreSqlDialect | DuckDbDialect | GenericDialect) | |
&& self.dialect.supports_explain_with_utility_options() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated. thank you
tests/sqlparser_common.rs
Outdated
run_explain_analyze_with_specific_dialect( | ||
|_d| true, | ||
query, | ||
expected_verbose, | ||
expected_analyze, | ||
expected_format, | ||
exepcted_options, | ||
) | ||
} | ||
|
||
fn run_explain_analyze_with_specific_dialect<T: Fn(&dyn Dialect) -> bool>( | ||
dialect_predicate: T, | ||
query: &str, | ||
expected_verbose: bool, | ||
expected_analyze: bool, | ||
expected_format: Option<AnalyzeFormat>, | ||
exepcted_options: Option<Vec<UtilityOption>>, | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of having two functions, we can reuse the existing run_explain_analyze
and have that one take in a dialect: TestedDialects
as the argument (instead of a lambda), then the existing tests can pass in all_dialects()
while the new tests pass in all_dialects_where(|d| d.supports_option_list())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
src/test_utils.rs
Outdated
/// Ensures that `sql` parses as a single [Statement] and that the re-serialization of the parsed | ||
/// result matches the given `canonical` SQL string. | ||
pub fn verified_stmt_with_canonical(&self, sql: &str, canonical: &str) -> Statement { | ||
self.one_statement_parses_to(sql, canonical) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Ensures that `sql` parses as a single [Statement] and that the re-serialization of the parsed | |
/// result matches the given `canonical` SQL string. | |
pub fn verified_stmt_with_canonical(&self, sql: &str, canonical: &str) -> Statement { | |
self.one_statement_parses_to(sql, canonical) | |
} |
this looks unused and we can remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! cc @alamb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -7116,6 +7123,47 @@ where | |||
} | |||
} | |||
|
|||
/// Represents a single PostgreSQL utility option. | |||
/// | |||
/// A utility option is a key-value pair where the key is an identifier (IDENT) and the value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Looks like there are some small CI issues to address |
Pull Request Test Coverage Report for Build 10942458377Details
💛 - Coveralls |
…dd Explain describe_alias check
d935ebe
to
b5bb4f2
Compare
Fixes the CI issues @alamb . |
support
EXPLAIN [ ( option [, ...] ) ] statement
close #1425