Git Product home page Git Product logo

flight-duckdb-example's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.