Spark 1.1

Posted on by

Crypho 3.3.3

The new book is now available on-line and in print!
  1. Spark 1/18 Porsche 919 Hybrid Le Man's 2016
  2. Chevy Spark 1.1
  3. Spark 1.1 0
  4. Spark 1/18 Mclaren M7a
  • Connect to Spark from R. The sparklyr package provides a
    complete dplyr backend.
  • Filter and aggregate Spark datasets then bring them into R for
    analysis and visualization.
  • Use Spark’s distributed machine learning library from R.
  • Create extensions that call the full Spark API and provide
    interfaces to Spark packages.


Installation

You can install the sparklyr package from CRAN as follows:

Today we are excited to share that sparklyr 1.1 is now available on CRAN! In a nutshell, you can use sparklyr to scale datasets across computing clusters running Apache Spark. For this particular release, we would like to highlight the following new features: Delta Lake enables database-like properties in Spark. Spark 3.0 preview is now available through sparklyr. Today we’re thrilled to announce the release of Apache Spark 1.1! Apache Spark 1.1 introduces many new features along with scale and stability improvements. This post will introduce some key features of Apache Spark 1.1 and provide context on the priorities of Spark for this and the next release. In the next two weeks, we’ll.

You should also install a local version of Spark for development purposes:

To upgrade to the latest version of sparklyr, run the following command and restart your r session:

If you use the RStudio IDE, you should also download the latest preview release of the IDE which includes several enhancements for interacting with Spark (see the RStudio IDE section below for more details).

Connecting to Spark

You can connect to both local instances of Spark as well as remote Spark clusters. Here we’ll connect to a local instance of Spark via the spark_connect function:

The returned Spark connection (sc) provides a remote dplyr data source to the Spark cluster.

For more information on connecting to remote Spark clusters see the Deployment section of the sparklyr website.

Using dplyr

We can now use all of the available dplyr verbs against the tables within the cluster.

We’ll start by copying some datasets from R into the Spark cluster (note that you may need to install the nycflights13 and Lahman packages in order to execute this code):

To start with here’s a simple filtering example:

Introduction to dplyr provides additional dplyr examples you can try. For example, consider the last example from the tutorial which plots data on flight delays:

Window Functions

dplyr window functions are also supported, for example:

For additional documentation on using dplyr with Spark see the dplyr section of the sparklyr website.

Using SQL

It’s also possible to execute SQL queries directly against tables within a Spark cluster. The spark_connection object implements a DBI interface for Spark, so you can use dbGetQuery to execute SQL and return the result as an R data frame:

Machine Learning

You can orchestrate machine learning algorithms in a Spark cluster via the machine learning functions within sparklyr. These functions connect to a set of high-level APIs built on top of DataFrames that help you create and tune machine learning workflows.

Spark 1/18 Porsche 919 Hybrid Le Man's 2016

Here’s an example where we use ml_linear_regression to fit a linear regression model. We’ll use the built-in mtcars dataset, and see if we can predict a car’s fuel consumption (mpg) based on its weight (wt), and the number of cylinders the engine contains (cyl). We’ll assume in each case that the relationship between mpg and each of our features is linear.

For linear regression models produced by Spark, we can use summary() to learn a bit more about the quality of our fit, and the statistical significance of each of our predictors.

Spark machine learning supports a wide array of algorithms and feature transformations and as illustrated above it’s easy to chain these functions together with dplyr pipelines. To learn more see the machine learning section.

Reading and Writing Data

You can read and write data in CSV, JSON, and Parquet formats. Data can be stored in HDFS, S3, or on the local filesystem of cluster nodes.

Distributed R

You can execute arbitrary r code across your cluster using spark_apply. For example, we can apply rgamma over iris as follows:

You can also group by columns to perform an operation over each group of rows and make use of any package within the closure:

Extensions

