Skip to content

fix(redshift): support APPROXIMATE PERCENTILE_DISC round-trip#7585

Merged
georgesittas merged 1 commit intomainfrom
fix/redshift-approximate-percentile
Apr 30, 2026
Merged

fix(redshift): support APPROXIMATE PERCENTILE_DISC round-trip#7585
georgesittas merged 1 commit intomainfrom
fix/redshift-approximate-percentile

Conversation

@fivetran-kwoodbeck
Copy link
Copy Markdown
Collaborator

APPROXIMATE PERCENTILE_DISC(p) WITHIN GROUP (ORDER BY x) is valid Redshift syntax that was causing a ParseError on round-trip. _parse_approximate_count only handled APPROXIMATE COUNT(DISTINCT ...) — when it saw a PercentileDisc it retreated, leaving APPROXIMATE stranded in the projection list.

To fix, another branch was added to _parse_approximate_count and generator was updated to output exp.ApproxQuantile correctly.

@github-actions
Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:fix/redshift-approximate-percentile, sqlglot version: fix/redshift-approximate-percentile)
  • baseline (main, sqlglot version: 0.0.1.dev1)

By Dialect

dialect main sqlglot:fix/redshift-approximate-percentile transitions links
bigquery -> bigquery 24647/24652 passed (100.0%) 23497/23497 passed (100.0%) No change full result / delta
bigquery -> duckdb 867/1154 passed (75.1%) 0/0 passed (0.0%) Results not found full result / delta
duckdb -> duckdb 5823/5823 passed (100.0%) 0/0 passed (0.0%) Results not found full result / delta
snowflake -> duckdb 1063/1961 passed (54.2%) 0/0 passed (0.0%) Results not found full result / delta
snowflake -> snowflake 65133/65133 passed (100.0%) 63027/63027 passed (100.0%) No change full result / delta
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 7101/7101 passed (100.0%) 7101/7101 passed (100.0%) No change full result / delta

Overall

main: 113236 total, 112046 passed (pass rate: 98.9%), sqlglot version: 0.0.1.dev1

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

Transitions:
No change

Dialect pair changes: 0 previous results not found, 3 current results not found

✅ 38 test(s) passed

@georgesittas georgesittas merged commit 9f169ab into main Apr 30, 2026
8 checks passed
@georgesittas georgesittas deleted the fix/redshift-approximate-percentile branch April 30, 2026 17:08
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.

2 participants