Skip to content
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

Support some analytical functions #19405

Open
leiysky opened this issue Aug 24, 2020 · 4 comments
Open

Support some analytical functions #19405

leiysky opened this issue Aug 24, 2020 · 4 comments
Labels
feature/accepted This feature request is accepted by product managers type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@leiysky
Copy link
Contributor

leiysky commented Aug 24, 2020

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, where x represents count_of_records / n:

SELECT value FROM t 
ORDER BY value
LIMIT x, 1 

While in Clickhouse, a function quantileExact is enough:

SELECT quantileExact(1/n)(value) FROM t

Describe the feature you'd like:
Support following functions:

It had better make the functions pushed to TiFlash.

Describe alternatives you've considered:
None.

Teachability, Documentation, Adoption, Migration Strategy:
None.

@leiysky leiysky added the type/feature-request Categorizes issue or PR as related to a new feature. label Aug 24, 2020
@zz-jason
Copy link
Member

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?

@leiysky
Copy link
Contributor Author

leiysky commented Aug 26, 2020

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.

@zz-jason zz-jason added the feature/reviewing This feature request is reviewing by product managers label Aug 28, 2020
@zz-jason
Copy link
Member

zz-jason commented Sep 1, 2020

Since we have supported APPROX_COUNT_DISTINCT(), how about using APPROX_PERCENTILE() to implement quantileExact() function in Clickhouse?

@leiysky
Copy link
Contributor Author

leiysky commented Sep 1, 2020

@zz-jason That's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/accepted This feature request is accepted by product managers type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants