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 for STDEV in SQL #13302

Closed
ameysami opened this issue Dec 28, 2023 · 1 comment · Fixed by #13303
Closed

Support for STDEV in SQL #13302

ameysami opened this issue Dec 28, 2023 · 1 comment · Fixed by #13303
Labels
A-sql Area: Polars SQL functionality accepted Ready for implementation enhancement New feature or an improvement of an existing feature

Comments

@ameysami
Copy link

ameysami commented Dec 28, 2023

Description

The sql interpreter does not know STDEV or STDEVP as known functions and therefore errors out when a user attempts to use them.
SELECT *, STDEV(COLUMN_X) FROM INPUT_TABLE errors out with the following error message:
polars.exceptions.InvalidOperationError: unsupported SQL function: stdev

Please note, while you can obviously use the python methods for calculating standard deviation, it is useful to also have that capability in SQL as well. Primarily to satisfy different preferences, but also as addition of support for such important functions can lead to trivial development of an equivalent method to pandas eval, which I believe is a highly used feature for data scientists when feature engineering tabular data.

@ameysami ameysami added the enhancement New feature or an improvement of an existing feature label Dec 28, 2023
@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Dec 28, 2023

We already support standard deviation for SQL, but favour PostgreSQL syntax, which expects STDDEV (note the extra 'D'). I don't think it's unreasonable to support both spellings though, as a quick look over various dialects show that it's a coin-flip between which one each uses. I'll enable support for both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql Area: Polars SQL functionality accepted Ready for implementation enhancement New feature or an improvement of an existing feature
Projects
Archived in project
2 participants