Learn R Programming

sparklyr: R interface for Apache Spark

  • Install and connect to Spark using YARN, Mesos, Livy or Kubernetes.
  • Use dplyr to filter and aggregate Spark datasets and streams then bring them into R for analysis and visualization.
  • Use MLlib, H2O, XGBoost and GraphFrames to train models at scale in Spark.
  • Create interoperable machine learning pipelines and productionize them with MLeap.
  • Create extensions that call the full Spark API or run distributed R code to support new functionality.

Table of Contents

Installation

You can install the sparklyr package from CRAN as follows:

install.packages("sparklyr")

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

library(sparklyr)
spark_install()

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

install.packages("devtools")
devtools::install_github("sparklyr/sparklyr")

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:

library(sparklyr)
sc <- spark_connect(master = "local")

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

install.packages(c("nycflights13", "Lahman"))
library(dplyr)
iris_tbl <- copy_to(sc, iris, overwrite = TRUE)
flights_tbl <- copy_to(sc, nycflights13::flights, "flights", overwrite = TRUE)
batting_tbl <- copy_to(sc, Lahman::Batting, "batting", overwrite = TRUE)
src_tbls(sc)
#> [1] "batting" "flights" "iris"

To start with here’s a simple filtering example:

# filter by departure delay and print the first few records
flights_tbl %>% filter(dep_delay == 2)
#> # Source: spark<?> [?? x 19]
#>     year month   day dep_time sched_dep_time dep_delay
#>    <int> <int> <int>    <int>          <int>     <dbl>
#>  1  2013     1     1      517            515         2
#>  2  2013     1     1      542            540         2
#>  3  2013     1     1      702            700         2
#>  4  2013     1     1      715            713         2
#>  5  2013     1     1      752            750         2
#>  6  2013     1     1      917            915         2
#>  7  2013     1     1      932            930         2
#>  8  2013     1     1     1028           1026         2
#>  9  2013     1     1     1042           1040         2
#> 10  2013     1     1     1231           1229         2
#> # ℹ more rows
#> # ℹ 13 more variables: arr_time <int>,
#> #   sched_arr_time <int>, arr_delay <dbl>, carrier <chr>,
#> #   flight <int>, tailnum <chr>, origin <chr>, dest <chr>,
#> #   air_time <dbl>, distance <dbl>, hour <dbl>,
#> #   minute <dbl>, time_hour <dttm>

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:

delay <- flights_tbl %>%
  group_by(tailnum) %>%
  summarise(count = n(), dist = mean(distance), delay = mean(arr_delay)) %>%
  filter(count > 20, dist < 2000, !is.na(delay)) %>%
  collect()

# plot delays
library(ggplot2)
ggplot(delay, aes(dist, delay)) +
  geom_point(aes(size = count), alpha = 1/2) +
  geom_smooth() +
  scale_size_area(max_size = 2)
#> `geom_smooth()` using method = 'gam' and formula = 'y ~
#> s(x, bs = "cs")'

Window Functions

dplyr window functions are also supported, for example:

batting_tbl %>%
  select(playerID, yearID, teamID, G, AB:H) %>%
  arrange(playerID, yearID, teamID) %>%
  group_by(playerID) %>%
  filter(min_rank(desc(H)) <= 2 & H > 0)
#> # Source:     spark<?> [?? x 7]
#> # Groups:     playerID
#> # Ordered by: playerID, yearID, teamID
#>    playerID  yearID teamID     G    AB     R     H
#>    <chr>      <int> <chr>  <int> <int> <int> <int>
#>  1 abadijo01   1875 PH3       11    45     3    10
#>  2 abadijo01   1875 BR2        1     4     1     1
#>  3 abbeybe01   1896 BRO       25    63     7    12
#>  4 abbeybe01   1892 WAS       27    75     5     9
#>  5 abbeych01   1894 WAS      129   523    95   164
#>  6 abbeych01   1895 WAS      133   516   102   142
#>  7 abbotfr01   1903 CLE       77   255    25    60
#>  8 abbotfr01   1905 PHI       42   128     9    25
#>  9 abbotky01   1992 PHI       31    29     1     2
#> 10 abbotky01   1995 PHI       18     2     1     1
#> # ℹ more rows

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:

