Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Connecting JavaScript and StarRocks with ADBC

Instructions

This example uses StarRocks, an open query engine for sub-second, ad-hoc analytics both on and off the data lakehouse.

Tip

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

Prerequisites

  1. Install Node.js (version 22 or later)

    • Alternatively, you can use Bun or Deno
  2. Install dbc

Set up StarRocks

  1. Install Docker

  2. Start a StarRocks instance:

    docker run --rm -p 9030:9030 -p 8030:8030 -p 8040:8040 -p 9408:9408 -p 9419:9419 -itd \
    --name quickstart starrocks/allin1-ubuntu
  3. Configure StarRocks for Arrow Flight SQL:

    docker exec quickstart sed -i 's/JAVA_OPTS="-Dlog4j2/JAVA_OPTS="--add-opens=java.base\/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED -Dlog4j2/' /data/deploy/starrocks/fe/conf/fe.conf
    docker exec quickstart bash -c 'echo "arrow_flight_port = 9408" >> /data/deploy/starrocks/fe/conf/fe.conf'
    docker exec quickstart bash -c 'echo "arrow_flight_port = 9419" >> /data/deploy/starrocks/be/conf/be.conf'
    docker restart quickstart
  4. Wait for the container to become healthy before proceeding:

    docker ps --filter "name=quickstart"

Connect to StarRocks

  1. Install the Flight SQL ADBC driver:

    dbc install flightsql
  2. Install dependencies:

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

    • Change the connection arguments in databaseOptions
      • uri is the URI of your StarRocks instance. The host and FE Arrow Flight port will depend on your installation.
      • username and password are the username and password of your StarRocks user.
    • Change the SQL SELECT statement in conn.query() if desired.
  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 StarRocks:

docker stop quickstart