Open leiysky opened 4 years ago
The feature request looks good to me. I'm thinking about if there any other possible names for these functions. Do other databases have the same functions, what's their function name for these functions?
In Spark SQL there is a approx_percentile
function(https://spark.apache.org/docs/latest/api/sql/index.html#approx_percentile) to calculate quantile value.
There is a function ROUND(date)
in Oracle(https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions136.htm), which is more generic but complicated and may break current syntax rules.
@zz-jason FYI.
Since we have supported APPROX_COUNT_DISTINCT()
, how about using APPROX_PERCENTILE()
to implement quantileExact()
function in Clickhouse?
@zz-jason That's fine.
Feature Request
Is your feature request related to a problem? Please describe: In some analytic scenes, we cannot write SQL conveniently with funtions currently supported by TiDB.
For example, if you want to get a
n-quantile
, you have to write a SQL as follows, wherex
representscount_of_records / n
:While in
Clickhouse
, a functionquantileExact
is enough:Describe the feature you'd like: Support following functions:
quantileExact
, reference: https://clickhouse.tech/docs/en/sql-reference/aggregate-functions/reference/quantileexacttoStartOfXxx
family (Xxx
represents time unit, which can beDay
,Hour
,Minute
etc.), reference: https://clickhouse.tech/docs/en/sql-reference/functions/date-time-functions/#tostartofdayIt had better make the functions pushed to TiFlash.
Describe alternatives you've considered: None.
Teachability, Documentation, Adoption, Migration Strategy: None.