[CALCITE-6767] PERCENTILE_CONT/PERCENTILE_DISC function are not supported#5095
[CALCITE-6767] PERCENTILE_CONT/PERCENTILE_DISC function are not supported#5095xuzifu666 wants to merge 2 commits into
Conversation
|
|
||
| # [CALCITE-4644] Add PERCENTILE_CONT and PERCENTILE_DISC aggregate functions. | ||
| # PERCENTILE_CONT / PERCENTILE_DISC without GROUP BY. | ||
| select |
There was a problem hiding this comment.
The result is validated in PostgreSQL in https://onecompiler.com/postgresql/44u4qdgpy and result is as expected
| !ok | ||
|
|
||
| # [CALCITE-6767] PERCENTILE_CONT/PERCENTILE_DISC syntax not supported. | ||
| # These sql was validated in PostgreSQL |
There was a problem hiding this comment.
sql -> sql programs
was -> were
There was a problem hiding this comment.
Thanks for the remind, done.
| final double rank = fraction * (n - 1); | ||
| final int lo = (int) Math.floor(rank); | ||
| final int hi = (int) Math.ceil(rank); | ||
| final double loValue = values.get(lo).doubleValue(); |
There was a problem hiding this comment.
I think this won't work for DECIMAL values with large precisions, since double has only 53 bits of mantissa, which is insufficient to store large decimal values without a large precision loss. If the decimals are close in values, the error will be very large.
I think using BigDecimal is probably a better approach.
There was a problem hiding this comment.
Makes sense. I’ve updated the handling logic to use BigDecimal instead of double.
|



jira: https://issues.apache.org/jira/browse/CALCITE-6767