Skip to content

Commit

Permalink
Fix(redshift): allow # as an identifier prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas committed Apr 13, 2023
1 parent f7679ff commit cc7691c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sqlglot/dialects/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class Tokenizer(Postgres.Tokenizer):
"VARBYTE": TokenType.VARBINARY,
}

# Redshift allows # to appear as a table identifier prefix
SINGLE_TOKENS = Postgres.Tokenizer.SINGLE_TOKENS.copy()
SINGLE_TOKENS.pop("#")

class Generator(Postgres.Generator):
SINGLE_STRING_INTERVAL = True

Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TestRedshift(Validator):
dialect = "redshift"

def test_redshift(self):
self.validate_identity("SELECT * FROM #x")
self.validate_identity("SELECT INTERVAL '5 days'")

self.validate_all(
Expand Down

0 comments on commit cc7691c

Please sign in to comment.