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()

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 None
StockDataSource stock Read stock data from Alpha Vantage None
SimpleJsonDataSource simplejson Read JSON data from a file databricks-sdk

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 --all-extras
poetry shell

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.6.tar.gz (17.4 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.6-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyspark_data_sources-0.1.6.tar.gz
  • Upload date:
  • Size: 17.4 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.6.tar.gz
Algorithm Hash digest
SHA256 94888b7ddae1ff25438ea31388f5a01ca60bd25ad93279443151339fdb56cf67
MD5 1ca6f1ee5edb2817627977724efdb9d8
BLAKE2b-256 1c836f65d8fb4af3068fe01c361bf90396ec4bbec2b81f72da55e5a6671643d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyspark_data_sources-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fa36b83e6b881385b2e4c5b5fc26a7be577ea58080b5208e96a866ccc287498d
MD5 b021c226b891c5c5f8aaecc5a2c7b542
BLAKE2b-256 d57e4677aff6433061184ad28adbf910f0443f624426c831d2953636f34d1b0a

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