library(DBI)
iris_preview <- dbGetQuery(sc, "SELECT * FROM iris LIMIT 10")
iris_preview
#>    Sepal_Length Sepal_Width Petal_Length Petal_Width
#> 1           5.1         3.5          1.4         0.2
#> 2           4.9         3.0          1.4         0.2
#> 3           4.7         3.2          1.3         0.2
#> 4           4.6         3.1          1.5         0.2
#> 5           5.0         3.6          1.4         0.2
#> 6           5.4         3.9          1.7         0.4
#> 7           4.6         3.4          1.4         0.3
#> 8           5.0         3.4          1.5         0.2
#> 9           4.4         2.9          1.4         0.2
#> 10          4.9         3.1          1.5         0.1
#>    Species
#> 1   setosa
#> 2   setosa
#> 3   setosa
#> 4   setosa
#> 5   setosa
#> 6   setosa
#> 7   setosa
#> 8   setosa
#> 9   setosa
#> 10  setosa

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.

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.

# copy mtcars into spark
mtcars_tbl <- copy_to(sc, mtcars, overwrite = TRUE)

# transform our data set, and then partition into 'training', 'test'
partitions <- mtcars_tbl %>%
  filter(hp >= 100) %>%
  mutate(cyl8 = cyl == 8) %>%
  sdf_partition(training = 0.5, test = 0.5, seed = 1099)

# fit a linear model to the training dataset
fit <- partitions$training %>%
  ml_linear_regression(response = "mpg", features = c("wt", "cyl"))
fit
#> Formula: mpg ~ wt + cyl
#> 
#> Coefficients:
#> (Intercept)          wt         cyl 
#>  37.1464554  -4.3408005  -0.5830515

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.

summary(fit)
#> Deviance Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -2.5134 -0.9158 -0.1683  1.1503  2.1534 
#> 
#> Coefficients:
#> (Intercept)          wt         cyl 
#>  37.1464554  -4.3408005  -0.5830515 
#> 
#> R-Squared: 0.9428
#> Root Mean Squared Error: 1.409

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.

temp_csv <- tempfile(fileext = ".csv")
temp_parquet <- tempfile(fileext = ".parquet")
temp_json <- tempfile(fileext = ".json")

spark_write_csv(iris_tbl, temp_csv)
iris_csv_tbl <- spark_read_csv(sc, "iris_csv", temp_csv)

spark_write_parquet(iris_tbl, temp_parquet)
iris_parquet_tbl <- spark_read_parquet(sc, "iris_parquet", temp_parquet)

spark_write_json(iris_tbl, temp_json)
iris_json_tbl <- spark_read_json(sc, "iris_json", temp_json)

src_tbls(sc)
#> [1] "batting"      "flights"      "iris"        
#> [4] "iris_csv"     "iris_json"    "iris_parquet"
#> [7] "mtcars"

Distributed R

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

spark_apply(iris_tbl, function(data) {
  data[1:4] + rgamma(1,2)
})
#> # Source: spark<?> [?? x 4]
#>    Sepal_Length Sepal_Width Petal_Length Petal_Width
#>           <dbl>       <dbl>        <dbl>       <dbl>
#>  1         5.75        4.15         2.05       0.846
#>  2         5.55        3.65         2.05       0.846
#>  3         5.35        3.85         1.95       0.846
#>  4         5.25        3.75         2.15       0.846
#>  5         5.65        4.25         2.05       0.846
#>  6         6.05        4.55         2.35       1.05 
#>  7         5.25        4.05         2.05       0.946
#>  8         5.65        4.05         2.15       0.846
#>  9         5.05        3.55         2.05       0.846
#> 10         5.55        3.75         2.15       0.746
#> # ℹ more rows

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

