Skip to main content

Helpers & syntax sugar for PySpark.

Project description

Sparkly PyPi Version Sparkly Build Status Documentation Status

Helpers & syntax sugar for PySpark. There are several features to make your life easier:

  • Definition of spark packages, external jars, UDFs and spark options within your code;

  • Simplified reader/writer api for Cassandra, Elastic, MySQL;

  • Testing framework for spark applications.

More details could be found in the official documentation.

Installation

Sparkly itself is easy to install:

pip install sparkly

The tricky part is pyspark. There is no official distribution on PyPI. As a workaround we can suggest:

  1. Use env variable PYTHONPATH to point to your Spark installation, something like:

    export PYTHONPATH="/usr/local/spark/python/lib/pyspark.zip:/usr/local/spark/python/lib/py4j-0.9-src.zip"
  2. Use our setup.py file for pyspark. Just add this to your requirements.txt:

    -e git+https://github.com/Tubular/spark@branch-1.6#egg=pyspark&subdirectory=python

Here in Tubular, we published pyspark to our internal PyPi repository.

Getting Started

Here is a small code snippet to show how to easily read Cassandra table and write its content to ElasticSearch index:

from sparkly import SparklyContext


class MyContext(SparklyContext):
    packages = [
        'datastax:spark-cassandra-connector:1.6.1-s_2.10',
        'org.elasticsearch:elasticsearch-spark_2.10:2.3.0',
    ]


if __name__ == '__main__':
    hc = MyContext()
    df = hc.read_ext.cassandra('localhost', 'my_keyspace', 'my_table')
    df.write_ext.elastic('localhost', 'my_index', 'my_type')

See the online documentation for more details.

Testing

To run tests you have to have docker and docker-compose installed on your system. If you are working on MacOS we highly recommend you to use docker-machine. As soon as the tools mentioned above have been installed, all you need is to run:

make test

Supported Spark Versions

At the moment we support only Spark 1.6.x. In the nearest future, we are going to add support for Spark 2.x.

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

sparkly-1.1.1.tar.gz (19.5 kB view details)

Uploaded Source

File details

Details for the file sparkly-1.1.1.tar.gz.

File metadata

  • Download URL: sparkly-1.1.1.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sparkly-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c4f14aee7478f0e4e4ff3ee232ea464ef33a03e2d4798d78d6f333c9f95576c5
MD5 18c2bc2e1607efa96939414c0cb0475c
BLAKE2b-256 ab39b93968b3d4c7d7b6bcf8bb6de35d32773c278bc90b435b37391411fe62c9

See more details on using hashes here.

Supported by

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