Redshift: Support APPROXIMATE PERCENTILE_DISC - #2480
Open
BenSatori wants to merge 8 commits into
Open
Conversation
BenSatori
force-pushed
the
approximate-percentile-disc
branch
from
September 3, 2026 10:49
68b491c to
88094e6
Compare
iffyio
requested changes
Sep 7, 2026
| // be a json path | ||
| impl Dialect for RedshiftSqlDialect { | ||
| fn parse_prefix(&self, parser: &mut Parser) -> Option<Result<Expr, ParserError>> { | ||
| if matches!(&parser.peek_token_ref().token, Token::Word(word) if word.value.eq_ignore_ascii_case("approximate")) |
Contributor
There was a problem hiding this comment.
hmm this doesnt look like the correct place for this functionality, we already have function parsers in the parser and support other percentile_disc variants. so that I think we likely just need to adjust that logic to accept redshifts' syntax
iffyio
reviewed
Sep 7, 2026
Comment on lines
+564
to
+571
| r#"SELECT TOP 10 date.caldate, | ||
| COUNT(totalprice), SUM(totalprice), | ||
| APPROXIMATE PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY totalprice) | ||
| FROM listing | ||
| JOIN date ON listing.dateid = date.dateid | ||
| GROUP BY date.caldate | ||
| ORDER BY 3 DESC"#, | ||
| "SELECT TOP 10 date.caldate, COUNT(totalprice), SUM(totalprice), APPROXIMATE PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY totalprice) FROM listing JOIN date ON listing.dateid = date.dateid GROUP BY date.caldate ORDER BY 3 DESC", |
Contributor
There was a problem hiding this comment.
lets simplify this test input so that its clear what's being tested. also we should use verified_stmt
Contributor
Author
There was a problem hiding this comment.
Sure thing. Will do. My intuition was to use the example in Redshift's documentation, but I will change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Redshift support for APPROXIMATE PERCENTILE_DISC with WITHIN GROUP.
Previously, queries such as:
SELECT APPROXIMATE PERCENTILE_DISC(0.5)
WITHIN GROUP (ORDER BY totalprice)
failed to parse. Added a regression test based on the documented Redshift syntax.