5 ms·
This looks awesome. I want to integrate this with my SQL tool (using JS). I've noticed the limited standard library. I wonder if prql supports "passthrough" fu
by tanin 4y ago
This looks awesome. I want to integrate this with my SQL tool (using JS).
I've noticed the limited standard library. I wonder if prql supports "passthrough" function where it just uses function as-is e.g. if I invoke "random_function(a)", it transpiles to "random_function(a)" in SQL.
- krab 4y agoIn the examples, they show S- strings. If I understand it correctly, s"random_function(a)" does what you want. The question is whether you can rely on `a` that you reference being still named `a` in SQL.
- snthpy 4y agoCorrect, s-strings are the general "escape hatch" to allow pass-through for things that are not yet implemented, like dialect specific functions. See the section in the PRQL Book [0] for more detail. It does make it opaque to the compiler though so the user becomes responsible for ensuring symbol names are valid and accessible in the scope. [0]: https://prql-lang.org/book/language-features/s-strings.html https://prql-lang.org/book/language-features/s-strings.html
- viraptor 4y agoI wish they made it more obvious in the docs. S-string is not something I would look at when trying to figure out how to use "NOW()". I spent a reasonable time looking for a way to call functions and then just abandoned the idea of prql since it seemed impossible.
- maximilianroos 4y ago(PRQL core-dev here, not sure whether you'll see this given it's a day later) Thanks for the feedback. We had similar feedback before, and we added an s-string to the example on the homepage. derive country_code = s"LEFT(country, 2)" Any thoughts on how to communicate this more clearly? They're also an item in the Showcase. Without them, PRQL would indeed be harder to start using now, so keen to make them more obvious.
- viraptor 4y agoI just tried to do what I would do originally and the steps were: - look at the "functions" example on the main page (an opportunity to mention s-strings there) - search for "function" in the prql book (s-strings are about 18th position, I probably bailed out before that) - search for "prql SQL function" and "prql native function" - neither returns the answer on the first page The sstring on the front page definitely helps a lot. I think just a bit of SEO and a right phrase here and there mentioning "SQL function" and "native function" could help a lot as well.
- maximilianroos 4y agoGreat! I made some of these changes at https://github.com/PRQL/prql/pull/1370 https://github.com/PRQL/prql/pull/1370