Adding PRQL Support to GlareDB
tl;dr> Last week we announced GlareDB Pro in v0.6.0, along with a host of other features including experimental support for PRQL. We are excited about this change and want to show you what it's all about!
PRQL
PRQL is a domain-specific language for querying and transforming data, built around the metaphor of a pipeline. You can envision data flowing through a statement with selections, filtering, field removal, computed fields, and aggregating the results.
PRQL can be translated to SQL. Rather than building or modifying an existing database engine to support PRQL, the PRQL compiler is used to translate PRQL queries to SQL. This works with most SQL databases, including GlareDB, today. However, without PRQL support in the database engine, the responsibility for handling PRQL moves up a layer to the application and becomes difficult for more interactive cases where you'd need to write a PRQL query, translate it to SQL and then run it.
Now with official support for PRQL in GlareDB v0.6.0, all you have to do is set the dialect!
Using PRQL in GlareDB
Ensure you're on GlareDB v0.6.0 or later. If you need to update, just run:
curl https://glaredb.com/install.sh | sh
Now with official support for PRQL in GlareDB, you can set the dialect to PRQL:
set dialect = 'prql';
FROM my_table | take 1
To go back to writing SQL, just set the dialect back to SQL:
set dialect = 'sql';
Python
In the glaredb python client:
con = glaredb.connect()
con.execute('set dialect = prql')
con.sql('from my_table | take 1').show()
All subsequent .sql()
calls on this connection object will use PRQL, until the
dialect is changed. That's it!
More to come
If you encounter any issues, please open an issue in the GlareDB project.
There's more work to be done on this integration, of course, but we wanted to get it into your hands soon while we continue to work on it. Things we're thinking of:
- simple functions for loading data and interacting with GlareDB specifics within PRQL
- a PRQL stage for the
COPY
operator - improved validation, and interfaces in the Python bindings and local client
- other changes based on your feedback
Give it a try, and tell us what you think!
Get started now
Ready to get the most out of your data? Get started with GlareDB locally, or spin up a deployment on GlareDB Cloud!