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.7.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.7-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyspark_data_sources-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 7a16e655fed8df8f645ae06820d8c609927d74f5517cf4aaddec005d68b2c3db
MD5 138d66ff66c087737b94f1b6ca246e6b
BLAKE2b-256 b6c4c2fedbace5f1a0d64c7622b06f791634780196a65c63fe3c1b8fe2487bd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyspark_data_sources-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 024ca0bf5cf7de26c28b02e4588d71d7b0388c401efa47f9d86d33a34419ddfa
MD5 0e1bba8d35868ee91918054a7e75f879
BLAKE2b-256 ad3943320b4b39b884099ddaa71be71d0dff1d2bf76afaa29748335b1c05d68f

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