chore
3 files changed
tree: 464358a251b44deec90b4cfef3e8af1d12e9151c
  1. .github/
  2. examples/
  3. src/
  4. .gitignore
  5. .gitmodules
  6. .pre-commit-config.yaml
  7. build.rs
  8. Cargo.lock
  9. Cargo.toml
  10. docker-compose.yml
  11. LICENSE.txt
  12. pre-commit.sh
  13. README.md
README.md

Apache Spark Connect Client for Rust

This project houses the experimental client for Spark Connect for Apache Spark written in Rust

Current State of the Project

Currently, the Spark Connect client for Rust is highly experimental and should not be used in any production setting. This is currently a “proof of concept” to identify the methods of interacting with Spark cluster from rust.

Quick Start

The spark-connect-rs aims to provide an entrypoint to Spark Connect, and provide similar DataFrame API interactions.

docker compose up --build -d
use spark_connect_rs;

use spark_connect_rs::{SparkSession, SparkSessionBuilder};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let spark = SparkSessionBuilder::remote("sc://127.0.0.1:15002/".to_string())
            .build()
            .await?;

    let mut df = spark.sql("SELECT * FROM json.`/opt/spark/examples/src/main/resources/employees.json`");

    df.filter("salary > 3000").show(Some(5), None, None).await?;

    Ok(())
}

Getting Started

git clone https://github.com/sjrusso8/spark-connect-rs.git
git submodule update --init --recursive

docker compose up --build -d

cargo build && cargo test

Features

The following section outlines some of the implemented functions that are working with the Spark Connect session.

  • open better Error handling
  • open not so much use of clone()

SparkSession

SparkSessionAPIComment
rangedone
sqldoneDoes not include the new Spark Connect 3.5 feature with “position arguments”
readdone
createDataFrameopen
getActiveSessionopen
many more!!

DataFrame

DataFrameAPIComment
selectdone
selectExprdoneDoes not include the new Spark Connect 3.5 feature with “position arguments”
filterdone
limitdone
dropDuplicatesdone
withColumnsRenameddone
dropdone
sampledone
repartitiondone
offsetdone
schemadoneThe output needs to be handled better
explaindoneThe output needs to be handled better
showdone
taildone
collectdone
withColumnsopen
sortopen
groupByopen
createTempViewopenThere is an error right now, and the functions are private till it's fixed
many more!open

DataFrameWriter

Spark Connect should respect the format as long as your cluster supports the specified type and has the required jars

DataFrameAPIComment
formatdone
optiondone
optionsdone
modedone
bucketBydone
sortBydone
partitionBydone
savedone
saveAsTabledone
insertIntodone