@@ -1025,6 +1025,7 @@ pub enum Expr {
10251025 expr : Box < Expr > ,
10261026 } ,
10271027 /// CONVERT a value to a different data type or character encoding. e.g. `CONVERT(foo USING utf8mb4)`
1028+ // XXX too big
10281029 Convert {
10291030 /// CONVERT (false) or TRY_CONVERT (true)
10301031 /// <https://learn.microsoft.com/en-us/sql/t-sql/functions/try-convert-transact-sql?view=sql-server-ver16>
@@ -1043,6 +1044,7 @@ pub enum Expr {
10431044 styles : Vec < Expr > ,
10441045 } ,
10451046 /// `CAST` an expression to a different data type e.g. `CAST(foo AS VARCHAR(123))`
1047+ // XXX too big
10461048 Cast {
10471049 /// The cast kind (e.g., `CAST`, `TRY_CAST`).
10481050 kind : CastKind ,
@@ -1192,14 +1194,17 @@ pub enum Expr {
11921194 /// A constant of form `<data_type> 'value'`.
11931195 /// This can represent ANSI SQL `DATE`, `TIME`, and `TIMESTAMP` literals (such as `DATE '2020-01-01'`),
11941196 /// as well as constants of other types (a non-standard PostgreSQL extension).
1197+ // XXX too big
11951198 TypedString ( TypedString ) ,
11961199 /// Scalar function call e.g. `LEFT(foo, 5)`
1197- Function ( Function ) ,
1200+ // XXX too big
1201+ Function ( Box < Function > ) ,
11981202 /// `CASE [<operand>] WHEN <condition> THEN <result> ... [ELSE <result>] END`
11991203 ///
12001204 /// Note we only recognize a complete single expression as `<condition>`,
12011205 /// not `< 0` nor `1, 2, 3` as allowed in a `<simple when clause>` per
12021206 /// <https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#simple-when-clause>
1207+ // XXX too big
12031208 Case {
12041209 /// The attached `CASE` token (keeps original spacing/comments).
12051210 case_token : AttachedToken ,
@@ -1277,6 +1282,7 @@ pub enum Expr {
12771282 /// An array expression e.g. `ARRAY[1, 2]`
12781283 Array ( Array ) ,
12791284 /// An interval expression e.g. `INTERVAL '1' YEAR`
1285+ // XXX too big
12801286 Interval ( Interval ) ,
12811287 /// `MySQL` specific text search function [(1)].
12821288 ///
@@ -1328,6 +1334,7 @@ pub enum Expr {
13281334 /// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/functions#higher-order-functions---operator-and-lambdaparams-expr-function)
13291335 /// [Databricks](https://docs.databricks.com/en/sql/language-manual/sql-ref-lambda-functions.html)
13301336 /// [DuckDB](https://duckdb.org/docs/stable/sql/functions/lambda)
1337+ // XXX too big
13311338 Lambda ( LambdaFunction ) ,
13321339 /// Checks membership of a value in a JSON array
13331340 MemberOf ( MemberOf ) ,
@@ -1338,6 +1345,16 @@ impl Expr {
13381345 pub fn value ( value : impl Into < ValueWithSpan > ) -> Self {
13391346 Expr :: Value ( value. into ( ) )
13401347 }
1348+
1349+ /// Convenience method to retrieve `Expr::Function`'s value if `self` is a
1350+ /// function expression.
1351+ pub fn as_function ( & self ) -> Option < & Function > {
1352+ if let Expr :: Function ( f) = self {
1353+ Some ( & * * f)
1354+ } else {
1355+ None
1356+ }
1357+ }
13411358}
13421359
13431360/// The contents inside the `[` and `]` in a subscript expression.
@@ -10887,7 +10904,7 @@ pub enum TableObject {
1088710904 /// INSERT INTO TABLE FUNCTION remote('localhost', default.simple_table)
1088810905 /// ```
1088910906 /// [Clickhouse](https://clickhouse.com/docs/en/sql-reference/table-functions)
10890- TableFunction ( Function ) ,
10907+ TableFunction ( Box < Function > ) ,
1089110908}
1089210909
1089310910impl fmt:: Display for TableObject {
0 commit comments