File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -242,6 +242,10 @@ pub enum Expr {
242242 /// Nested expression e.g. `(foo > bar)` or `(1)`
243243 /// Snowflake allows multiple comma-separated expressions here
244244 Nested ( Vec < Expr > ) ,
245+ /// redshift seems to allow brackets around identifiers, e.g.
246+ /// select ["a"] from (select 1 a);
247+ /// We preserve them even though it's not clear that they have any effect
248+ Brackets ( Box < Expr > ) ,
245249 /// A literal value, such as string, number, date or NULL
246250 Value ( Value ) ,
247251 /// A constant of form `<data_type> 'value'`.
@@ -398,6 +402,7 @@ impl fmt::Display for Expr {
398402 }
399403 write ! ( f, ")" )
400404 }
405+ Expr :: Brackets ( expr) => write ! ( f, "[{}]" , expr) ,
401406 Expr :: Value ( v) => write ! ( f, "{}" , v) ,
402407 Expr :: TypedString { data_type, value } => {
403408 write ! ( f, "{}" , data_type) ?;
Original file line number Diff line number Diff line change @@ -339,6 +339,11 @@ impl<'a> Parser<'a> {
339339 self . expect_token ( & Token :: RParen ) ?;
340340 Ok ( expr)
341341 }
342+ Token :: LBracket => {
343+ let ident = self . parse_identifier ( ) ?;
344+ self . expect_token ( & Token :: RBracket ) ?;
345+ Ok ( Expr :: Brackets ( Box :: new ( Expr :: Identifier ( ident) ) ) )
346+ }
342347 unexpected => self . expected ( "an expression" , unexpected) ,
343348 } ?;
344349
You can’t perform that action at this time.
0 commit comments