web/website/content/faq.md
Here are some of the most common questions we hear. Have something else you'd like to ask? Pop by our Discord and ask away!
{{< faq "Cool story Hansel, but what can I actually do with PRQL now?" >}}
PRQL is ready to use by the intrepid, either with our supported integrations, or within your own tools, using one of our supported language bindings. The easiest way is with our integrations:
%%prql
magic. As well as connecting to existing DBs, our integration with DuckDB
enables querying pandas dataframes, CSVs & Parquet files, and writing the
output to a dataframe.It's also possible to query PRQL from your code with our bindings for R, Rust, Python & JS. For an example of using PRQL with DuckDB, check out Querying with PRQL.
{{</ faq >}}
{{< faq "Something here reminds me of another project, did you take the idea from them?" >}}
Yes, probably. We're standing on the shoulders of giants:
And there are many projects similar to PRQL:
.NET ecosystem which can (mostly) compile to
SQL. It was one of the first languages to take this approach.If any of these descriptions can be improved, please feel free to PR changes.
{{</ faq >}}
{{< faq "How is PRQL different from all the projects that SQL has defeated?" >}}
Many languages have attempted to replace SQL, and yet SQL has massively grown in usage and importance in the past decade. There are lots of reasonable critiques on these attempts. So a reasonable question is "Why are y'all building something that many others have failed at?". Some thoughts:
filter rather than WHERE &
HAVING & QUALIFY brings both more power and more accessibility.In the same way that "SQL was invented in the 1970s and therefore must be bad"
is questionable logic, "n languages have tried and failed so therefore SQL
cannot be improved." suffers a similar fallacy. SQL isn't bad because it's old.
It's bad because — in some cases — it's bad.
{{</ faq >}}
{{< faq "Which databases does PRQL work with?" >}}
PRQL compiles to SQL, so it's compatible with any database that accepts SQL.
A query's dialect can be explicitly specified, allowing for dialect-specific SQL to be generated. See the Dialect docs for more info; note that there is currently very limited implementation of this, and most dialects' implementation are identical to a generic implementation.
{{</ faq >}}
{{< faq "What's this aggregate function?" >}}
...and why not just use SELECT & GROUP BY?
SQL uses SELECT for all of these:
Selecting or computing columns, without changing the shape of the data:
SELECT x * 2 FROM y as two_x
Reducing a column into a single row, with a reduction function:
SELECT SUM(x) FROM y
Reducing a column into groups, with a reduction function and a GROUP BY
function:
SELECT SUM(x) FROM y GROUP BY z
These are not orthogonal — SELECT does lots of different things depending on
the context. It's difficult for both people and machines to evaluate the shape
of the output. It's easy to mix meanings and raise an error (e.g.
SELECT x, MIN(y) FROM z).
PRQL clearly delineates two operations with two transforms:
select — picking & calculating columns. These calculations always produce
exactly one output row for every input row.
from employees
select name = f"{first_name} {last_name}"
aggregate — reducing multiple rows to a single row, with a reduction
function like sum or min.
from employees
aggregate {total_salary = sum salary}
aggregate can then be used in a group transform, where it has exactly the
same semantics on the group as it would on a whole table — another example of
PRQL's orthogonality.
from employees
group department (
aggregate {total_salary = sum salary}
)
While you should be skeptical of new claims from new entrants Hadley Wickham, the developer of Tidyverse commented in a discussion on PRQL:
FWIW the separate
group_by()is one of my greatest design regrets with dplyr — I wish I had madebya parameter ofsummarise(),mutate(),filter()etc.
For more detail, check out the docs in the PRQL Book.
{{</ faq >}}
{{< faq "Can PRQL write to databases?" >}}
PRQL is focused on analytical queries, so we don't currently support writing or
modifying data in databases. However, PRQL queries can be used to generate SQL
statements that write to databases. For example, surround the SQL output of a
PRQL query in CREATE OR REPLACE TABLE foo AS (...).
{{</ faq >}}
{{< faq "Is it 'PRQL' or 'prql' or 'Prql'?" >}}
It's PRQL, since it's a backronym! We name the repo and some libraries prql
because of a strong convention around lowercase, but everywhere else we use
PRQL.
{{</ faq >}}
{{< faq "Where can I find the logos?" >}}
See our press materials.
{{</ faq >}}