spark_apply(
  iris_tbl,
  function(e) broom::tidy(lm(Petal_Width ~ Petal_Length, e)),
  columns = c("term", "estimate", "std.error", "statistic", "p.value"),
  group_by = "Species"
)
#> # Source: spark<?> [?? x 6]
#>   Species    term      estimate std.error statistic  p.value
#>   <chr>      <chr>        <dbl>     <dbl>     <dbl>    <dbl>
#> 1 versicolor (Interce…  -0.0843    0.161     -0.525 6.02e- 1
#> 2 versicolor Petal_Le…   0.331     0.0375     8.83  1.27e-11
#> 3 virginica  (Interce…   1.14      0.379      2.99  4.34e- 3
#> 4 virginica  Petal_Le…   0.160     0.0680     2.36  2.25e- 2
#> 5 setosa     (Interce…  -0.0482    0.122     -0.396 6.94e- 1
#> 6 setosa     Petal_Le…   0.201     0.0826     2.44  1.86e- 2

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:

# write a CSV
tempfile <- tempfile(fileext = ".csv")
write.csv(nycflights13::flights, tempfile, row.names = FALSE, na = "")

# define an R interface to Spark line counting
count_lines <- function(sc, path) {
  spark_context(sc) %>%
    invoke("textFile", path, 1L) %>%
      invoke("count")
}

# call spark to count the lines of the CSV
count_lines(sc, tempfile)
#> [1] 336777

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

Table Utilities

You can cache a table into memory with:

tbl_cache(sc, "batting")

and unload from memory using:

tbl_uncache(sc, "batting")

Connection Utilities

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

spark_web(sc)

You can show the log using the spark_log() function:

spark_log(sc, n = 10)
#> 24/01/08 15:49:41 INFO Executor: Running task 0.0 in stage 87.0 (TID 115)
#> 24/01/08 15:49:41 INFO HadoopRDD: Input split: file:/var/folders/l8/v1ym1mc10_b0dftql5wrrm8w0000gn/T/Rtmpl48w30/file213f56a22695.csv:0+33313106
#> 24/01/08 15:49:41 INFO BlockManagerInfo: Removed broadcast_94_piece0 on localhost:56103 in memory (size: 20.0 KiB, free: 1048.6 MiB)
#> 24/01/08 15:49:41 INFO Executor: Finished task 0.0 in stage 87.0 (TID 115). 969 bytes result sent to driver
#> 24/01/08 15:49:41 INFO TaskSetManager: Finished task 0.0 in stage 87.0 (TID 115) in 102 ms on localhost (executor driver) (1/1)
#> 24/01/08 15:49:41 INFO TaskSchedulerImpl: Removed TaskSet 87.0, whose tasks have all completed, from pool 
#> 24/01/08 15:49:41 INFO DAGScheduler: ResultStage 87 (count at DirectMethodHandleAccessor.java:104) finished in 0.105 s
#> 24/01/08 15:49:41 INFO DAGScheduler: Job 70 is finished. Cancelling potential speculative or zombie tasks for this job
#> 24/01/08 15:49:41 INFO TaskSchedulerImpl: Killing all running tasks in stage 87: Stage finished
#> 24/01/08 15:49:41 INFO DAGScheduler: Job 70 finished: count at DirectMethodHandleAccessor.java:104, took 0.106307 s

Finally, we disconnect from Spark:

  spark_disconnect(sc)

RStudio IDE

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:

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:

library(rsparkling)
library(sparklyr)
library(dplyr)
library(h2o)

sc <- spark_connect(master = "local", version = "2.3.2")
mtcars_tbl <- copy_to(sc, mtcars, "mtcars", overwrite = TRUE)

mtcars_h2o <- as_h2o_frame(sc, mtcars_tbl, strict_version_check = FALSE)

mtcars_glm <- h2o.glm(x = c("wt", "cyl"),
                      y = "mpg",
                      training_frame = mtcars_h2o,
                      lambda_search = TRUE)
