-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
[FLINK-37239][docs] Add examples for unhex, btrim, translate, elt and percentile #26091
base: master
Are you sure you want to change the base?
Conversation
docs/data/sql_functions.yml
Outdated
E.g., SELECT PERCENTILE(age, 0.5) FROM (VALUES (0), (50), (100)) AS age or $('age').percentile(0.5) returns 50.0. | ||
|
||
The percentage must be a literal numeric value between `[0.0, 1.0]` or an array of such values. |
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.
Sorry, during the first iteration I didn't test the examples...
Now it took me almost half an hour to realize that this is based on a continuous distribution...
I think we need to think about other example here...
It returns same result for the case of 0.5 for both
however in case of discrete distribution
SELECT PERCENTILE(age, 0.25) FROM (VALUES (0), (25), (50), (100)) AS age
I would expect output 25.0 however it shows different result (since the function is for continuous)
It should be explicitly mentioned in the doc since in SQL Standard there are PERCENTILE_CONT
and PERCENTILE_DISC
.
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.
Returns the exact percentile value of expr at the specified percentage in a group.
looks like description is also incorrect since usually by group it is meant within a limited group (discrete)
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 looked into it and makes sense. I can update the example to a non ambiguous one and complement the description. Suggestion:
Returns the percentile value of expr at the specified percentage using continous distribution.
E.g., SELECT PERCENTILE(age, 0.25) FROM (VALUES (10), (20), (30), (40)) AS age returns 17.5
The percentage must be a literal numeric value between `[0.0, 1.0]` or an array of such values.
...
Btw, there's another paragraph right below that points to the behavior being of a continuous percentile function and explain to the user how the value is calculated when there's no exact match:
If no expr lies exactly at the desired percentile, the result is calculated using linear interpolation of the two nearest exprs. If expr or frequency is NULL, or frequency is not positive, the input row will be ignored.
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.
sounds good to me, thanks
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.
Done. Thanks for the input @snuyanzin
What is the purpose of the change
We currently have no examples for some functions in the documentation. 5 examples of these are unhex, btrim, percentile, translate and ETL. This PR adds examples to these.
Upon merging, I'll create another ticket for the chinese translation.
Brief change log
Verifying this change
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation