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:
Dmitry Patsura 2021-09-09 18:49:33 +03:00 committed by GitHub
parent d8adb1708c
commit d2d4fc0c58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 10 deletions

View file

@ -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);