@@ -1014,6 +1014,7 @@ pub enum Expr {
10141014 expr : Box < Expr > ,
10151015 } ,
10161016 /// CONVERT a value to a different data type or character encoding. e.g. `CONVERT(foo USING utf8mb4)`
1017+ // XXX too big
10171018 Convert {
10181019 /// CONVERT (false) or TRY_CONVERT (true)
10191020 /// <https://learn.microsoft.com/en-us/sql/t-sql/functions/try-convert-transact-sql?view=sql-server-ver16>
@@ -1032,6 +1033,7 @@ pub enum Expr {
10321033 styles : Vec < Expr > ,
10331034 } ,
10341035 /// `CAST` an expression to a different data type e.g. `CAST(foo AS VARCHAR(123))`
1036+ // XXX too big
10351037 Cast {
10361038 /// The cast kind (e.g., `CAST`, `TRY_CAST`).
10371039 kind : CastKind ,
@@ -1181,14 +1183,17 @@ pub enum Expr {
11811183 /// A constant of form `<data_type> 'value'`.
11821184 /// This can represent ANSI SQL `DATE`, `TIME`, and `TIMESTAMP` literals (such as `DATE '2020-01-01'`),
11831185 /// as well as constants of other types (a non-standard PostgreSQL extension).
1186+ // XXX too big
11841187 TypedString ( TypedString ) ,
11851188 /// Scalar function call e.g. `LEFT(foo, 5)`
1186- Function ( Function ) ,
1189+ // XXX too big
1190+ Function ( Box < Function > ) ,
11871191 /// `CASE [<operand>] WHEN <condition> THEN <result> ... [ELSE <result>] END`
11881192 ///
11891193 /// Note we only recognize a complete single expression as `<condition>`,
11901194 /// not `< 0` nor `1, 2, 3` as allowed in a `<simple when clause>` per
11911195 /// <https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#simple-when-clause>
1196+ // XXX too big
11921197 Case {
11931198 /// The attached `CASE` token (keeps original spacing/comments).
11941199 case_token : AttachedToken ,
@@ -1266,6 +1271,7 @@ pub enum Expr {
12661271 /// An array expression e.g. `ARRAY[1, 2]`
12671272 Array ( Array ) ,
12681273 /// An interval expression e.g. `INTERVAL '1' YEAR`
1274+ // XXX too big
12691275 Interval ( Interval ) ,
12701276 /// `MySQL` specific text search function [(1)].
12711277 ///
@@ -1317,6 +1323,7 @@ pub enum Expr {
13171323 /// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/functions#higher-order-functions---operator-and-lambdaparams-expr-function)
13181324 /// [Databricks](https://docs.databricks.com/en/sql/language-manual/sql-ref-lambda-functions.html)
13191325 /// [DuckDB](https://duckdb.org/docs/stable/sql/functions/lambda)
1326+ // XXX too big
13201327 Lambda ( LambdaFunction ) ,
13211328 /// Checks membership of a value in a JSON array
13221329 MemberOf ( MemberOf ) ,
@@ -1327,6 +1334,16 @@ impl Expr {
13271334 pub fn value ( value : impl Into < ValueWithSpan > ) -> Self {
13281335 Expr :: Value ( value. into ( ) )
13291336 }
1337+
1338+ /// Convenience method to retrieve `Expr::Function`'s value if `self` is a
1339+ /// function expression.
1340+ pub fn as_function ( & self ) -> Option < & Function > {
1341+ if let Expr :: Function ( f) = self {
1342+ Some ( & * * f)
1343+ } else {
1344+ None
1345+ }
1346+ }
13301347}
13311348
13321349/// The contents inside the `[` and `]` in a subscript expression.
@@ -10741,7 +10758,7 @@ pub enum TableObject {
1074110758 /// INSERT INTO TABLE FUNCTION remote('localhost', default.simple_table)
1074210759 /// ```
1074310760 /// [Clickhouse](https://clickhouse.com/docs/en/sql-reference/table-functions)
10744- TableFunction ( Function ) ,
10761+ TableFunction ( Box < Function > ) ,
1074510762}
1074610763
1074710764impl fmt:: Display for TableObject {
0 commit comments