mtcars_glm
#> Model Details:
#> ==============
#>
#> H2ORegressionModel: glm
#> Model ID:  GLM_model_R_1527265202599_1
#> GLM Model: summary
#>     family     link                              regularization
#> 1 gaussian identity Elastic Net (alpha = 0.5, lambda = 0.1013 )
#>                                                                lambda_search
#> 1 nlambda = 100, lambda.max = 10.132, lambda.min = 0.1013, lambda.1se = -1.0
#>   number_of_predictors_total number_of_active_predictors
#> 1                          2                           2
#>   number_of_iterations                                training_frame
#> 1                  100 frame_rdd_31_ad5c4e88ec97eb8ccedae9475ad34e02
#>
#> Coefficients: glm coefficients
#>       names coefficients standardized_coefficients
#> 1 Intercept    38.941654                 20.090625
#> 2       cyl    -1.468783                 -2.623132
#> 3        wt    -3.034558                 -2.969186
#>
#> H2ORegressionMetrics: glm
#> ** Reported on training data. **
#>
#> MSE:  6.017684
#> RMSE:  2.453097
#> MAE:  1.940985
#> RMSLE:  0.1114801
#> Mean Residual Deviance :  6.017684
#> R^2 :  0.8289895
#> Null Deviance :1126.047
#> Null D.o.F. :31
#> Residual Deviance :192.5659
#> Residual D.o.F. :29
#> AIC :156.2425
spark_disconnect(sc)

Connecting through Livy

Livy enables remote connections to Apache Spark clusters. However, please notice that connecting to Spark clusters through Livy is much slower than any other connection method.

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:

livy_install()
livy_service_start()

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

sc <- spark_connect(master = "http://localhost:8998", method = "livy", version = "3.0.0")
copy_to(sc, iris, overwrite = TRUE)

spark_disconnect(sc)

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

livy_service_stop()

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

config <- livy_config(username="<username>", password="<password>")
sc <- spark_connect(master = "<address>", method = "livy", config = config)
spark_disconnect(sc)

Connecting through Databricks Connect v2

sparklyr is able to interact with Databricks Connect v2 via a new extension called pysparklyr. To learn how to use, and the latest updates on this integration see the article in sparklyr’s official website.

Copy Link

Version

Install

install.packages('sparklyr')

Monthly Downloads

49,125

Version

1.8.5

License

Apache License 2.0 | file LICENSE

Maintainer

Last Published

March 25th, 2024

Functions in sparklyr (1.8.5)

ft_dct

Feature Transformation -- Discrete Cosine Transform (DCT) (Transformer)
find_scalac

Discover the Scala Compiler
ft_elementwise_product

Feature Transformation -- ElementwiseProduct (Transformer)
ft_chisq_selector

Feature Transformation -- ChiSqSelector (Estimator)
ft_count_vectorizer

Feature Transformation -- CountVectorizer (Estimator)
ft_idf

Feature Transformation -- IDF (Estimator)
ft_imputer

Feature Transformation -- Imputer (Estimator)
ft_interaction

Feature Transformation -- Interaction (Transformer)
ft_index_to_string

Feature Transformation -- IndexToString (Transformer)
ft_one_hot_encoder

Feature Transformation -- OneHotEncoder (Transformer)
ft_lsh

Feature Transformation -- LSH (Estimator)
ft_lsh_utils

Utility functions for LSH models
ft_one_hot_encoder_estimator

Feature Transformation -- OneHotEncoderEstimator (Estimator)
ft_pca

Feature Transformation -- PCA (Estimator)
ft_polynomial_expansion

Feature Transformation -- PolynomialExpansion (Transformer)
ft_min_max_scaler

Feature Transformation -- MinMaxScaler (Estimator)
ft_max_abs_scaler

Feature Transformation -- MaxAbsScaler (Estimator)
ft_normalizer

Feature Transformation -- Normalizer (Transformer)
ft_hashing_tf

Feature Transformation -- HashingTF (Transformer)
ft_feature_hasher

Feature Transformation -- FeatureHasher (Transformer)
ft_ngram

Feature Transformation -- NGram (Transformer)
ft_standard_scaler

Feature Transformation -- StandardScaler (Estimator)
ft_vector_assembler

Feature Transformation -- VectorAssembler (Transformer)
ft_regex_tokenizer

Feature Transformation -- RegexTokenizer (Transformer)
ft_robust_scaler

Feature Transformation -- RobustScaler (Estimator)
ft_vector_indexer

Feature Transformation -- VectorIndexer (Estimator)
ft_quantile_discretizer

Feature Transformation -- QuantileDiscretizer (Estimator)
ft_r_formula

Feature Transformation -- RFormula (Estimator)
ft_string_indexer

Feature Transformation -- StringIndexer (Estimator)
ft_tokenizer

Feature Transformation -- Tokenizer (Transformer)
hof_array_sort

Sorts array using a custom comparator
ft_stop_words_remover

