MyNixOS website logo
Description

R Bindings for the 'prqlc' Rust Library.

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.

prqlr

prqlr statusbadge CRANstatus

R bindings for the prqlc Rust library, powered by savvy.

This version supports PRQL 0.11.2.

Installation

Requires R 4.2.0 or later.

This package can be installed from CRAN or R-universe. If available, a binary package will be installed.

# Install from CRAN
install.packages("prqlr")
# Install from R-universe
install.packages("prqlr", repos = "https://prql.r-universe.dev")

For source installation, pre-built Rust libraries may be available if the environment variable NOT_CRAN is set to "true". (Or, set LIBPRQLR_BUILD to "false")

Sys.setenv(NOT_CRAN = "true")
install.packages("prqlr")

Or, the Rust toolchain (Rust 1.65 or later) must be configured to build the Rust library.

Please check the https://github.com/r-rust/hellorust repository for about Rust code in R packages.

Examples

library(prqlr)

"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
  prql_compile() |>
  cat()
#> SELECT
#>   cyl,
#>   mpg
#> FROM
#>   mtcars
#> WHERE
#>   cyl > 6
#> 
#> -- Generated by PRQL compiler version:0.11.2 (https://prql-lang.org)

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

"from mtcars \n filter cyl > 6 \n select {cyl, mpg}" |>
  prql_compile() |>
  cat()
#> SELECT
#>   cyl,
#>   mpg
#> FROM
#>   mtcars
#> WHERE
#>   cyl > 6
#> 
#> -- Generated by PRQL compiler version:0.11.2 (https://prql-lang.org)
"from mtcars
filter cyl > 6
select {cyl, mpg}" |>
  prql_compile() |>
  cat()
#> SELECT
#>   cyl,
#>   mpg
#> FROM
#>   mtcars
#> WHERE
#>   cyl > 6
#> 
#> -- Generated by PRQL compiler version:0.11.2 (https://prql-lang.org)

Thanks to the {tidyquery} package, we can even convert a PRQL query to a SQL query and then to a {dplyr} query!

"from mtcars
filter cyl > 6
select {cyl, mpg}" |>
  prql_compile() |>
  tidyquery::show_dplyr()
#> mtcars %>%
#>   filter(cyl > 6) %>%
#>   select(cyl, mpg)

{knitr} integration

Using {prqlr} with {knitr} makes it easy to create documents that lists PRQL queries and a translated SQL queries, or documents that lists PRQL queries and tables of data retrieved by PRQL queries.

Please check the vignette vignette("knitr", "prqlr") for details.

Metadata

Version

0.8.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows