Keywords and Builtin functions for PRQL
Just trying to capture this somewhere, so far I have:
Builtins
- from
- join (side)
- select
- aggregate (by)
- sort (order)
- take
- derive
- func
- table
- value
- let
Aggregate functions
- count
- sum
- min
- max
- average
- stddev
- variance
Operators
[ ], lists( ), code bodyx:y, passing named argument x value y|, pipes results to next function
What's missing ?
Thanks for doing the list!
We now have table as of today!
And then I expect they'll be a long list of simple functions like stddev etc.
Those could be PRQL functions rather than written in rust, since they'll generally transpile to `func(foo)‘
I'm all for making them PRQL functions, easier to share across implementations.
Closing this till we get a full list which can put in the docs somewhere.
OK — feel free to PR a partial list for the meantime, and if you have the prql code then awesome (re your screenshots on discord). Thanks @qorrect
Ok will do, I'm hoping to provide a PR for the standard library below, and a bunch of queries for testing, I'm not sure the right place for them so I'll let you place them.
# Aggregate Functions
func min column = f"MIN({column})"
func max column = f"MAX({column})"
func sum column = f"SUM({column})"
func avg column = f"AVG({column})"
func stddev column = f"STDDEV({column})"
func average column = f"AVG({column})"
func count = f"COUNT(*)"
func count column = f"COUNT({column})"
func count_distinct column = f"COUNT(DISTINCT `{column}`)"
# Casting functions
func float column = f'CAST({column} AS FLOAT)'
func int column = f'CAST({column} AS INT)'
func string column = f'CAST({column} AS CHAR)'
func date column = f'CAST({column} AS DATE)'
func datetime column = f'CAST({column} AS DATETIME)'
func timestamp column = f'CAST({column} AS TIMESTAMP)'
func time column = f'CAST({column} AS TIME)'
func boolean column = f'CAST({column} AS BOOLEAN)'
func decimal column = f'CAST({column} AS DECIMAL)'
func double column = f'CAST({column} AS DOUBLE)'
from null
That's great! We could add this to a file functions.pest initially? I'm sure it'll move around but I'm very up for adding it and then we can build on it.
For the Casting — I though the plan for as that we had in discord was good? So it would just be a single func, if you agree...
Yes agreed, I'll update it.