Feature Transformation -- StopWordsRemover (Transformer)
%->%

Infix operator for composing a lambda expression
hof_exists

Determine Whether Some Element Exists in an Array Column
get_spark_sql_catalog_implementation

Retrieve the Spark connection's SQL catalog implementation property
hof_aggregate

Apply Aggregate Function to Array Column
hive_context_config

Runtime configuration interface for Hive
hof_map_filter

Filters a map
ft_vector_slicer

Feature Transformation -- VectorSlicer (Transformer)
generic_call_interface

Generic Call Interface
full_join

Full join
invoke

Invoke a Method on a JVM Object
hof_filter

Filter Array Column
hof_forall

Checks whether all elements in an array satisfy a predicate
inner_join

Inner join
ft_word2vec

Feature Transformation -- Word2Vec (Estimator)
j_invoke_method

Generic Call Interface
join.tbl_spark

Join Spark tbls.
jarray

Instantiate a Java array with a specific element type.
hof_map_zip_with

Merges two maps into one
left_join

Left join
jfloat_array

Instantiate an Array[Float].
hof_zip_with

Combines 2 Array Columns
hof_transform_keys

Transforms keys of a map
hof_transform

Transform Array Column
hof_transform_values

Transforms values of a map
jfloat

Instantiate a Java float type.
ml-transform-methods

Spark ML -- Transform, fit, and predict methods (ml_ interface)
ml-tuning

Spark ML -- Tuning
ml-params

Spark ML -- ML Params
j_invoke

Invoke a Java function.
invoke_method

Generic Call Interface
ml-persistence

Spark ML -- Model Persistence
livy_service_start

Start Livy
jobj_set_param

Parameter Setting for JVM Objects
jobj_class

Superclasses of object
livy_install

Install Livy
ml-constructors

Constructors for Pipeline Stages
ml_supervised_pipeline

Constructors for `ml_model` Objects
livy_config

Create a Spark Configuration for Livy
list_sparklyr_jars

list all sparklyr-*.jar files that have been built
ml_aft_survival_regression

Spark ML -- Survival Regression
ml_add_stage

Add a Stage to a Pipeline
ml_chisquare_test

Chi-square hypothesis testing for categorical data.
ml_als

Spark ML -- ALS
ml_call_constructor

Wrap a Spark ML JVM object
ml_bisecting_kmeans

Spark ML -- Bisecting K-Means Clustering
ml_als_tidiers

Tidying methods for Spark ML ALS
ml_clustering_evaluator

Spark ML - Clustering Evaluator
ml_decision_tree_classifier

Spark ML -- Decision Trees
ml_corr

Compute correlation matrix
ml_generalized_linear_regression

Spark ML -- Generalized Linear Regression
ml_glm_tidiers

Tidying methods for Spark ML linear models
ml_fpgrowth

Frequent Pattern Mining -- FPGrowth
ml_gaussian_mixture

Spark ML -- Gaussian Mixture clustering.
ml_evaluator

Spark ML - Evaluators
ml_feature_importances

Spark ML - Feature Importance for Tree Models
ml_default_stop_words

Default stop words
ml_evaluate

Evaluate the Model on a Validation Set
ml_kmeans_cluster_eval

Evaluate a K-mean clustering
ml_linear_regression

Spark ML -- Linear Regression
ml_linear_svc_tidiers

Tidying methods for Spark ML linear svc
ml_linear_svc

Spark ML -- LinearSVC
ml_logistic_regression_tidiers

Tidying methods for Spark ML Logistic Regression
ml_lda

Spark ML -- Latent Dirichlet Allocation
ml_logistic_regression

Spark ML -- Logistic Regression
ml_isotonic_regression_tidiers

Tidying methods for Spark ML Isotonic Regression
ml_lda_tidiers

Tidying methods for Spark ML LDA models
ml_isotonic_regression

Spark ML -- Isotonic Regression
ml_kmeans

Spark ML -- K-Means Clustering
ml_gbt_classifier

Spark ML -- Gradient Boosted Trees
ml_naive_bayes

Spark ML -- Naive-Bayes
ml_multilayer_perceptron_classifier

Spark ML -- Multilayer Perceptron
ml_metrics_regression

