prql_compile {prqlr}R Documentation

Compile a PRQL query into a SQL query

Description

Compile a PRQL query into a SQL query

Usage

prql_compile(
  prql_query,
  target = getOption("prqlr.target", default = NULL),
  format = getOption("prqlr.format", default = TRUE),
  signature_comment = getOption("prqlr.signature_comment", default = TRUE)
)

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.

Value

a SQL query string

See Also

prql_get_targets

Examples

"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
  prql_compile()

"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
  prql_compile(format = FALSE, signature_comment = FALSE)

"
from mtcars
filter cyl > 6
select !{cyl}
" |>
  prql_compile("sql.duckdb") |>
  cat()

# 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()

[Package prqlr version 0.8.1 Index]