Skip to content

Commit 85e0e5f

Browse files
alambovr
andauthored
Add docs for MapAccess (#489)
* Add docs for `MapAccess` * fix: fmt * Apply suggestions from code review Co-authored-by: Dmitry Patsura <[email protected]> * touchup Co-authored-by: Dmitry Patsura <[email protected]>
1 parent 11046f6 commit 85e0e5f

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

src/ast/mod.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,7 @@ pub enum Expr {
232232
right: Box<Expr>,
233233
},
234234
/// CompositeAccess (postgres) eg: SELECT (information_schema._pg_expandarray(array['i','i'])).n
235-
CompositeAccess {
236-
expr: Box<Expr>,
237-
key: Ident,
238-
},
235+
CompositeAccess { expr: Box<Expr>, key: Ident },
239236
/// `IS NULL` operator
240237
IsNull(Box<Expr>),
241238
/// `IS NOT NULL` operator
@@ -280,10 +277,7 @@ pub enum Expr {
280277
/// ALL operation e.g. `1 ALL (1)` or `foo > ALL(bar)`, It will be wrapped in the right side of BinaryExpr
281278
AllOp(Box<Expr>),
282279
/// Unary operation e.g. `NOT foo`
283-
UnaryOp {
284-
op: UnaryOperator,
285-
expr: Box<Expr>,
286-
},
280+
UnaryOp { op: UnaryOperator, expr: Box<Expr> },
287281
/// CAST an expression to a different data type e.g. `CAST(foo AS VARCHAR(123))`
288282
Cast {
289283
expr: Box<Expr>,
@@ -301,10 +295,7 @@ pub enum Expr {
301295
expr: Box<Expr>,
302296
},
303297
/// POSITION(<expr> in <expr>)
304-
Position {
305-
expr: Box<Expr>,
306-
r#in: Box<Expr>,
307-
},
298+
Position { expr: Box<Expr>, r#in: Box<Expr> },
308299
/// SUBSTRING(<expr> [FROM <expr>] [FOR <expr>])
309300
Substring {
310301
expr: Box<Expr>,
@@ -331,14 +322,12 @@ pub enum Expr {
331322
/// A constant of form `<data_type> 'value'`.
332323
/// This can represent ANSI SQL `DATE`, `TIME`, and `TIMESTAMP` literals (such as `DATE '2020-01-01'`),
333324
/// as well as constants of other types (a non-standard PostgreSQL extension).
334-
TypedString {
335-
data_type: DataType,
336-
value: String,
337-
},
338-
MapAccess {
339-
column: Box<Expr>,
340-
keys: Vec<Expr>,
341-
},
325+
TypedString { data_type: DataType, value: String },
326+
/// Access a map-like object by field (e.g. `column['field']` or `column[4]`
327+
/// Note that depending on the dialect, struct like accesses may be
328+
/// parsed as [`ArrayIndex`] or [`MapAccess`]
329+
/// <https://clickhouse.com/docs/en/sql-reference/data-types/map/>
330+
MapAccess { column: Box<Expr>, keys: Vec<Expr> },
342331
/// Scalar function call e.g. `LEFT(foo, 5)`
343332
Function(Function),
344333
/// `CASE [<operand>] WHEN <condition> THEN <result> ... [ELSE <result>] END`
@@ -369,10 +358,7 @@ pub enum Expr {
369358
/// ROW / TUPLE a single value, such as `SELECT (1, 2)`
370359
Tuple(Vec<Expr>),
371360
/// An array index expression e.g. `(ARRAY[1, 2])[1]` or `(current_schemas(FALSE))[1]`
372-
ArrayIndex {
373-
obj: Box<Expr>,
374-
indexes: Vec<Expr>,
375-
},
361+
ArrayIndex { obj: Box<Expr>, indexes: Vec<Expr> },
376362
/// An array expression e.g. `ARRAY[1, 2]`
377363
Array(Array),
378364
}

0 commit comments

Comments
 (0)