Extracts metrics from a fitted table
ml_metrics_binary

Extracts metrics from a fitted table
ml_one_vs_rest

Spark ML -- OneVsRest
ml_naive_bayes_tidiers

Tidying methods for Spark ML Naive Bayes
ml_metrics_multiclass

Extracts metrics from a fitted table
ml_pca_tidiers

Tidying methods for Spark ML Principal Component Analysis
ml_multilayer_perceptron_tidiers

Tidying methods for Spark ML MLP
ml_stage

Spark ML -- Pipeline stage extraction
ml_standardize_formula

Standardize Formula Input for `ml_model`
ml_model_data

Extracts data associated with a Spark ML model
ml_prefixspan

Frequent Pattern Mining -- PrefixSpan
ml_random_forest_classifier

Spark ML -- Random Forest
mutate

Mutate
ml_unsupervised_tidiers

Tidying methods for Spark ML unsupervised models
random_string

Random string generation
nest

Nest
ml_power_iteration

Spark ML -- Power Iteration Clustering
sdf_along

Create DataFrame for along Object
ml_pipeline

Spark ML -- Pipelines
na.replace

Replace Missing Values in Objects
quote_sql_name

Translate input character vector or symbol to a SQL identifier
ml_uid

Spark ML -- UID
replace_na

Replace NA
ml_tree_tidiers

Tidying methods for Spark ML tree models
sdf_bind

Bind multiple Spark DataFrames by row and column
%>%

Pipe operator
reactiveSpark

Reactive spark reader
pivot_wider

Pivot wider
right_join

Right join
reexports

Objects exported from other packages
print_jobj

Generic method for print jobj for a connection type
sdf_coalesce

Coalesces a Spark DataFrame
sdf_collect

Collect a Spark DataFrame into R.
sdf_expand_grid

Create a Spark dataframe containing all combinations of inputs
sdf_drop_duplicates

Remove duplicates from a Spark DataFrame
pivot_longer

Pivot longer
sdf_copy_to

Copy an Object into Spark
sdf_len

Create DataFrame for Length
sdf_crosstab

Cross Tabulation
ml_survival_regression_tidiers

Tidying methods for Spark ML Survival Regression
ml_summary

Spark ML -- Extraction of summary metrics
sdf_partition_sizes

Compute the number of records within each partition of a Spark DataFrame
sdf-saveload

Save / Load a Spark DataFrame
sdf-transform-methods

Spark ML -- Transform, fit, and predict methods (sdf_ interface)
sdf_dim

Support for Dimension Operations
sdf_distinct

Invoke distinct on a Spark DataFrame
sdf_persist

Persist a Spark DataFrame
sdf_pivot

Pivot a Spark DataFrame
sdf_project

Project features onto principal components
sdf_register

Register a Spark DataFrame
sdf_read_column

Read a Column from a Spark DataFrame
sdf_repartition

Repartition a Spark DataFrame
sdf_residuals.ml_model_generalized_linear_regression

Model Residuals
sdf_rgeom

Generate random samples from a geometric distribution
registerDoSpark

Register a Parallel Backend
sdf_random_split

Partition a Spark Dataframe
sdf_quantile

Compute (Approximate) Quantiles with a Spark DataFrame
sdf_num_partitions

Gets number of partitions of a Spark DataFrame
sdf_broadcast

Broadcast hint
sdf_unnest_longer

Unnest longer
sdf_to_avro

Convert column(s) to avro format
sdf_rhyper

Generate random samples from a hypergeometric distribution
sdf_rt

Generate random samples from a t-distribution
sdf_rpois

Generate random samples from a Poisson distribution
sdf_sort

Sort a Spark DataFrame
sdf_sql

Spark DataFrame from SQL
register_extension

Register a Package that Implements a Spark Extension
sdf_unnest_wider

Unnest wider
sdf_weighted_sample

Perform Weighted Random Sampling on a Spark DataFrame
sdf_separate_column

Separate a Vector Column into Scalar Columns
separate

Separate
select

Select
sdf_fast_bind_cols

Fast cbind for Spark DataFrames
sdf_is_streaming

Spark DataFrame is Streaming
sdf_seq

Create DataFrame for Range
sdf_checkpoint

