Skip to content

Redshift dialect: -- comment should end at a carriage return #2958

Open

Description

@preston-footprint

In the Redshift dialect a -- comment runs to the next \n, but Redshift ends it at a lone \r too, as Postgres does. sqlparser already stops at \r for PostgreSqlDialect (tokenizer tokenize_single_line_comment).

select 1 as a --\r, pg_backend_pid()

(\r is a literal carriage return.)

  • sqlparser 0.64.0: SingleLineComment("\r, pg_backend_pid()"); parses as SELECT 1 AS a.
  • Redshift: two columns, a = 1, pg_backend_pid = 1073905994.

Redshift is based on PostgreSQL 8.0.2 (https://docs.aws.amazon.com/redshift/latest/dg/c_redshift-and-postgres-sql.html), whose lexer treats both \n and \r as newlines. Could RedshiftSqlDialect share the Postgres behavior here?

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