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.
-
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
-
Configure StarRocks for Arrow Flight SQL using one of the following options:
Run these commands from your terminal:
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
If you prefer to understand and apply the changes yourself:
-
Open a shell inside the container:
docker exec -it quickstart bash -
Edit the FE (frontend) configuration:
vi /data/deploy/starrocks/fe/conf/fe.conf
-
Find the
JAVA_OPTSline and add the Arrow memory module at the beginning:JAVA_OPTS="--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED ..." -
Add this line at the end of the file:
arrow_flight_port = 9408
-
-
Edit the BE (backend) configuration:
vi /data/deploy/starrocks/be/conf/be.conf
- Add this line at the end of the file:
arrow_flight_port = 9419
- Add this line at the end of the file:
-
Exit the container and restart it:
exit docker restart quickstart
-
-
Verify the container is ready. Wait for the container to become healthy:
docker ps --filter "name=quickstart"You should see
(healthy)in the status before proceeding.
-
Install the Flight SQL ADBC driver:
dbc install flightsql
-
Customize the Go program
main.goas needed.- Change the connection arguments in the
NewDatabase()call.uriis the URI of your StarRocks instance. The host and FE Arrow Flight port will depend on your installation.usernameandpasswordare the username and password of your StarRocks user.
- Change the SQL
SELECTstatement instmt.SetSqlQuery()if desired.
- Change the connection arguments in the
-
Run the Go program:
go mod tidy go run main.go
Stop the Docker container running StarRocks:
docker stop quickstart