Skip to content

Fix Redshift parenthesized single-column SORTKEY - #5915

Open
simen-strand wants to merge 4 commits into
SQLMesh:mainfrom
simen-strand:fix/redshift-single-column-sortkey
Open

simen-strand wants to merge 4 commits into
SQLMesh:mainfrom
simen-strand:fix/redshift-single-column-sortkey

Conversation

@simen-strand

@simen-strand simen-strand commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Redshift: adds support for parenthesized single-column sortkey.

SQLGlot parses sortkey = (column) as an exp.Paren, producing invalid Redshift syntax such as SORTKEY((column)).

This change explicitly normalizes tuple, array, parenthesized, and scalar SORTKEY expressions before constructing the SortKeyProperty.

Tests

  • Updated the model-level Redshift physical properties test to cover every sortkey form a user can write.
  • Ran pytest tests/core/engine_adapter/test_redshift.py (42 passed).

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

simen-strand and others added 4 commits July 23, 2026 12:13
Signed-off-by: Simen Strand <simen.strand@netcheck.de>
Parametrize the model-definition test over bare, quoted, parenthesized
single-column, tuple, and array sortkey values, restoring coverage for
the bare single-column form.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Simen Strand <simen.strand@netcheck.de>
@simen-strand

Copy link
Copy Markdown
Contributor Author

@StuffbyYuki could you take a look? This small PR makes the Redshift sortkey property accept the documented SORTKEY (column_name [, ...]) form for single columns too

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.

1 participant