web/book/src/reference/stdlib/README.md
The standard library currently contains commonly used functions that are used in SQL. It's not yet as broad as we'd like, and we're very open to expanding it.
Currently s-strings are an escape-hatch for any function that isn't in our standard library. If we find ourselves using them for something frequently, raise an issue and we'll add it to the stdlib.
Here's the source of the current
PRQL std:
[!NOTE] PRQL 0.9.0 has started supporting different DB implementations for standard library functions. The source is the
std.sql.
{{#include ../../../../../prqlc/prqlc/src/semantic/std.prql}}
And a couple of examples:
from employees
derive {
gross_salary = (salary + payroll_tax | as int),
gross_salary_rounded = (gross_salary | math.round 0),
time = date.now, # current timestamp; or use s"NOW()" for a dialect-specific s-string
}
Example of different implementations of division and integer division:
prql target:sql.sqlite
from [{x = 13, y = 5}]
select {
quotient = x / y,
int_quotient = x // y,
}
prql target:sql.mysql
from [{x = 13, y = 5}]
select {
quotient = x / y,
int_quotient = x // y,
}