The facilities used internally by sparklyr for its dplyr and machine learning interfaces are available to extension packages. Since Spark is a general purpose cluster computing system there are many potential applications for extensions (e.g. interfaces to custom machine learning pipelines, interfaces to 3rd party Spark packages, etc.).

Here’s a simple example that wraps a Spark text file line counting function with an R function:

To learn more about creating extensions see the Extensions section of the sparklyr website.

Table Utilities

You can cache a table into memory with:

and unload from memory using:

Connection Utilities

You can view the Spark web console using the spark_web function:

You can show the log using the spark_log function:

Finally, we disconnect from Spark:

RStudio IDE

The latest RStudio Preview Release of the RStudio IDE includes integrated support for Spark and the sparklyr package, including tools for:

  • Creating and managing Spark connections
  • Browsing the tables and columns of Spark DataFrames
  • Previewing the first 1,000 rows of Spark DataFrames

Once you’ve installed the sparklyr package, you should find a new Spark pane within the IDE. This pane includes a New Connection dialog which can be used to make connections to local or remote Spark instances:

Once you’ve connected to Spark you’ll be able to browse the tables contained within the Spark cluster and preview Spark DataFrames using the standard RStudio data viewer:

You can also connect to Spark through Livy through a new connection dialog:

The RStudio IDE features for sparklyr are available now as part of the RStudio Preview Release.

Spark

Using H2O

rsparkling is a CRAN package from H2O that extends sparklyr to provide an interface into Sparkling Water. For instance, the following example installs, configures and runs h2o.glm:

Connecting through Livy

Livy enables remote connections to Apache Spark clusters. Before connecting to Livy, you will need the connection information to an existing service running Livy. Otherwise, to test livy in your local environment, you can install it and run it locally as follows:

To connect, use the Livy service address as master and method = 'livy' in spark_connect. Once connection completes, use sparklyr as usual, for instance:

Once you are done using livy locally, you should stop this service with:

To connect to remote livy clusters that support basic authentication connect as:

Chevy Spark 1.1

2018-10-02 — Announcement

We are excited to share that sparklyr 0.9 is now available on CRAN! Spark Stream integration, Job Monitoring and support for Kubernetes

Read More…

We are very excited to announce that the graphframes package is now on CRAN!What does graphframes do? It adds support for GraphFrames which aims to provide the functionality of GraphX. Perform graph algorithms like: PageRank, ShortestPaths and many others. Designed to work with sparklyr and the sparklyr extensions. New article A new article has been added to the site that walk through how to get started with Graph Analysis inside Spark: R interface for GraphFrames

Read More…

We had lots of fun attending Data Day Mexico 2018, and presenting a workshop in Spanish, which focused on basic `sparklyr` operations.

Read More…

A new article is now available to provide further background and guidance on how to use and implement ML Pipelines via sparklyr: Spark ML Pipelines

Read More…

We are excited to share that sparklyr 0.7 is now available on CRAN!

Read More…

Download Apache Spark™

  1. Choose a Spark release:

  2. Choose a package type:

  3. Download Spark:

  4. Verify this release using the and project release KEYS.

Note that, Spark is pre-built with Scala 2.11 except version 2.4.2, which is pre-built with Scala 2.12.

Latest Preview Release

Preview releases, as the name suggests, are releases for previewing upcoming features.Unlike nightly packages, preview releases have been audited by the project’s management committeeto satisfy the legal requirements of Apache Software Foundation’s release policy.Preview releases are not meant to be functional, i.e. they can and highly likely will containcritical bugs or documentation errors.The latest preview release is Spark 3.0.0-preview2, published on Dec 23, 2019.You can select and download it above.

Link with Spark

Spark artifacts are hosted in Maven Central. You can add a Maven dependency with the following coordinates:

Installing with PyPi

PySpark is now available in pypi. To install just run pip install pyspark.

Release Notes for Stable Releases

Spark 1.1 0

Archived Releases

Spark 1/18 Mclaren M7a

As new Spark releases come out for each development stream, previous ones will be archived, but they are still available at Spark release archives.