Skip to content

Commit

Permalink
fix: update to adopt latest dev prql-compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Jun 17, 2023
1 parent cc784a4 commit acf3b65
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 69 deletions.
168 changes: 168 additions & 0 deletions LICENSE.note
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -143,13 +206,34 @@ 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
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
100 changes: 38 additions & 62 deletions tests/testthat/_snaps/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,55 @@
Code
cat(prql_compile(query, "sql.any", TRUE, FALSE))
Error <simpleError>
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.
───╯
[31mError:[0m
[38;5;246m╭[0m[38;5;246m─[0m[38;5;246m[[0m:1:23[38;5;246m][0m
[38;5;246m│[0m
[38;5;246m1 │[0m [38;5;249mM[0m[38;5;249mi[0m[38;5;249ms[0m[38;5;249ms[0m[38;5;249mi[0m[38;5;249ms[0m[38;5;249ms[0m[38;5;249mi[0m[38;5;249mp[0m[38;5;249mp[0m[38;5;249mi[0m[38;5;249m [0m[38;5;249mh[0m[38;5;249ma[0m[38;5;249ms[0m[38;5;249m [0m[38;5;249mf[0m[38;5;249mo[0m[38;5;249mu[0m[38;5;249mr[0m[38;5;249m [0m[38;5;249mS[0m’[38;5;249ms[0m[38;5;249m [0m[38;5;249ma[0m[38;5;249mn[0m[38;5;249md[0m[38;5;249m [0m[38;5;249mf[0m[38;5;249mo[0m[38;5;249mu[0m[38;5;249mr[0m[38;5;249m [0m[38;5;249mI[0m[38;5;249m’[0m[38;5;249ms[0m[38;5;249m.[0m
[38;5;240m[0m
[38;5;240m[0m ╰── unexpected ’
[38;5;246m───╯[0m
[31mError:[0m
[38;5;246m╭[0m[38;5;246m─[0m[38;5;246m[[0m:1:36[38;5;246m][0m
[38;5;246m│[0m
[38;5;246m1 │[0m [38;5;249mM[0m[38;5;249mi[0m[38;5;249ms[0m[38;5;249ms[0m[38;5;249mi[0m[38;5;249ms[0m[38;5;249ms[0m[38;5;249mi[0m[38;5;249mp[0m[38;5;249mp[0m[38;5;249mi[0m[38;5;249m [0m[38;5;249mh[0m[38;5;249ma[0m[38;5;249ms[0m[38;5;249m [0m[38;5;249mf[0m[38;5;249mo[0m[38;5;249mu[0m[38;5;249mr[0m[38;5;249m [0m[38;5;249mS[0m[38;5;249m’[0m[38;5;249ms[0m[38;5;249m [0m[38;5;249ma[0m[38;5;249mn[0m[38;5;249md[0m[38;5;249m [0m[38;5;249mf[0m[38;5;249mo[0m[38;5;249mu[0m[38;5;249mr[0m[38;5;249m [0m[38;5;249mI[0m’[38;5;249ms[0m[38;5;249m.[0m
[38;5;240m[0m
[38;5;240m[0m ╰── unexpected ’
[38;5;246m───╯[0m
[31mError:[0m
[38;5;246m╭[0m[38;5;246m─[0m[38;5;246m[[0m:1:38[38;5;246m][0m
[38;5;246m│[0m
[38;5;246m1 │[0m [38;5;249mM[0m[38;5;249mi[0m[38;5;249ms[0m[38;5;249ms[0m[38;5;249mi[0m[38;5;249ms[0m[38;5;249ms[0m[38;5;249mi[0m[38;5;249mp[0m[38;5;249mp[0m[38;5;249mi[0m[38;5;249m [0m[38;5;249mh[0m[38;5;249ma[0m[38;5;249ms[0m[38;5;249m [0m[38;5;249mf[0m[38;5;249mo[0m[38;5;249mu[0m[38;5;249mr[0m[38;5;249m [0m[38;5;249mS[0m[38;5;249m’[0m[38;5;249ms[0m[38;5;249m [0m[38;5;249ma[0m[38;5;249mn[0m[38;5;249md[0m[38;5;249m [0m[38;5;249mf[0m[38;5;249mo[0m[38;5;249mu[0m[38;5;249mr[0m[38;5;249m [0m[38;5;249mI[0m[38;5;249m’[0m[38;5;249ms[0m.
[38;5;240m[0m
[38;5;240m[0m ╰── Expected * or an identifier, but didn't find anything before the end.
[38;5;246m───╯[0m

# Syntax error query=from a | select [b]

Code
cat(prql_compile(query, "sql.any", TRUE, FALSE))
Error <simpleError>
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)
───╯
[31mError:[0m
[38;5;246m╭[0m[38;5;246m─[0m[38;5;246m[[0m:1:17[38;5;246m][0m
[38;5;246m│[0m
[38;5;246m1 │[0m [38;5;249mf[0m[38;5;249mr[0m[38;5;249mo[0m[38;5;249mm[0m[38;5;249m [0m[38;5;249ma[0m[38;5;249m [0m[38;5;249m|[0m[38;5;249m [0m[38;5;249ms[0m[38;5;249me[0m[38;5;249ml[0m[38;5;249me[0m[38;5;249mc[0m[38;5;249mt[0m[38;5;249m [0m[b]
[38;5;240m[0m ─┬─
[38;5;240m[0m ╰─── unexpected `[_frame.a.b]`
[38;5;240m[0m
[38;5;240m[0m [38;5;115mHelp[0m: this is probably a 'bad type' error (we are working on that)
[38;5;246m───╯[0m

# Syntax error query=from a | select {{{b

Code
cat(prql_compile(query, "sql.any", TRUE, FALSE))
Error <simpleError>
Error:
╭─[:1:20]
1 │ from a | select {{{b
│ ┬
│ ╰── unexpected end of input while parsing function call
───╯
[31mError:[0m
[38;5;246m╭[0m[38;5;246m─[0m[38;5;246m[[0m:1:20[38;5;246m][0m
[38;5;246m│[0m
[38;5;246m1 │[0m [38;5;249mf[0m[38;5;249mr[0m[38;5;249mo[0m[38;5;249mm[0m[38;5;249m [0m[38;5;249ma[0m[38;5;249m [0m[38;5;249m|[0m[38;5;249m [0m[38;5;249ms[0m[38;5;249me[0m[38;5;249ml[0m[38;5;249me[0m[38;5;249mc[0m[38;5;249mt[0m[38;5;249m [0m[38;5;249m{[0m[38;5;249m{[0m[38;5;249m{[0mb
[38;5;240m[0m
[38;5;240m[0m ╰── unexpected end of input while parsing function call
[38;5;246m───╯[0m

# Targets target=sql.any

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit acf3b65

Please sign in to comment.