This repository is based on https://github.com/duckdb/extension-template, check it out if you want to build and ship your own DuckDB extension.
This extension, Quack, allow you to ... <extension_goal>.
First step is to clone this repo and make sure you pull in
DuckDB by using --recurse-submodules:
git clone --recurse-submodules https://github.com/krlmlr/duckdb-rfuns.gitNow to build the extension, run:
makeThe main binaries that will be built are:
./build/release/duckdb
./build/release/test/unittest
./build/release/extension/rfuns/rfuns.duckdb_extensionduckdbis the binary for the duckdb shell with the extension code automatically loaded.unittestis the test runner of duckdb. Again, the extension is already linked into the binary.rfuns.duckdb_extensionis the loadable binary as it would be distributed.
The duckdbrfuns package in the r/ directory has some tools to facilitate
working with the extension.
One you've make the extension, you can develop the 📦 normally, i.e. open the r/duckdbrfuns.Rproj
in RStudio and use load_all(), document() ...
You can also use the pkg target
make pkgOne you have the extension built and the R package installed, you can use the user defined functions:
library(duckdb)
con <- duckdbrfuns:::con()> dbGetQuery(con, 'SELECT "r_base::+"(1, 2)')
r_base::+(1, 2)
1 3The extension may also be used outside of R, via the ./build/release/duckdb executable:
D select "r_base::+"(1, 2);
┌─────────────────┐
│ r_base::+(1, 2) │
│ int32 │
├─────────────────┤
│ 3 │
└─────────────────┘
Different tests can be created for DuckDB extensions. The primary way of testing DuckDB extensions should be the SQL tests in ./test/sql. These SQL tests can be run using:
make testTo install your extension binaries from S3, duckdb should also be launched with the allow_unsigned_extensions option set to true.
Secondly, you will need to set the repository endpoint in DuckDB to the HTTP url of your bucket + version of the extension you want to install. To do this run the following SQL query in DuckDB:
SET custom_extension_repository='bucket.s3.eu-west-1.amazonaws.com/<your_extension_name>/latest';Note that the /latest path will allow you to install the latest extension version available for your current version of
DuckDB. To specify a specific version, you can pass the version instead.
After running these steps, you can install and load your extension using the regular INSTALL/LOAD commands in DuckDB:
INSTALL rfuns
LOAD rfuns