Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Commit

Permalink
Updates prql-compiler to 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Brandt authored and Tobias Brandt committed Mar 27, 2023
1 parent a61aaa8 commit 11d2cf2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 105 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Adds --version parameter (#29, @eitsupi)
* Updates prql-compiler to 0.4.2 (#27, @aljazerzen)
* Updates prql-compiler to 0.6.1 (@snth)

## 0.0.14 - 2022-11-09

Expand Down
135 changes: 36 additions & 99 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env_logger = "0.9.0"
log = "0.4.17"
parquet = { version = "23", optional = true }
polars = { version = "0.24.2", optional = true, features = ["docs-selection"] }
prql-compiler = { version = "0.4.2" }
prql-compiler = { version = "0.6.1" }
regex = { version = "1.6.0", optional = true }
tokio = { version = "1.19", features = ["rt-multi-thread", "macros"] }
url = "2"
Expand Down
2 changes: 1 addition & 1 deletion examples/queries/invoice_totals.prql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from i=invoices
join ii=invoice_items [invoice_id]
join ii=invoice_items [==invoice_id]
derive [
month = s"STRFTIME('%Y-%m', {i.invoice_date})",
day = s"STRFTIME('%Y-%m-%d', {i.invoice_date})",
Expand Down
2 changes: 1 addition & 1 deletion src/backends/duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn query(

Ok(stmts)
.and_then(prql_compiler::pl_to_rq)
.and_then(|rq| prql_compiler::rq_to_sql(rq, None))
.and_then(|rq| prql_compiler::rq_to_sql(rq, &prql_compiler::Options::default()))
.map_err(|e| anyhow!(e))?
} else {
query.to_string()
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::prelude::*;
use std::{fs, io};

use clap::{Parser, ValueEnum};
use prql_compiler::{compile, PRQL_VERSION};
use prql_compiler::{compile, Options, PRQL_VERSION};

cfg_if::cfg_if! {
if #[cfg(feature = "datafusion")] {
Expand Down Expand Up @@ -152,7 +152,8 @@ fn main() -> Result<()> {
// args.sql
if !args.sql && !query.starts_with("prql ") {
// prepend a PRQL header to signal this is a PRQL query rather than a SQL one
query = format!("prql version:'0.4' target:sql.generic\n{query}")
// FIXME: When the backend is DuckDB, the target should be sql.duckdb
query = format!("prql version:'{}' target:sql.generic\n{query}", PRQL_VERSION.to_string())
}
debug!("query = {query:?}");

Expand Down Expand Up @@ -276,7 +277,7 @@ fn get_dest_from_to(to: &str) -> Result<Box<dyn Write>> {

fn get_sql_from_query(query: &str) -> Result<String> {
let sql = if query.starts_with("prql ") {
compile(query, None).map_err(|e| anyhow!(e))?
compile(query, &Options::default()).map_err(|e| anyhow!(e))?
} else {
query.to_string()
};
Expand Down

0 comments on commit 11d2cf2

Please sign in to comment.