Compile a PRQL query into a SQL query
Arguments
- prql_query
a PRQL query string.
- target
a compile target name to use. If not specified (
NULL
), the target contained in the query will be used. All available target names can be listed with the prql_get_targets function.- format
a logical flag (default:
TRUE
). Whether to format the SQL query.- signature_comment
a logical flag. (default:
TRUE
). Whether to add a signature comment to the output SQL query.
Examples
"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
prql_compile()
#> [1] "SELECT\n cyl,\n mpg\nFROM\n mtcars\nWHERE\n cyl > 6\n\n-- Generated by PRQL compiler version:0.13.0 (https://prql-lang.org)\n"
"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
prql_compile(format = FALSE, signature_comment = FALSE)
#> [1] "SELECT cyl, mpg FROM mtcars WHERE cyl > 6"
"
from mtcars
filter cyl > 6
select !{cyl}
" |>
prql_compile("sql.duckdb") |>
cat()
#> SELECT
#> * EXCLUDE (cyl)
#> FROM
#> mtcars
#> WHERE
#> cyl > 6
#>
#> -- Generated by PRQL compiler version:0.13.0 target:sql.duckdb (https://prql-lang.org)
# If the `target` argument is `NULL` (default) or `"sql.any"`,
# the target specified in the header of the query will be used.
"
prql target:sql.duckdb
from mtcars
filter cyl > 6
select !{cyl}
" |>
prql_compile() |>
cat()
#> SELECT
#> * EXCLUDE (cyl)
#> FROM
#> mtcars
#> WHERE
#> cyl > 6
#>
#> -- Generated by PRQL compiler version:0.13.0 (https://prql-lang.org)