-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description
The SQL parser requires DESC TABLE <name> or DESCRIBE TABLE <name> with the TABLE keyword mandatory. However, tools like Apache Superset send DESC <name> without the TABLE keyword, which is the standard MySQL/PostgreSQL syntax.
Similarly, DESC <view_name> should work for materialized views when no qualifier is provided.
Example
-- Currently accepted
DESC TABLE ecommerce
DESCRIBE TABLE ecommerce
-- Should also be accepted (TABLE keyword optional)
DESC ecommerce
DESCRIBE ecommerceExpected Behaviour
The TABLE keyword should be optional in DESCRIBE/DESC statements. When omitted, the parser should default to describing a table (or resolve to a materialized view if no table matches).
Impact
- Superset compatibility: Superset sends
DESC <name>via SQL Lab, which fails with a parse error - User convenience:
DESC ecommerceis the most natural syntax - MySQL/PostgreSQL parity: both accept
DESC <name>without qualifier
Implementation Notes
Parser change
In Parser.scala, make TABLE optional in describeTable:
def describeTable: PackratParser[DescribeTable] =
(("DESCRIBE" | "DESC") ~ opt("TABLE")) ~ ident ^^ { case _ ~ table =>
DescribeTable(table)
}Grammar ordering (critical)
In dqlStatement, the describe parsers must be reordered so that more specific forms are tried before the now-generic describeTable:
describeMaterializedView | // DESC MATERIALIZED VIEW x — most specific
describePipeline | // DESC PIPELINE x
describeTable | // DESC [TABLE] x — least specific (fallback)Without this reordering, DESC PIPELINE foo would be incorrectly captured by describeTable (treating PIPELINE as a table name).
Current order in dqlStatement
describeTable | // line 910
...
describePipeline | // line 914
...
describeMaterializedView // line 919
Required order
describeMaterializedView |
describePipeline |
describeTable |
Files to modify
| File | Change |
|---|---|
sql/.../parser/Parser.scala |
Make TABLE optional in describeTable, reorder describe parsers in dqlStatement |
Tests
- Parser unit test:
DESC ecommerceparses asDescribeTable("ecommerce") - Parser unit test:
DESC TABLE ecommercestill parses asDescribeTable("ecommerce") - Parser unit test:
DESC PIPELINE mypipestill parses asDescribePipeline("mypipe") - Parser unit test:
DESC MATERIALIZED VIEW myviewstill parses asDescribeMaterializedView("myview")