Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: bump prql-compiler to unreleased 0.9.0 #130

Merged
merged 9 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Description:
Provides a function to convert 'PRQL' strings to 'SQL' strings.
Combined with other R functions that take 'SQL' as an argument,
'PRQL' can be used on R.
Version: 0.4.0.9000
Version: 0.4.0.9001
Authors@R:
person("Tatsuya", "Shima", email = "ts1s1andn@gmail.com", role = c("aut", "cre"))
URL: https://eitsupi.github.io/prqlr/, https://github.com/eitsupi/prqlr
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# prqlr (development version)

## Breaking changes

- Based on [`prql-compiler`](https://github.com/prql/prql) 0.9.0 (#130)

# prqlr 0.4.0

## Breaking changes
Expand Down
8 changes: 4 additions & 4 deletions R/compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#' @return a SQL query string
#' @seealso [prql_get_targets]
#' @examples
#' "from mtcars | filter cyl > 6 | select [cyl, mpg]" |>
#' "from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
#' prql_compile()
#'
#' "from mtcars | filter cyl > 6 | select [cyl, mpg]" |>
#' "from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
#' prql_compile(format = FALSE, signature_comment = FALSE)
#'
#' "
#' from mtcars
#' filter cyl > 6
#' select ![cyl]
#' select !{cyl}
#' " |>
#' prql_compile("sql.duckdb") |>
#' cat()
Expand All @@ -28,7 +28,7 @@
#'
#' from mtcars
#' filter cyl > 6
#' select ![cyl]
#' select !{cyl}
#' " |>
#' prql_compile() |>
#' cat()
Expand Down
8 changes: 4 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ Please check the <https://github.com/r-rust/hellorust> repository for about Rust

```{r}
library(prqlr)
"from mtcars | filter cyl > 6 | select [cyl, mpg]" |>
"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
prql_compile() |>
cat()
```

PRQL's pipelines can be joined by the newline character (`\n`), or actual newlines in addition to `|`.

```{r}
"from mtcars \n filter cyl > 6 \n select [cyl, mpg]" |>
"from mtcars \n filter cyl > 6 \n select {cyl, mpg}" |>
prql_compile() |>
cat()
```

```{r}
"from mtcars
filter cyl > 6
select [cyl, mpg]" |>
select {cyl, mpg}" |>
prql_compile() |>
cat()
```
Expand All @@ -79,7 +79,7 @@ we can even convert a PRQL query to a SQL query and then to a `{dplyr}` query!
```{r}
"from mtcars
filter cyl > 6
select [cyl, mpg]" |>
select {cyl, mpg}" |>
prql_compile() |>
tidyquery::show_dplyr()
```
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ install.packages("prqlr")
install.packages("prqlr", repos = "https://eitsupi.r-universe.dev")
```

For source installation, the Rust toolchain (Rust 1.61 or later) must be
For source installation, the Rust toolchain (Rust 1.65 or later) must be
configured. Please check the <https://github.com/r-rust/hellorust>
repository for about Rust code in R packages.

## Examples

``` r
library(prqlr)
"from mtcars | filter cyl > 6 | select [cyl, mpg]" |>
"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
prql_compile() |>
cat()
#> SELECT
Expand All @@ -61,7 +61,7 @@ PRQL’s pipelines can be joined by the newline character (`\n`), or
actual newlines in addition to `|`.

``` r
"from mtcars \n filter cyl > 6 \n select [cyl, mpg]" |>
"from mtcars \n filter cyl > 6 \n select {cyl, mpg}" |>
prql_compile() |>
cat()
#> SELECT
Expand All @@ -78,7 +78,7 @@ actual newlines in addition to `|`.
``` r
"from mtcars
filter cyl > 6
select [cyl, mpg]" |>
select {cyl, mpg}" |>
prql_compile() |>
cat()
#> SELECT
Expand All @@ -98,7 +98,7 @@ a SQL query and then to a `{dplyr}` query!
``` r
"from mtcars
filter cyl > 6
select [cyl, mpg]" |>
select {cyl, mpg}" |>
prql_compile() |>
tidyquery::show_dplyr()
#> mtcars %>%
Expand Down
8 changes: 4 additions & 4 deletions man/prql_compile.Rd

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

6 changes: 3 additions & 3 deletions src/rust/Cargo.lock

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

4 changes: 2 additions & 2 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "prqlr"
version = "0.1.0"
edition = "2021"
rust-version = "1.61"
rust-version = "1.65"

[lib]
crate-type = ['staticlib']
Expand All @@ -13,4 +13,4 @@ extendr-api = "0.4.0"
# extendr-api = { git = "https://github.com/extendr/extendr", rev = "e0326174278ece5d28690a16234eea25b1ccf884" }
# prql-compiler = { version = "0.8.1", default-features = false }
# prql-compiler 0.8.1 is not compatible with Rust 1.64, so a slightly modified version is installed from the fork. https://github.com/PRQL/prql/pull/1561
prql-compiler = { git = "https://github.com/eitsupi/prql", rev = "a3841742ad740370896a695b97f0e9c3f2374261", default-features = false }
prql-compiler = { git = "https://github.com/PRQL/prql", rev = "d786a8b4969a2f7423cbffe4bffef2bc84b982fa", default-features = false }
4 changes: 2 additions & 2 deletions 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, false));
.map_err(|e| e.composed(&prql_query.into(), false));

r_result_list(result)
}
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn rq_to_sql(rq_json: &str) -> List {
/// @noRd
#[extendr]
pub fn compiler_version() -> String {
prql_compiler::PRQL_VERSION.to_string()
prql_compiler::COMPILER_VERSION.to_string()
}

/// @title Get available target names
Expand Down
27 changes: 11 additions & 16 deletions tests/testthat/_snaps/compile.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PRQL query

Code
cat(prql_compile("from a | select [b]"))
cat(prql_compile("from a | select {b}"))
Output
SELECT
b
Expand All @@ -13,15 +13,15 @@
---

Code
cat(prql_compile("from a | select [b]", NA, FALSE, FALSE))
cat(prql_compile("from a | select {b}", NA, FALSE, FALSE))
Output
SELECT b FROM a

---

Code
cat(unwrap(compile(
"from star_wars\n select [star_wars.*]\n select ![jar_jar_binks, midichlorians]",
"from star_wars\n select {star_wars.*}\n select !{jar_jar_binks, midichlorians}",
"sql.duckdb", TRUE, TRUE)))
Output
SELECT
Expand Down Expand Up @@ -58,24 +58,19 @@
│ ╰── Expected * or an identifier, but didn't find anything before the end.
───╯

# Syntax error query=from a | select {b}
# 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 {
───╯
Error:
╭─[:1:19]
1 │ from a | select [b]
│ ─┬─
│ ╰─── unexpected `[_frame.a.b]`
1 │ from a | select {b}
│ ┬
│ ╰── unexpected }
│ Help: this is probably a 'bad type' error (we are working on that)
───╯

# Syntax error query=from a | select {{{b
Expand All @@ -84,11 +79,11 @@
cat(prql_compile(query, "sql.any", TRUE, FALSE))
Error <simpleError>
Error:
╭─[:1:17]
╭─[:1:20]
1 │ from a | select {{{b
│ ┬
│ ╰── unexpected {
╰── unexpected end of input while parsing function call
───╯

# Targets target=sql.any
Expand Down
40 changes: 20 additions & 20 deletions tests/testthat/_snaps/knitr-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand All @@ -29,8 +29,8 @@
```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand All @@ -57,8 +57,8 @@
```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand All @@ -77,8 +77,8 @@
```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand All @@ -104,8 +104,8 @@
```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand Down Expand Up @@ -166,8 +166,8 @@
```prql
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand All @@ -192,8 +192,8 @@
```foo
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand All @@ -218,8 +218,8 @@
```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand Down Expand Up @@ -249,17 +249,17 @@
```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```


```elm
from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
select {cyl, mpg}
derive {mpg_int = round 0 mpg}
take 3
```

Expand Down
Loading