Tip
If you already have a Spark instance running, skip the steps to set up and clean up Spark.
-
Start a Spark instance:
docker run -d --rm --name spark-connect -p 15002:15002 apache/spark:4.1.2 bash -c "/opt/spark/sbin/start-connect-server.sh && tail -f /dev/null"
-
Install the Spark ADBC driver:
dbc install --level user spark --pre
-
Customize the C++ program
main.cpp- Change the connection arguments in the
AdbcDatabaseSetOption()calls- Format
uriaccording to the driver documentation, or keep it as is
- Format
- If you changed which database you're connecting to, also change the SQL SELECT statement in
AdbcStatementSetSqlQuery()
- Change the connection arguments in the
-
Build and run the C++ program:
Using Make:
pixi run make ./spark_demo
Or using CMake:
pixi run cmake -B build pixi run cmake --build build ./build/spark_demo
-
Stop the Docker container running Spark:
docker stop spark-connect
-
Clean build artifacts:
Using Make:
pixi run make clean
Using CMake:
rm -rf build