Skip to content

fix(redshift): roundtrip support for CURRENT_USER_ID and USER#7633

Merged
georgesittas merged 3 commits into
mainfrom
fix/redshift-current_user_id
May 12, 2026
Merged

fix(redshift): roundtrip support for CURRENT_USER_ID and USER#7633
georgesittas merged 3 commits into
mainfrom
fix/redshift-current_user_id

Conversation

@fivetran-kwoodbeck
Copy link
Copy Markdown
Collaborator

SELECT USER and SELECT CURRENT_USER_ID were being quoted as "USER" and "CURRENT_USER_ID" because they were treated as reserved-word identifiers. Both are Redshift pseudo-columns that should parse and generate as bare keywords. Additionally, user used as a table name (e.g. FROM salesforce.user) was causing a ParseError.

-- before
SELECT USER            → SELECT "USER"
SELECT CURRENT_USER_ID → SELECT "CURRENT_USER_ID"
FROM salesforce.user   → ParseError

-- after
SELECT USER            → SELECT USER
SELECT CURRENT_USER_ID → SELECT CURRENT_USER_ID
FROM salesforce.user   → SELECT ... FROM salesforce."user"

@geooo109 geooo109 self-assigned this May 11, 2026
Copy link
Copy Markdown
Collaborator

@geooo109 geooo109 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fivetran-kwoodbeck USER is a synonym for CURRENT_USER in redshift USER docs. As a result, we can map the USER to CURRENT_USER here to simplify things. (we have already support for CURRENT_USER). We do this for other dialects, check here. Let me know if this works.

Comment thread sqlglot/generators/redshift.py Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:fix/redshift-current_user_id, sqlglot version: fix/redshift-current_user_id)
  • baseline (sqlglot:cold-prql-test, sqlglot version: cold-prql-test)

By Dialect

dialect sqlglot:cold-prql-test sqlglot:fix/redshift-current_user_id transitions links
databricks -> databricks 1370/1370 passed (100.0%) 1370/1370 passed (100.0%) No change full result / delta
postgres -> postgres 6042/6042 passed (100.0%) 6042/6042 passed (100.0%) No change full result / delta
redshift -> redshift 7100/7101 passed (100.0%) 7101/7101 passed (100.0%) 1 fail -> pass full result / delta
snowflake -> snowflake 63027/63027 passed (100.0%) 63027/63027 passed (100.0%) No change full result / delta
bigquery -> bigquery 23497/23497 passed (100.0%) 23497/23497 passed (100.0%) No change full result / delta

Overall

sqlglot:cold-prql-test: 101037 total, 101036 passed (pass rate: 100.0%), sqlglot version: cold-prql-test

sqlglot:fix/redshift-current_user_id: 101037 total, 101037 passed (pass rate: 100.0%), sqlglot version: fix/redshift-current_user_id

Transitions:
1 fail -> pass

✅ 61 test(s) passed

@fivetran-kwoodbeck fivetran-kwoodbeck force-pushed the fix/redshift-current_user_id branch from e92cfd3 to 9ab2e73 Compare May 11, 2026 19:17
@fivetran-kwoodbeck
Copy link
Copy Markdown
Collaborator Author

@fivetran-kwoodbeck USER is a synonym for CURRENT_USER in redshift USER docs. As a result, we can map the USER to CURRENT_USER here to simplify things. (we have already support for CURRENT_USER). We do this for other dialects, check here. Let me know if this works.

@geooo109 Sounds good, it's been updated

Comment thread sqlglot/parsers/redshift.py Outdated
@fivetran-kwoodbeck fivetran-kwoodbeck force-pushed the fix/redshift-current_user_id branch from 9ab2e73 to 030eff6 Compare May 12, 2026 14:26
@georgesittas georgesittas force-pushed the fix/redshift-current_user_id branch from 627fa29 to e075a2a Compare May 12, 2026 16:27
@georgesittas georgesittas merged commit 87cc106 into main May 12, 2026
8 checks passed
@georgesittas georgesittas deleted the fix/redshift-current_user_id branch May 12, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants