mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
feat: Support DESCRIBE table_name (#340)
* feat: Support DESCRIBE * feat: Support DESCRIBE table_name * Update src/ast/mod.rs Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> * Update src/ast/mod.rs Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> * Update src/ast/mod.rs Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
d8adb1708c
commit
d2d4fc0c58
3 changed files with 67 additions and 10 deletions
|
@ -1803,6 +1803,7 @@ fn parse_scalar_function_in_projection() {
|
|||
fn run_explain_analyze(query: &str, expected_verbose: bool, expected_analyze: bool) {
|
||||
match verified_stmt(query) {
|
||||
Statement::Explain {
|
||||
describe_alias: _,
|
||||
analyze,
|
||||
verbose,
|
||||
statement,
|
||||
|
@ -1815,8 +1816,28 @@ fn run_explain_analyze(query: &str, expected_verbose: bool, expected_analyze: bo
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_explain_table() {
|
||||
let validate_explain = |query: &str, expected_describe_alias: bool| match verified_stmt(query) {
|
||||
Statement::ExplainTable {
|
||||
describe_alias,
|
||||
table_name,
|
||||
} => {
|
||||
assert_eq!(describe_alias, expected_describe_alias);
|
||||
assert_eq!("test_identifier", table_name.to_string());
|
||||
}
|
||||
_ => panic!("Unexpected Statement, must be ExplainTable"),
|
||||
};
|
||||
|
||||
validate_explain("EXPLAIN test_identifier", false);
|
||||
validate_explain("DESCRIBE test_identifier", true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_explain_analyze_with_simple_select() {
|
||||
// Describe is an alias for EXPLAIN
|
||||
run_explain_analyze("DESCRIBE SELECT sqrt(id) FROM foo", false, false);
|
||||
|
||||
run_explain_analyze("EXPLAIN SELECT sqrt(id) FROM foo", false, false);
|
||||
run_explain_analyze("EXPLAIN VERBOSE SELECT sqrt(id) FROM foo", true, false);
|
||||
run_explain_analyze("EXPLAIN ANALYZE SELECT sqrt(id) FROM foo", false, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue