Add docs for MapAccess (#489)

* Add docs for `MapAccess`

* fix: fmt

* Apply suggestions from code review

Co-authored-by: Dmitry Patsura <zaets28rus@gmail.com>

* touchup

Co-authored-by: Dmitry Patsura <zaets28rus@gmail.com>
This commit is contained in:
Andrew Lamb 2022-05-22 15:26:06 -04:00 committed by GitHub
parent 11046f66e7
commit 85e0e5fd39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -232,10 +232,7 @@ pub enum Expr {
right: Box<Expr>, right: Box<Expr>,
}, },
/// CompositeAccess (postgres) eg: SELECT (information_schema._pg_expandarray(array['i','i'])).n /// CompositeAccess (postgres) eg: SELECT (information_schema._pg_expandarray(array['i','i'])).n
CompositeAccess { CompositeAccess { expr: Box<Expr>, key: Ident },
expr: Box<Expr>,
key: Ident,
},
/// `IS NULL` operator /// `IS NULL` operator
IsNull(Box<Expr>), IsNull(Box<Expr>),
/// `IS NOT NULL` operator /// `IS NOT NULL` operator
@ -280,10 +277,7 @@ pub enum Expr {
/// ALL operation e.g. `1 ALL (1)` or `foo > ALL(bar)`, It will be wrapped in the right side of BinaryExpr /// ALL operation e.g. `1 ALL (1)` or `foo > ALL(bar)`, It will be wrapped in the right side of BinaryExpr
AllOp(Box<Expr>), AllOp(Box<Expr>),
/// Unary operation e.g. `NOT foo` /// Unary operation e.g. `NOT foo`
UnaryOp { UnaryOp { op: UnaryOperator, expr: Box<Expr> },
op: UnaryOperator,
expr: Box<Expr>,
},
/// CAST an expression to a different data type e.g. `CAST(foo AS VARCHAR(123))` /// CAST an expression to a different data type e.g. `CAST(foo AS VARCHAR(123))`
Cast { Cast {
expr: Box<Expr>, expr: Box<Expr>,
@ -301,10 +295,7 @@ pub enum Expr {
expr: Box<Expr>, expr: Box<Expr>,
}, },
/// POSITION(<expr> in <expr>) /// POSITION(<expr> in <expr>)
Position { Position { expr: Box<Expr>, r#in: Box<Expr> },
expr: Box<Expr>,
r#in: Box<Expr>,
},
/// SUBSTRING(<expr> [FROM <expr>] [FOR <expr>]) /// SUBSTRING(<expr> [FROM <expr>] [FOR <expr>])
Substring { Substring {
expr: Box<Expr>, expr: Box<Expr>,
@ -331,14 +322,12 @@ pub enum Expr {
/// A constant of form `<data_type> 'value'`. /// A constant of form `<data_type> 'value'`.
/// This can represent ANSI SQL `DATE`, `TIME`, and `TIMESTAMP` literals (such as `DATE '2020-01-01'`), /// This can represent ANSI SQL `DATE`, `TIME`, and `TIMESTAMP` literals (such as `DATE '2020-01-01'`),
/// as well as constants of other types (a non-standard PostgreSQL extension). /// as well as constants of other types (a non-standard PostgreSQL extension).
TypedString { TypedString { data_type: DataType, value: String },
data_type: DataType, /// Access a map-like object by field (e.g. `column['field']` or `column[4]`
value: String, /// Note that depending on the dialect, struct like accesses may be
}, /// parsed as [`ArrayIndex`] or [`MapAccess`]
MapAccess { /// <https://clickhouse.com/docs/en/sql-reference/data-types/map/>
column: Box<Expr>, MapAccess { column: Box<Expr>, keys: Vec<Expr> },
keys: Vec<Expr>,
},
/// Scalar function call e.g. `LEFT(foo, 5)` /// Scalar function call e.g. `LEFT(foo, 5)`
Function(Function), Function(Function),
/// `CASE [<operand>] WHEN <condition> THEN <result> ... [ELSE <result>] END` /// `CASE [<operand>] WHEN <condition> THEN <result> ... [ELSE <result>] END`
@ -369,10 +358,7 @@ pub enum Expr {
/// ROW / TUPLE a single value, such as `SELECT (1, 2)` /// ROW / TUPLE a single value, such as `SELECT (1, 2)`
Tuple(Vec<Expr>), Tuple(Vec<Expr>),
/// An array index expression e.g. `(ARRAY[1, 2])[1]` or `(current_schemas(FALSE))[1]` /// An array index expression e.g. `(ARRAY[1, 2])[1]` or `(current_schemas(FALSE))[1]`
ArrayIndex { ArrayIndex { obj: Box<Expr>, indexes: Vec<Expr> },
obj: Box<Expr>,
indexes: Vec<Expr>,
},
/// An array expression e.g. `ARRAY[1, 2]` /// An array expression e.g. `ARRAY[1, 2]`
Array(Array), Array(Array),
} }