-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CALCITE-6035] Unparse 'WITHIN GROUP' for BigQuery dialect to match BigQuery documentation #3466
base: main
Are you sure you want to change the base?
Conversation
…igQuery documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just left a couple questions
private static void unparseWithinGroup(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { | ||
assert call.operandCount() == 2; | ||
call.operand(0).unparse(writer, 0, 0); | ||
writer.keyword("OVER"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I think you're more familiar with these clauses than me, is it guaranteed that the WITHIN GROUP translates to BQ's OVER in every case? are they really just synonyms for each other, I mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I detailed in this comment how Calcite currently only supports
select percentile_cont(0.5) within group (order by X)
so I want to say that for what is supported at this moment, it is sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh ok. So if Calcite ended up supporting the partition by
case (your input_2
from that comment), do you know if this would break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Julian had a comment here about how we should approach the followup tickets
I think it won't work out of the box, there are things to figure out
We would still be parsing it as within_group
in the parser, but want it to be handled differently in the validator.
questions to then consider: would we still use a SqlWithinGroupOperator? If yes, then that would be unparsed into "OVER" correctly. If not, this may have to change
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
@Test void testPercentileContWithinGroupClauseBigQuery() { | ||
final String query = "select percentile_cont(0.5) WITHIN GROUP (ORDER BY `product_class_id`)\n" | ||
+ "from `foodmart`.`product`"; | ||
final String expected = "SELECT PERCENTILE_CONT(0.5) OVER " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PERCENTILE_CONT function for BigQuery must have two arguments. I think this expected query would probably fail since the column isn't passed to the function directly as an argument
No description provided.