Skip to content

Commit 99ab529

Browse files
MazterQyouovr
authored andcommitted
feat: Support field access with dot expression in SELECT
1 parent 082dc65 commit 99ab529

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/ast/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ pub enum Expr {
323323
},
324324
/// An array expression e.g. `ARRAY[1, 2]`
325325
Array(Array),
326+
/// An expression with field access, such as `SELECT (udf_returning_struct()).field`
327+
DotExpr {
328+
expr: Box<Expr>,
329+
field: Ident,
330+
},
326331
}
327332

328333
impl fmt::Display for Expr {
@@ -508,6 +513,9 @@ impl fmt::Display for Expr {
508513
Expr::Array(set) => {
509514
write!(f, "{}", set)
510515
}
516+
Expr::DotExpr { expr, field } => {
517+
write!(f, "{}.{}", expr, field)
518+
}
511519
}
512520
}
513521
}
@@ -2457,7 +2465,7 @@ impl fmt::Display for CopyLegacyCsvOption {
24572465
}
24582466
}
24592467

2460-
///
2468+
///
24612469
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
24622470
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
24632471
pub enum MergeClause {

src/parser.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,14 @@ impl<'a> Parser<'a> {
518518
}
519519
};
520520
self.expect_token(&Token::RParen)?;
521-
Ok(expr)
521+
if !self.consume_token(&Token::Period) {
522+
return Ok(expr);
523+
}
524+
525+
Ok(Expr::DotExpr {
526+
expr: Box::new(expr),
527+
field: self.parse_identifier()?,
528+
})
522529
}
523530
Token::Placeholder(_) => {
524531
self.prev_token();

0 commit comments

Comments
 (0)