Skip to content

Commit bb62bf8

Browse files
committed
Snowflake: parse DESCRIBE/DESC RESULT <query_id>
Add Statement::DescribeResult carrying a general expression argument so both DESCRIBE RESULT '<id>' (string literal) and DESCRIBE RESULT LAST_QUERY_ID() (function call) parse under SnowflakeDialect.
1 parent 16cedc5 commit bb62bf8

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/ast/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5216,6 +5216,19 @@ pub enum Statement {
52165216
object_name: ObjectName,
52175217
},
52185218
/// ```sql
5219+
/// DESC | DESCRIBE RESULT <query_id>
5220+
/// ```
5221+
/// Snowflake-style `DESCRIBE RESULT '<query_id>'`, returning the column
5222+
/// metadata of a previously executed query's result set. The argument is a
5223+
/// general expression covering a string literal (`'01b...'`) and a function
5224+
/// call (`LAST_QUERY_ID()`).
5225+
DescribeResult {
5226+
/// `DESC` or `DESCRIBE`
5227+
describe_alias: DescribeAlias,
5228+
/// The query-id argument.
5229+
query_id: Box<Expr>,
5230+
},
5231+
/// ```sql
52195232
/// [EXPLAIN | DESC | DESCRIBE] <statement>
52205233
/// ```
52215234
Explain {
@@ -5754,6 +5767,12 @@ impl fmt::Display for Statement {
57545767
} => {
57555768
write!(f, "{describe_alias} {object_type} {object_name}")
57565769
}
5770+
Statement::DescribeResult {
5771+
describe_alias,
5772+
query_id,
5773+
} => {
5774+
write!(f, "{describe_alias} RESULT {query_id}")
5775+
}
57575776
Statement::Explain {
57585777
describe_alias,
57595778
verbose,

src/ast/spans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ impl Spanned for Statement {
476476
Statement::Kill { .. } => Span::empty(),
477477
Statement::ExplainTable { .. } => Span::empty(),
478478
Statement::DescribeObject { .. } => Span::empty(),
479+
Statement::DescribeResult { .. } => Span::empty(),
479480
Statement::Explain { .. } => Span::empty(),
480481
Statement::Savepoint { .. } => Span::empty(),
481482
Statement::ReleaseSavepoint { .. } => Span::empty(),

src/parser/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14549,6 +14549,13 @@ impl<'a> Parser<'a> {
1454914549
DescribeAlias::Desc | DescribeAlias::Describe
1455014550
)
1455114551
{
14552+
if self.parse_keyword(Keyword::RESULT) {
14553+
let query_id = self.parse_expr()?;
14554+
return Ok(Statement::DescribeResult {
14555+
describe_alias,
14556+
query_id: Box::new(query_id),
14557+
});
14558+
}
1455214559
if let Some(kw) = self.parse_one_of_keywords(&[
1455314560
Keyword::TABLE,
1455414561
Keyword::VIEW,

0 commit comments

Comments
 (0)