| Type: | Package | 
| Title: | Executes 'SQL' Statements | 
| Version: | 0.1.1 | 
| Description: | Runs 'SQL' statements on in-memory data frames within a temporary in-memory 'duckdb' data base. | 
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] | 
| Encoding: | UTF-8 | 
| ByteCompile: | yes | 
| Depends: | R (≥ 4.1.0) | 
| Imports: | DBI, duckdb, arrow, stringr | 
| NeedsCompilation: | no | 
| Packaged: | 2023-05-25 08:59:25 UTC; H2IZGK | 
| Author: | Jean-Luc Lipatz [aut, cre, cph] | 
| Maintainer: | Jean-Luc Lipatz <jllipatz@protonmail.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2023-05-25 09:20:13 UTC | 
Run duckdb SQL statements on data frames
Description
Runs Duckdb SQL statements on in-memory data frames without registering nor copying them. Optionnaly sends the result of a query to a parquet file in an efficient way. Using the 'path' argument may be be twenty times faster than using the COPY ... TO SQL statement.
Usage
SQL(query,path)
Arguments
| query | A character string containing SQL statements undertandable by Duckdb. | 
| path | A path to a parquet file to be created. | 
Value
If 'path' is not given a value, returns the result of the query as a data frame, else returns an invisible NULL.
Examples
SQL("SELECT * FROM mtcars LIMIT 1")
# Temporary tables may be created but must be quoted when used
SQL("
  CREATE TABLE cyls AS SELECT DISTINCT cyl FROM mtcars;
  SELECT * FROM 'cyls'
")
## Not run: 
# Mixing data frames and parquet files, then writing to parquet
dep <- rio::import('V:/PALETTES/IGoR/data/dep2014.dbf')
SQL(
  "SELECT a.*,b.REGION
   FROM 'V:/PALETTES/parquet/rp68a19.parquet' a
   LEFT JOIN dep b
   ON a.DR=b.DEP",
  'V:/PALETTES/tmp/rp68a19s.parquet'
)
 
## End(Not run)