Skip to content

Commit 5a81d98

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 43c42ab commit 5a81d98

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
@@ -5200,6 +5200,19 @@ pub enum Statement {
52005200
object_name: ObjectName,
52015201
},
52025202
/// ```sql
5203+
/// DESC | DESCRIBE RESULT <query_id>
5204+
/// ```
5205+
/// Snowflake-style `DESCRIBE RESULT '<query_id>'`, returning the column
5206+
/// metadata of a previously executed query's result set. The argument is a
5207+
/// general expression covering a string literal (`'01b...'`) and a function
5208+
/// call (`LAST_QUERY_ID()`).
5209+
DescribeResult {
5210+
/// `DESC` or `DESCRIBE`
5211+
describe_alias: DescribeAlias,
5212+
/// The query-id argument.
5213+
query_id: Box<Expr>,
5214+
},
5215+
/// ```sql
52035216
/// [EXPLAIN | DESC | DESCRIBE] <statement>
52045217
/// ```
52055218
Explain {
@@ -5738,6 +5751,12 @@ impl fmt::Display for Statement {
57385751
} => {
57395752
write!(f, "{describe_alias} {object_type} {object_name}")
57405753
}
5754+
Statement::DescribeResult {
5755+
describe_alias,
5756+
query_id,
5757+
} => {
5758+
write!(f, "{describe_alias} RESULT {query_id}")
5759+
}
57415760
Statement::Explain {
57425761
describe_alias,
57435762
verbose,

src/ast/spans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ impl Spanned for Statement {
474474
Statement::Kill { .. } => Span::empty(),
475475
Statement::ExplainTable { .. } => Span::empty(),
476476
Statement::DescribeObject { .. } => Span::empty(),
477+
Statement::DescribeResult { .. } => Span::empty(),
477478
Statement::Explain { .. } => Span::empty(),
478479
Statement::Savepoint { .. } => Span::empty(),
479480
Statement::ReleaseSavepoint { .. } => Span::empty(),

src/parser/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14490,6 +14490,13 @@ impl<'a> Parser<'a> {
1449014490
DescribeAlias::Desc | DescribeAlias::Describe
1449114491
)
1449214492
{
14493+
if self.parse_keyword(Keyword::RESULT) {
14494+
let query_id = self.parse_expr()?;
14495+
return Ok(Statement::DescribeResult {
14496+
describe_alias,
14497+
query_id: Box::new(query_id),
14498+
});
14499+
}
1449314500
if let Some(kw) = self.parse_one_of_keywords(&[
1449414501
Keyword::TABLE,
1449514502
Keyword::VIEW,

0 commit comments

Comments
 (0)