Prql (prql_rs v0.1.0)
View SourcePRQL compiler for Elixir, powered by Rust's prqlc.
Summary
Types
@type dialect() :: Prql.Options.dialect()
@type display_option() :: Prql.Options.display_option()
@type option() :: Prql.Options.option()
@type options() :: Prql.Options.options()
Functions
Compiles a PRQL query to SQL.
Options
:format
- Whether to format the SQL output (default:false
):target
- The SQL dialect to target (optional, no default):signature_comment
- Whether to include the PRQL signature comment (default:false
):color
- Whether to enable color in the output (default:false
):display
- Display options for the output (:plain
or:ansi_color
, default::plain
)
Examples
iex> Prql.compile("from employees | select {name, age}")
{:ok, "SELECT name, age FROM employees"}
iex> Prql.compile("from employees | select {name, age}", target: :postgres)
{:ok, "SELECT name, age FROM employees"}
Returns {:ok, sql_string}
on success, or {:error, reason}
on failure.
Same as compile/2
but raises an exception if compilation fails.
Options
See compile/2
for available options.
Examples
iex> Prql.compile!("from employees | select {name, age}")
"SELECT name, age FROM employees"
iex> Prql.compile!("from employees | select {name, age}", target: :postgres)
"SELECT name, age FROM employees"
iex> Prql.compile!("invalid prql")
** (RuntimeError) PRQL compilation failed: ...