Skip to content

Sample code to accompany blog post showcasing Arrow Flight SQL running on DuckDB

Notifications You must be signed in to change notification settings

voltrondata/flight-duckdb-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arrow FlightSQL example

Setup

In order to run this example you need to set up a new environment on your machine. Follow these steps to do so (thanks to David Li!).

  1. Make sure you have miniconda installed on your machine.
  2. Install Mamba: conda install -c conda-forge mamba.
  3. Now, create a new dev environment
$ mamba create -n flight-sql -c conda-forge python=3.9
$ conda activate flight-sql
$ 
  1. Build and install Arrow
$ cd scripts && ./install_arrow.sh
  1. Build and install duckdb. This is sometimes necessary as conda compilers seem to be including incompatible GlibC library with the compiled binaries of duckdb.
$ ./install_duckdb.sh
  1. Get the data.
$ mkdir ../data
$ wget https://github.com/lovasoa/TPCH-sqlite/releases/download/v1.0/TPC-H-small.db -O ../data/TPC-H-small.db
  1. Create duckdb database.
$ ./get_duckdb_database.sh
  1. Build the example.
$ mkdir build && cd build
$ cmake .. -GNinja -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/lib/cmake/arrow
$ ninja && ./flight_sql

Selecting different backends

This example allows chosing from two backends: SQLite and DuckDB. It defaults to DuckDB.

$ ./flight_sql
> duckdb server listening on localhost:31337
> Connected to server: localhost:31337
> Client created.
> ...

The above call is equivalent to running ./flight_sql -B duckdb or ./flight_sql --backend duckdb. To select SQLite run

$ ./flight_sql -B sqlite

or

$ ./flight_sql --backend sqlite

The above will produce the following:

> sqlite server listening on localhost:31337
> Connected to server: localhost:31337
> Client created.
> ...

Printing results of running query

This example defaults to running the queries but does not print out the query itself nor does it print the results. To switch to printing results and queries set the print flag to true.

$ ./flight_sql --print true

Print help

To see all the available options run ./flight.sql --help.

> Allowed options:
>   --help                         produce this help message
>   -B [ --backend ] arg (=duckdb) Specify the database backend. Allowed options:
>                                  duckdb, sqlite.
>   --print arg (=false)           Print the results of running queries. Allowed 
>                                  options: false, true.

About

Sample code to accompany blog post showcasing Arrow Flight SQL running on DuckDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages