Skip to content

Latest commit

 

History

History

druid

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Connecting JavaScript 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 Node.js (version 22 or later)

    • Alternatively, you can use Bun or Deno
  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 --pre druid
  2. Install dependencies:

    npm --prefix .. install
  3. Customize the script main.js as needed

    • Change the connection arguments in databaseOptions
  4. Run the script:

    Node.js:

    node main.js

    Bun:

    bun run main.js

    Deno:

    deno run --allow-ffi --allow-env main.js

Clean up

Stop the Docker container running Druid:

docker stop druid