From acf3b655f3bfc70474c27ed62dd413697b1aadd5 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Sat, 17 Jun 2023 03:21:03 +0000 Subject: [PATCH] fix: update to adopt latest dev prql-compiler --- LICENSE.note | 168 +++++++++++++++++++++++++++++++ src/rust/src/lib.rs | 2 +- tests/testthat/_snaps/compile.md | 100 +++++++----------- tests/testthat/test-compile.R | 6 +- vignettes/prqlr.Rmd | 6 +- 5 files changed, 213 insertions(+), 69 deletions(-) diff --git a/LICENSE.note b/LICENSE.note index 2d9d431d..8624ba2f 100644 --- a/LICENSE.note +++ b/LICENSE.note @@ -31,6 +31,41 @@ License: MIT OR Unlicense ------------------------------------------------------------- +Name: anstream +Repository: https://github.com/rust-cli/anstyle.git +Authors: anstream authors +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: anstyle +Repository: https://github.com/rust-cli/anstyle.git +Authors: anstyle authors +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: anstyle-parse +Repository: https://github.com/rust-cli/anstyle.git +Authors: anstyle-parse authors +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: anstyle-query +Repository: https://github.com/rust-cli/anstyle +Authors: anstyle-query authors +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: anstyle-wincon +Repository: https://github.com/rust-cli/anstyle.git +Authors: anstyle-wincon authors +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + Name: anyhow Repository: https://github.com/dtolnay/anyhow Authors: David Tolnay @@ -52,6 +87,13 @@ License: Apache-2.0 OR MIT ------------------------------------------------------------- +Name: bitflags +Repository: https://github.com/bitflags/bitflags +Authors: The Rust Project Developers +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + Name: cfg-if Repository: https://github.com/alexcrichton/cfg-if Authors: Alex Crichton @@ -66,6 +108,13 @@ License: MIT ------------------------------------------------------------- +Name: colorchoice +Repository: https://github.com/rust-cli/anstyle +Authors: colorchoice authors +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + Name: csv Repository: https://github.com/BurntSushi/rust-csv Authors: Andrew Gallant @@ -94,6 +143,20 @@ License: Apache-2.0 OR MIT ------------------------------------------------------------- +Name: errno +Repository: https://github.com/lambda-fairy/rust-errno +Authors: Chris Wong +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: errno-dragonfly +Repository: https://github.com/mneumann/errno-dragonfly-rs +Authors: Michael Neumann +License: MIT + +------------------------------------------------------------- + Name: extendr-api Repository: https://github.com/extendr/extendr Authors: andy-thomason, Thomas Down, Mossa Merhi Reimert, Claus O. Wilke, Hiroaki Yutani, Ilia A. Kosenkov, Michael Milton @@ -143,6 +206,13 @@ License: Apache-2.0 OR MIT ------------------------------------------------------------- +Name: hermit-abi +Repository: https://github.com/hermitcore/rusty-hermit +Authors: Stefan Lankes +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + Name: indexmap Repository: https://github.com/bluss/indexmap Authors: indexmap authors @@ -150,6 +220,20 @@ License: Apache-2.0 OR MIT ------------------------------------------------------------- +Name: io-lifetimes +Repository: https://github.com/sunfishcode/io-lifetimes +Authors: Dan Gohman +License: Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT + +------------------------------------------------------------- + +Name: is-terminal +Repository: https://github.com/sunfishcode/is-terminal +Authors: softprops, Dan Gohman +License: MIT + +------------------------------------------------------------- + Name: itertools Repository: https://github.com/rust-itertools/itertools Authors: bluss @@ -185,6 +269,13 @@ License: Apache-2.0 OR MIT ------------------------------------------------------------- +Name: linux-raw-sys +Repository: https://github.com/sunfishcode/linux-raw-sys +Authors: Dan Gohman +License: Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT + +------------------------------------------------------------- + Name: log Repository: https://github.com/rust-lang/log Authors: The Rust Project Developers @@ -290,6 +381,13 @@ License: Apache-2.0 OR MIT ------------------------------------------------------------- +Name: rustix +Repository: https://github.com/bytecodealliance/rustix +Authors: Dan Gohman, Jakub Konka +License: Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT + +------------------------------------------------------------- + Name: rustversion Repository: https://github.com/dtolnay/rustversion Authors: David Tolnay @@ -416,6 +514,13 @@ License: MIT ------------------------------------------------------------- +Name: utf8parse +Repository: https://github.com/alacritty/vte +Authors: Joe Wilm, Christian Duerr +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + Name: wasi Repository: https://github.com/bytecodealliance/wasi Authors: The Cranelift Project Developers @@ -444,6 +549,69 @@ License: Apache-2.0 OR MIT ------------------------------------------------------------- +Name: windows-sys +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows-targets +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows_aarch64_gnullvm +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows_aarch64_msvc +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows_i686_gnu +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows_i686_msvc +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows_x86_64_gnu +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows_x86_64_gnullvm +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + +Name: windows_x86_64_msvc +Repository: https://github.com/microsoft/windows-rs +Authors: Microsoft +License: Apache-2.0 OR MIT + +------------------------------------------------------------- + Name: yansi Repository: https://github.com/SergioBenitez/yansi Authors: Sergio Benitez diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 85b0f604..56c1af50 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -31,7 +31,7 @@ pub fn compile( .and_then(prql_compiler::pl_to_rq) .and_then(|rq| prql_compiler::rq_to_sql(rq, &opts)) }) - .map_err(|e| e.composed(&prql_query.into(), false)); + .map_err(|e| e.composed(&prql_query.into())); r_result_list(result) } diff --git a/tests/testthat/_snaps/compile.md b/tests/testthat/_snaps/compile.md index 75e3fffc..d4d4b3e1 100644 --- a/tests/testthat/_snaps/compile.md +++ b/tests/testthat/_snaps/compile.md @@ -36,55 +36,55 @@ Code cat(prql_compile(query, "sql.any", TRUE, FALSE)) Error - Error: - ╭─[:1:23] - │ - 1 │ Mississippi has four S’s and four I’s. - │ ┬ - │ ╰── unexpected ’ - ───╯ - Error: - ╭─[:1:36] - │ - 1 │ Mississippi has four S’s and four I’s. - │ ┬ - │ ╰── unexpected ’ - ───╯ - Error: - ╭─[:1:38] - │ - 1 │ Mississippi has four S’s and four I’s. - │ ┬ - │ ╰── Expected * or an identifier, but didn't find anything before the end. - ───╯ + Error: + ╭─[:1:23] + │ + 1 │ Mississippi has four S’s and four I’s. +  │ ┬ +  │ ╰── unexpected ’ + ───╯ + Error: + ╭─[:1:36] + │ + 1 │ Mississippi has four S’s and four I’s. +  │ ┬ +  │ ╰── unexpected ’ + ───╯ + Error: + ╭─[:1:38] + │ + 1 │ Mississippi has four S’s and four I’s. +  │ ┬ +  │ ╰── Expected * or an identifier, but didn't find anything before the end. + ───╯ # Syntax error query=from a | select [b] Code cat(prql_compile(query, "sql.any", TRUE, FALSE)) Error - Error: - ╭─[:1:17] - │ - 1 │ from a | select [b] - │ ─┬─ - │ ╰─── unexpected `[_frame.a.b]` - │ - │ Help: this is probably a 'bad type' error (we are working on that) - ───╯ + Error: + ╭─[:1:17] + │ + 1 │ from a | select [b] +  │ ─┬─ +  │ ╰─── unexpected `[_frame.a.b]` +  │ +  │ Help: this is probably a 'bad type' error (we are working on that) + ───╯ # Syntax error query=from a | select {{{b Code cat(prql_compile(query, "sql.any", TRUE, FALSE)) Error - Error: - ╭─[:1:20] - │ - 1 │ from a | select {{{b - │ ┬ - │ ╰── unexpected end of input while parsing function call - ───╯ + Error: + ╭─[:1:20] + │ + 1 │ from a | select {{{b +  │ ┬ +  │ ╰── unexpected end of input while parsing function call + ───╯ # Targets target=sql.any @@ -230,30 +230,6 @@ LIMIT 2 -# Targets target=sql.hive - - Code - cat(prql_compile(query, target, TRUE, FALSE)) - Output - SELECT - origin, - dest, - COUNT(*) AS num_flts, - ROUND(AVG(arr_delay), 0) AS avg_delay - FROM - flights - WHERE - distance BETWEEN 200 AND 300 - AND air_time IS NOT NULL - GROUP BY - origin, - dest - ORDER BY - origin DESC, - avg_delay - LIMIT - 2 - # Targets target=sql.mssql Code @@ -309,7 +285,7 @@ origin, dest, COUNT(*) AS num_flts, - ROUND(AVG(arr_delay), 0) AS avg_delay + ROUND((AVG(arr_delay)) :: numeric, 0) AS avg_delay FROM flights WHERE diff --git a/tests/testthat/test-compile.R b/tests/testthat/test-compile.R index ecb21d1f..472906ec 100644 --- a/tests/testthat/test-compile.R +++ b/tests/testthat/test-compile.R @@ -71,19 +71,19 @@ patrick::with_parameters_test_that("Syntax error", patrick::with_parameters_test_that("Targets", { - query <- " + query <- r"( from flights filter (distance | in 200..300) filter air_time != null group {origin, dest} ( aggregate { - num_flts = count, + num_flts = count s"*", avg_delay = (average arr_delay | round 0) } ) sort {-origin, avg_delay} take 2 -" +)" expect_snapshot(cat(prql_compile(query, target, TRUE, FALSE))) }, target = prql_get_targets() diff --git a/vignettes/prqlr.Rmd b/vignettes/prqlr.Rmd index f1ef3b83..2268fb8c 100644 --- a/vignettes/prqlr.Rmd +++ b/vignettes/prqlr.Rmd @@ -106,19 +106,19 @@ Let's run a query that aggregates a Data Frame `flights`, contained in the `{nyc library(tidyquery) library(nycflights13) -" +r"( from flights filter (distance | in 200..300) filter air_time != null group {origin, dest} ( aggregate { - num_flts = count, + num_flts = count s"*", avg_delay = (average arr_delay | round 0) } ) sort {-origin, avg_delay} take 2 -" |> +)" |> prql_compile() |> query() ```