From 11d2cf2df08573140dee11464564f3c4c0917515 Mon Sep 17 00:00:00 2001 From: Tobias Brandt Date: Mon, 27 Mar 2023 21:13:14 +0200 Subject: [PATCH] Updates prql-compiler to 0.6.1 --- CHANGELOG.md | 1 + Cargo.lock | 135 +++++++-------------------- Cargo.toml | 2 +- examples/queries/invoice_totals.prql | 2 +- src/backends/duckdb.rs | 2 +- src/main.rs | 7 +- 6 files changed, 44 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f890e62..7cfb7b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Cargo.lock b/Cargo.lock index 4da2b0f..4e7076f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,15 +23,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" -dependencies = [ - "const-random", -] - [[package]] name = "ahash" version = "0.7.6" @@ -405,18 +396,6 @@ dependencies = [ "alloc-stdlib", ] -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", - "serde", -] - [[package]] name = "bumpalo" version = "3.11.0" @@ -530,11 +509,12 @@ dependencies = [ [[package]] name = "chumsky" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d02796e4586c6c41aeb68eae9bfb4558a522c35f1430c14b40136c3706e09e4" +checksum = "23170228b96236b5a7299057ac284a321457700bc8c41a4476052f0f4ba5349d" dependencies = [ - "ahash 0.3.8", + "hashbrown", + "stacker", ] [[package]] @@ -756,13 +736,12 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.6" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad" dependencies = [ - "bstr", "csv-core", - "itoa 0.4.8", + "itoa", "ryu", "serde", ] @@ -1474,12 +1453,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "itoa" version = "1.0.4" @@ -2102,50 +2075,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" -[[package]] -name = "pest" -version = "2.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab62d2fa33726dbe6321cc97ef96d8cde531e3eeaf858a058de53a8a6d40d8f" -dependencies = [ - "thiserror", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf026e2d0581559db66d837fe5242320f525d85c76283c61f4d51a1238d65ea" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b27bd18aa01d91c8ed2b61ea23406a676b42d82609c6e2581fba42f0c15f17f" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pest_meta" -version = "2.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02b677c1859756359fc9983c2e56a0237f18624a3789528804406b7e915e5d" -dependencies = [ - "once_cell", - "pest", - "sha2", -] - [[package]] name = "phf" version = "0.11.1" @@ -2394,9 +2323,9 @@ dependencies = [ [[package]] name = "prql-compiler" -version = "0.4.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "695c1a8eb470d6fcd9cda81a4af75a4c5add357b2c1f97d7c320216651acf78c" +checksum = "3c5098924ebff82cd2847af36083411397190e69eb93dd97b6b2ea01716505cd" dependencies = [ "anyhow", "ariadne", @@ -2407,14 +2336,12 @@ dependencies = [ "lazy_static", "log", "once_cell", - "pest", - "pest_derive", "regex", "semver", "serde", "serde_json", "sqlformat", - "sqlparser 0.30.0", + "sqlparser 0.32.0", "strum 0.24.1", "strum_macros 0.24.3", ] @@ -2444,6 +2371,15 @@ dependencies = [ "url", ] +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + [[package]] name = "quad-rand" version = "0.2.1" @@ -2571,12 +2507,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - [[package]] name = "regex-syntax" version = "0.6.27" @@ -2718,7 +2648,7 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" dependencies = [ - "itoa 1.0.4", + "itoa", "ryu", "serde", ] @@ -2871,14 +2801,27 @@ dependencies = [ [[package]] name = "sqlparser" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db67dc6ef36edb658196c3fef0464a80b53dbbc194a904e81f9bd4190f9ecc5b" +checksum = "0366f270dbabb5cc2e4c88427dc4c08bba144f81e32fbd459a013f26a4d16aa0" dependencies = [ "log", "serde", ] +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "winapi", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -3179,12 +3122,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" -[[package]] -name = "ucd-trie" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" - [[package]] name = "uncased" version = "0.9.7" @@ -3268,7 +3205,7 @@ checksum = "c0a635407649b66e125e4d2ffd208153210179f8c7c8b71c030aa2ad3eeb4c8f" dependencies = [ "float-cmp", "halfbrown", - "itoa 1.0.4", + "itoa", "ryu", ] diff --git a/Cargo.toml b/Cargo.toml index b24c5b3..9c26eb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/examples/queries/invoice_totals.prql b/examples/queries/invoice_totals.prql index 11d53e8..4e0bc01 100644 --- a/examples/queries/invoice_totals.prql +++ b/examples/queries/invoice_totals.prql @@ -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})", diff --git a/src/backends/duckdb.rs b/src/backends/duckdb.rs index 121b55b..a0ede73 100644 --- a/src/backends/duckdb.rs +++ b/src/backends/duckdb.rs @@ -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() diff --git a/src/main.rs b/src/main.rs index 156ac69..5c65e72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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")] { @@ -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:?}"); @@ -276,7 +277,7 @@ fn get_dest_from_to(to: &str) -> Result> { fn get_sql_from_query(query: &str) -> Result { 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() };