prql
prql copied to clipboard
Support IN set of values
Currently, seems the only supported "in" is like:
from employees
filter (age | in 20..80)
which will be translated to:
SELECT
employees.*
FROM
employees
WHERE
age BETWEEN 20
AND 80
Is there a way for IN Clause, like:
SELECT
employees.*
FROM
employees
WHERE
dept IN ('tech', 'hr', 'sales')
Good point.
I propose following syntax:
from employees
filter (dept | in ['tech', 'hr', 'sales'])
There is quite a lot of punctuation, WDYT?
I think that's good!
Does this compile to the same SQL for most dialects?
Yes, I think
dept IN ('tech', 'hr', 'sales')
in SQL is supported by most dialects
Great. We'd need to work out a way of distinguishing based on the type of the arg from the stdlib, which isn't yet supported, but could be supported by #593.
If that's difficult, we could add it into the compiler, which would be fairly easy-ish™
Duplicate of https://github.com/PRQL/prql/issues/993 and fixed in https://github.com/PRQL/prql/pull/3883