Skip to content

Latest commit

 

History

History
105 lines (82 loc) · 2.74 KB

README.md

File metadata and controls

105 lines (82 loc) · 2.74 KB

DuckDB Record

A DuckDB extension to read/write records from binary or text encoded files

Development

Use the official DuckDB cmake builder

make

Or... use the experimental nix flake and zig builder within this repo

nix run .#build-fast

analyze_record

D select * from analyze_record('./input');
┌───────────────┐
│    result     │
│    varchar    │
├───────────────┤
│ Quack Jane 🐥 │
└───────────────┘

detect_record

D select * from detect_record('./input');
┌───────────────┐
│    result     │
│    varchar    │
├───────────────┤
│ Quack Jane 🐥 │
└───────────────┘

read_record

D select * from read_record('./input', '{ "name": "PIC(X(20))", "age": "PIC(9(3)), "salary": "PIC(9(10)V99)" }');
┌───────────────┐
│    result     │
│    varchar    │
├───────────────┤
│ Quack Jane 🐥 │
└───────────────┘

write_record

D select * from write_record('./input', '{ "name": "Scrooge McDuck", "age": 40, "salary": 1000000.13 }');
┌───────────────┐
│    result     │
│    varchar    │
├───────────────┤
│ Quack Jane 🐥 │
└───────────────┘

Test

make test

Installing the deployed binaries

To install your extension binaries from S3, you will need to do two things. Firstly, DuckDB should be launched with the allow_unsigned_extensions option set to true. How to set this will depend on the client you're using. Some examples:

CLI:

duckdb -unsigned

Python:

con = duckdb.connect(':memory:', config={'allow_unsigned_extensions' : 'true'})

NodeJS:

db = new duckdb.Database(':memory:', {"allow_unsigned_extensions": "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 record
LOAD record