Skip to main content

Custom Spark data sources for reading and writing data in Apache Spark, using the Python Data Source API

Project description

PySpark Data Sources

pypi

This repository showcases custom Spark data sources built using the new Python Data Source API introduced in Apache Spark 4.0. For an in-depth understanding of the API, please refer to the API source code. Note this repo is demo only and please be aware that it is not intended for production use. Contributions and feedback are welcome to help improve the examples.

Installation

pip install pyspark-data-sources

Usage

Make sure you have pyspark >= 4.0.0 installed.

pip install pyspark

Or use Databricks Runtime 15.4 LTS or above versions, or Databricks Serverless.

from pyspark_datasources.fake import FakeDataSource

# Register the data source
spark.dataSource.register(FakeDataSource)

spark.read.format("fake").load().show()

# For streaming data generation
spark.readStream.format("fake").load().writeStream.format("console").start()

Example Data Sources

Data Source Short Name Description Dependencies
GithubDataSource github Read pull requests from a Github repository None
FakeDataSource fake Generate fake data using the Faker library faker
StockDataSource stock Read stock data from Alpha Vantage None
GoogleSheetsDataSource googlesheets Read table from public Google Sheets None
KaggleDataSource kaggle Read datasets from Kaggle kagglehub, pandas
SimpleJsonDataSource simplejson Write JSON data to Databricks DBFS databricks-sdk
OpenSkyDataSource opensky Read from OpenSky Network. None

See more here: https://allisonwang-db.github.io/pyspark-data-sources/.

Official Data Sources

For production use, consider these official data source implementations built with the Python Data Source API:

Data Source Repository Description Features
HuggingFace Datasets @huggingface/pyspark_huggingface Production-ready Spark Data Source for 🤗 Hugging Face Datasets • Stream datasets as Spark DataFrames
• Select subsets/splits with filters
• Authentication support
• Save DataFrames to Hugging Face

Contributing

We welcome and appreciate any contributions to enhance and expand the custom data sources.:

  • Add New Data Sources: Want to add a new data source using the Python Data Source API? Submit a pull request or open an issue.
  • Suggest Enhancements: If you have ideas to improve a data source or the API, we'd love to hear them!
  • Report Bugs: Found something that doesn't work as expected? Let us know by opening an issue.

Development

Environment Setup

poetry install
poetry env activate

Build Docs

mkdocs serve

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyspark_data_sources-0.1.8.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyspark_data_sources-0.1.8-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file pyspark_data_sources-0.1.8.tar.gz.

File metadata

  • Download URL: pyspark_data_sources-0.1.8.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.5.0

File hashes

Hashes for pyspark_data_sources-0.1.8.tar.gz
Algorithm Hash digest
SHA256 bae5036cabc9e8605e0542af5b7da9ef66e49bdb73648864c4c4e4e39767e467
MD5 a686f713a25be9d2b1193bc3c3a8578d
BLAKE2b-256 5bfdacb2645c00dd315bbedc52f8bded7b54e98d64718b1369941bb8a56dc05e

See more details on using hashes here.

File details

Details for the file pyspark_data_sources-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for pyspark_data_sources-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 118f5a564e4c6b2b7f0eb5edaa47b54ff50486740baf25bf23e732934d551730
MD5 047c3608b782513b9b54075ab06a2411
BLAKE2b-256 d0d5b76b615e441f768b2e1290ce40d327328972da661137f2e55a8127b330f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page