Checkpoint a Spark DataFrame
spark_adaptive_query_execution

Retrieves or sets status of Spark AQE
sdf_last_index

Returns the last index of a Spark DataFrame
sdf_debug_string

Debug Info for Spark DataFrame
sdf_describe

Compute summary statistics for columns of a data frame
spark_apply

Apply an R Function in Spark
spark_advisory_shuffle_partition_size

Retrieves or sets advisory size of the shuffle partition
spark_apply_bundle

Create Bundle for Spark Apply
spark_session_config

Runtime configuration interface for the Spark Session
spark_config_value

A helper function to retrieve values from spark_config()
spark_coalesce_shuffle_partitions

Retrieves or sets whether coalescing contiguous shuffle partitions is enabled
spark_home_set

Set the SPARK_HOME environment variable
spark_home_dir

Find the SPARK_HOME directory for a version of Spark
sdf_rbeta

Generate random samples from a Beta distribution
sdf_rbinom

Generate random samples from a binomial distribution
sdf_from_avro

Convert column(s) from avro format
spark_compilation_spec

Define a Spark Compilation Specification
spark_config_exists

A helper function to check value exist under spark_config()
sdf_rgamma

Generate random samples from a Gamma distribution
sdf_rexp

Generate random samples from an exponential distribution
sdf_runif

Generate random samples from the uniform distribution U(0, 1).
spark_config_kubernetes

Kubernetes Configuration
spark_context_config

Runtime configuration interface for the Spark Context.
spark_read_delta

Read from Delta Lake into a Spark DataFrame.
sdf_rweibull

Generate random samples from a Weibull distribution.
spark_coalesce_initial_num_partitions

Retrieves or sets initial number of shuffle partitions before coalescing
sdf_rlnorm

Generate random samples from a log normal distribution
sdf_rcauchy

Generate random samples from a Cauchy distribution
sdf_rchisq

Generate random samples from a chi-squared distribution
spark_coalesce_min_num_partitions

Retrieves or sets the minimum number of shuffle partitions after coalescing
spark_connect_method

Function that negotiates the connection with the Spark back-end
sdf_rnorm

Generate random samples from the standard normal distribution
spark_connection

Retrieve the Spark Connection Associated with an R Object
spark_connection_find

Find Spark Connection
spark_dataframe

Retrieve a Spark DataFrame
spark_integ_test_skip

It lets the package know if it should test a particular functionality or not
spark_install_sync

helper function to sync sparkinstall project to sparklyr
spark_read_image

Read image data into a Spark DataFrame.
spark_read_table

Reads from a Spark Table into a Spark DataFrame.
spark_read_text

Read a Text file into a Spark DataFrame
spark-api

Access the Spark API
spark_compile

Compile Scala sources into a Java Archive
spark-connections

Manage Spark Connections
sdf_schema

Read the Schema of a Spark DataFrame
sdf_sample

Randomly Sample Rows from a Spark DataFrame
spark_config_settings

Retrieve Available Settings
spark_config_packages

Creates Spark Configuration
spark_config

Read Spark Configuration
sdf_with_sequential_id

Add a Sequential ID Column to a Spark DataFrame
spark_dependency

Define a Spark dependency
spark_write_jdbc

Writes a Spark DataFrame into a JDBC table
spark_dependency_fallback

Fallback to Spark Dependency
spark_ide_connection_open

Set of functions to provide integration with the RStudio IDE
spark_insert_table

Inserts a Spark DataFrame into a Spark table
spark_install_find

Find a given Spark installation by version.
spark_install

Download and install various versions of Spark
spark_default_compilation_spec

Default Compilation Specification for Spark Extensions
spark_read_source

Read from a generic source into a Spark DataFrame.
spark_read_binary

Read binary data into a Spark DataFrame.
spark_default_version

determine the version that will be used by default if version is NULL
spark_read_csv

Read a CSV file into a Spark DataFrame
spark_read

Read file(s) into a Spark DataFrame using a custom reader
spark_read_parquet

Read a Parquet file into a Spark DataFrame
spark_read_avro

Read Apache Avro data into a Spark DataFrame.
spark_connection-class

spark_connection class
spark_last_error

Surfaces the last error from Spark captured by internal `spark_error` function
spark_load_table

