Skip to main content

# Google Spark Connect Client

A wrapper of the Apache [Spark Connect](https://spark.apache.org/spark-connect/) client with additional functionalities that allow applications to communicate with a remote Dataproc Spark cluster using the Spark Connect protocol without requiring additional steps.

## Install

pip install google_spark_connect

## Uninstall

pip uninstall google_spark_connect

## Setup This client requires permissions to manage [Dataproc sessions and session templates](https://cloud.google.com/dataproc-serverless/docs/concepts/iam). If you are running the client outside of Google Cloud, you must set following environment variables:

## Usage

  1. Install the latest version of Dataproc Python client and Google Spark Connect modules:

    pip install google_cloud_dataproc --force-reinstall
    pip install google_spark_connect --force-reinstall
  2. Add the required import into your PySpark application or notebook:

    from google.cloud.spark_connect import GoogleSparkSession
  3. There are two ways to create a spark session,

    1. Start a Spark session using properties defined in DATAPROC_SPARK_CONNECT_SESSION_DEFAULT_CONFIG:

      spark = GoogleSparkSession.builder.getOrCreate()
    2. Start a Spark session with the following code instead of using a config file:

      from google.cloud.dataproc_v1 import SparkConnectConfig
      from google.cloud.dataproc_v1 import Session
      google_session_config = Session()
      google_session_config.spark_connect_session = SparkConnectConfig()
      google_session_config.environment_config.execution_config.subnetwork_uri = "<subnet>"
      google_session_config.runtime_config.version = '3.0'
      spark = GoogleSparkSession.builder.googleSessionConfig(google_session_config).getOrCreate()

## Billing As this client runs the spark workload on Dataproc, your project will be billed as per [Dataproc Serverless Pricing](https://cloud.google.com/dataproc-serverless/pricing). This will happen even if you are running the client from a non-GCE instance.

## Contributing ### Building and Deploying SDK

  1. Install the requirements in virtual environment.

    pip install -r requirements.txt
  2. Build the code.

    python setup.py sdist bdist_wheel
  3. Copy the generated .whl file to Cloud Storage. Use the version specified in the setup.py file.

    VERSION=<version> gsutil cp dist/google_spark_connect-${VERSION}-py2.py3-none-any.whl gs://<your_bucket_name>
  4. Download the new SDK on Vertex, then uninstall the old version and install the new one.

    %%bash
    export VERSION=<version>
    gsutil cp gs://<your_bucket_name>/google_spark_connect-${VERSION}-py2.py3-none-any.whl .
    yes | pip uninstall google_spark_connect
    pip install google_spark_connect-${VERSION}-py2.py3-none-any.whl

Metadata

Release files for google-spark-connect 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for google-spark-connect 0.5.6
File Size Uploaded Provenance Actions
google_spark_connect-0.5.6.tar.gz 17.4 kB Without provenance Details for google_spark_connect-0.5.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for google-spark-connect 0.5.6
File Interpreter ABI Platform Actions
google_spark_connect-0.5.6-py2.py3-none-any.whl Python 3, Python 2 none any Details for google_spark_connect-0.5.6-py2.py3-none-any.whl

Total release size: 36.8 kB

Release files / google_spark_connect-0.5.6.tar.gz

Download URL google_spark_connect-0.5.6.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
93456a12b47b8172302ff940e5b5e650a130ccb9c9bf6e3a185709246ab00b4a
BLAKE2b-256 checksum
How to use checksums
3f0c428990117f9c6a339c88fb35349bc93d5d9329bdc73c4aecc4f53f8f365a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release files / google_spark_connect-0.5.6-py2.py3-none-any.whl

Download URL google_spark_connect-0.5.6-py2.py3-none-any.whl
Size 19.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2a66aa4c38c14ae67cc8ab9662467e2b9a8fdc483ed38885f83c80f228c1c39c
BLAKE2b-256 checksum
How to use checksums
6c7e1da2b5e1c8554332bd7becadda1088e3f275fd0f7ca0de51b3978bfc5f4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Security for google-spark-connect 0.5.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page