prql icon indicating copy to clipboard operation
prql copied to clipboard

Where does documentation for `module` stand?

Open richb-hanover opened this issue 10 months ago • 14 comments

What's up?

I have a set of functions that I would like to include in each of my PRQL query files. I can't make it work.

I attempted to paste one of the definitions of a module from the Modules page into the Playground, but got this error message:

explicit module declarations are not allowed

I also tried simply adding module my_module_file.prql to the beginning of another query in an attempt to import the definitions, but no dice.

What else do I need to know? :-) Many thanks.

Update: This is the set of function declarations I use in several queries... If I'm understanding modules correctly, I could create the file once and simply "name it" in each query...

# dollars displays a numeric value as dollars with commas
let dollars = d -> s"""printf('$%,d',{d})"""

# pct computes the amount (percent) the new differs from old
let pct = o n -> 100.0*( n - o ) / o

# prtpct prints a floating point number with "%"
let prtpct = v -> s"printf('%1.1f%'', {v})"

richb-hanover avatar Aug 08 '23 21:08 richb-hanover