Reads from a Spark Table into a Spark DataFrame.
src_databases

Show database list
stream_name

Spark Stream's Name
stream_write_memory

Write Memory Stream
ft_sql_transformer

Feature Transformation -- SQLTransformer
stream_read_csv

Read files created by the stream
spark_apply_log

Log Writer for Spark Apply
sdf_with_unique_id

Add a Unique ID Column to a Spark DataFrame
spark_write_delta

Writes a Spark DataFrame into Delta Lake
transform_sdf

transform a subset of column(s) in a Spark Dataframe
spark_read_json

Read a JSON file into a Spark DataFrame
spark_read_libsvm

Read libsvm file into a Spark DataFrame.
spark_read_jdbc

Read from JDBC connection into a Spark DataFrame.
spark_log

View Entries in the Spark Log
spark_web

Open the Spark web interface
spark_write

Write Spark DataFrame to file using a custom writer
spark_read_orc

Read a ORC file into a Spark DataFrame
spark_auto_broadcast_join_threshold

Retrieves or sets the auto broadcast join threshold
stream_find

Find Stream
stream_generate_test

Generate Test Stream
spark_extension

Create Spark Extension
spark_get_java

Find path to Java
spark_jobj-class

spark_jobj class
spark_jobj

Retrieve a Spark JVM Object Reference
spark_version_from_home

Get the Spark Version Associated with a Spark Installation
[.tbl_spark

Subsetting operator for Spark dataframe
spark_write_table

Writes a Spark DataFrame into a Spark table
spark_versions

Retrieves a dataframe available Spark versions that van be installed.
spark_pipeline_stage

Create a Pipeline Stage Object
stream_id

Spark Stream's Identifier
spark_save_table

Saves a Spark DataFrame as a Spark table
worker_spark_apply_unbundle

Extracts a bundle of dependencies required by spark_apply()
spark_write_source

Writes a Spark DataFrame into a generic source
stream_lag

Apply lag function to columns of a Spark Streaming DataFrame
spark_write_parquet

Write a Spark DataFrame to a Parquet file
spark_statistical_routines

Generate random samples from some distribution
spark_table_name

Generate a Table Name from Expression
spark_version

Get the Spark Version Associated with a Spark Connection
spark_write_rds

Write Spark DataFrame to RDS files
stream_trigger_interval

Spark Stream Interval Trigger
stream_view

View Stream
spark_write_avro

Serialize a Spark DataFrame into Apache Avro format
spark_write_csv

Write a Spark DataFrame to a CSV
unite

Unite
unnest

Unnest
tbl_uncache

Uncache a Spark Table
stream_render

Render Stream
stream_stats

Stream Statistics
spark_write_json

Write a Spark DataFrame to a JSON file
stream_stop

Stops a Spark Stream
spark_write_orc

Write a Spark DataFrame to a ORC file
tbl_cache

Cache a Spark Table
stream_write_csv

Write files to the stream
stream_watermark

Watermark Stream
spark_write_text

Write a Spark DataFrame to a Text file
sparklyr_get_backend_port

Return the port number of a `sparklyr` backend.
stream_trigger_continuous

Spark Stream Continuous Trigger
tbl_change_db

Use specific database
DBISparkResult-class

DBI Spark Result.
checkpoint_directory

Set/Get Spark checkpoint directory
connection_config

Read configuration values for a connection
collect_from_rds

Collect Spark data serialized in RDS format into R
distinct

Distinct
ft_binarizer

Feature Transformation -- Binarizer (Transformer)
ft_bucketizer

Feature Transformation -- Bucketizer (Transformer)
compile_package_jars

Compile Scala sources into a Java Archive (jar)
copy_to.spark_connection

Copy an R Data Frame to Spark
ensure

Enforce Specific Structure for R Objects
download_scalac

Downloads default Scala Compilers
collect

Collect
arrow_enabled_object

Determine whether arrow is able to serialize the given R object
copy_to

Copy To
connection_spark_shinyapp

A Shiny app that can be used to construct a spark_connect statement
connection_is_open

Check whether the connection is open
filter

Filter
fill

Fill
dplyr_hof

dplyr wrappers for Apache Spark higher order functions