Skip to content

Latest commit

 

History

History

druid

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Connecting C++ and Apache Druid with ADBC

Instructions

Tip

If you already have a Druid instance running, skip the steps to set up Druid.

Prerequisites

  1. Install Pixi

  2. Install dbc

Set up Druid

  1. Install Docker

  2. Start a Druid 37 nano-quickstart instance:

    docker run --detach --rm \
      --name druid \
      --platform linux/amd64 \
      --publish 8888:8888 \
      --volume "$PWD/start-druid.sh:/opt/druid/start-druid.sh:ro" \
      --entrypoint /bin/bash \
      apache/druid:37.0.0 /opt/druid/start-druid.sh
  3. Wait for Druid to accept SQL queries:

    until curl --fail --silent --output /dev/null \
      --header 'Content-Type: application/json' \
      --data '{"query":"SELECT 1"}' \
      http://localhost:8888/druid/v2/sql; do sleep 2; done

Connect to Druid

  1. Install the Druid ADBC driver:

    dbc install --level user --pre druid
  2. Customize the C++ program main.cpp as needed,

    • Change the connection arguments in the AdbcDatabaseSetOption() calls
  3. Build and run the C++ program:

    Using Make:

    pixi run make
    ./druid_demo

    Or using CMake:

    pixi run cmake -B build
    pixi run cmake --build build
    ./build/druid_demo

Clean up

  1. Clean build artifacts:

    Using Make:

    pixi run make clean

    Using CMake:

    rm -rf build
  2. Stop the Docker container running Druid:

    docker stop druid