mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-30 06:47:17 +00:00
Allow to use the TABLE keyword in DESC|DESCRIBE|EXPLAIN TABLE statement (#1351)
This commit is contained in:
parent
547d82f07d
commit
7fdb2ec5d1
3 changed files with 42 additions and 12 deletions
|
|
@ -2699,6 +2699,11 @@ pub enum Statement {
|
|||
describe_alias: DescribeAlias,
|
||||
/// Hive style `FORMATTED | EXTENDED`
|
||||
hive_format: Option<HiveDescribeFormat>,
|
||||
/// Snowflake and ClickHouse support `DESC|DESCRIBE TABLE <table_name>` syntax
|
||||
///
|
||||
/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/desc-table.html)
|
||||
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/describe-table)
|
||||
has_table_keyword: bool,
|
||||
/// Table name
|
||||
#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
|
||||
table_name: ObjectName,
|
||||
|
|
@ -2872,6 +2877,7 @@ impl fmt::Display for Statement {
|
|||
Statement::ExplainTable {
|
||||
describe_alias,
|
||||
hive_format,
|
||||
has_table_keyword,
|
||||
table_name,
|
||||
} => {
|
||||
write!(f, "{describe_alias} ")?;
|
||||
|
|
@ -2879,6 +2885,9 @@ impl fmt::Display for Statement {
|
|||
if let Some(format) = hive_format {
|
||||
write!(f, "{} ", format)?;
|
||||
}
|
||||
if *has_table_keyword {
|
||||
write!(f, "TABLE ")?;
|
||||
}
|
||||
|
||||
write!(f, "{table_name}")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7972,10 +7972,13 @@ impl<'a> Parser<'a> {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
// only allow to use TABLE keyword for DESC|DESCRIBE statement
|
||||
let has_table_keyword = self.parse_keyword(Keyword::TABLE);
|
||||
let table_name = self.parse_object_name(false)?;
|
||||
Ok(Statement::ExplainTable {
|
||||
describe_alias,
|
||||
hive_format,
|
||||
has_table_keyword,
|
||||
table_name,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue