Skip to content

How to represent table generating functions? #1333

Answered by aljazerzen
nightpool asked this question in Q&A
Discussion options

You must be logged in to vote

from is meant for pulling data from tables it's actually not needed in your case.

But if you remove it, PRQL gives an error:

Error: 
   ╭─[:7:3]
   │
 7 │   weeks_between @2022-06-03 (current_week + 4)
   ·   ──────────────────────┬─────────────────────  
   ·                         ╰─────────────────────── table s-strings cannot contain interpolations
   · 
   · Help: are you missing `from` statement?
───╯

... which is a limitation we no longer need, so I just removed it.

Your query should now work, if you also prepend generate_series with SELECT (this is current implementation limitation):

prql sql_dialect:postgres

func weeks_between start end -> s"SELECT generate_series({start}, {en…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by max-sixty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants