Target & Version

Target dialect

PRQL allows specifying a target dialect at the top of the query, which allows PRQL to compile to a database-specific SQL flavor.

Examples

PRQL

  1. prql target:sql.postgres
  2. from employees
  3. sort age
  4. take 10

SQL

  1. SELECT
  2. *
  3. FROM
  4. employees
  5. ORDER BY
  6. age
  7. LIMIT
  8. 10

PRQL

  1. prql target:sql.mssql
  2. from employees
  3. sort age
  4. take 10

SQL

  1. SELECT
  2. TOP (10) *
  3. FROM
  4. employees
  5. ORDER BY
  6. age

Supported dialects

Note

Note that dialect support is early — most differences are not implemented, and most dialects’ implementations are identical to generic’s. Contributions are very welcome.

  • sql.ansi
  • sql.bigquery
  • sql.clickhouse
  • sql.generic
  • sql.hive
  • sql.mssql
  • sql.mysql
  • sql.postgres
  • sql.sqlite
  • sql.snowflake
  • sql.duckdb

Version

PRQL allows specifying a version of the language in the PRQL header, like:

PRQL

  1. prql version:"0.8.0"
  2. from employees

SQL

  1. SELECT
  2. *
  3. FROM
  4. employees

This has two roles, one of which is implemented:

  • The compiler will raise an error if the compiler is older than the query version. This prevents confusing errors when queries use newer features of the language but the compiler hasn’t yet been upgraded.
  • The compiler will compile for the major version of the query. This allows the language to evolve without breaking existing queries, or forcing multiple installations of the compiler. This isn’t yet implemented, but is a gating feature for PRQL 1.0.