Skip to content

Redshift dialect: [...] after an expression is a subscript, not a quoted identifier #2960

Open

Description

@preston-footprint

RedshiftSqlDialect accepts [ as a delimited identifier quote. In Redshift, brackets after an expression index into a SUPER value, and identifiers are quoted only with double quotes.

select a[pg_backend_pid() - pg_backend_pid()] from (select json_parse('[1,2]') as a)
  • sqlparser 0.64.0: Word { value: "pg_backend_pid() - pg_backend_pid()", quote_style: Some('[') }; parses as SELECT a AS [pg_backend_pid() - pg_backend_pid()] FROM ....
  • Redshift: returns a = 1, i.e. a[0], so the bracket contents ran as an expression.

Docs: SUPER navigation (https://docs.aws.amazon.com/redshift/latest/dg/query-super.html) and identifier rules (https://docs.aws.amazon.com/redshift/latest/dg/r_names.html).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions