-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-8506] Add pakages to R context created through init. #6928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
holdenk
wants to merge
6
commits into
apache:master
from
holdenk:SPARK-8506-sparkr-does-not-provide-an-easy-way-to-depend-on-spark-packages-when-performing-init-from-inside-of-r
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c818556
Add pakages to R
holdenk c1a9233
refactor for testing
holdenk c7a4471
Add some documentation
holdenk 865a90c
strip spaces for comparision
holdenk fa8bc92
typo: sparm -> spark
holdenk b60dd63
Add an example with the spark-csv package
holdenk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| context("functions in client.R") | ||
|
|
||
| test_that("adding spark-testing-base as a package works", { | ||
| args <- generateSparkSubmitArgs("", "", "", "", | ||
| "holdenk:spark-testing-base:1.3.0_0.0.5") | ||
| expect_equal(gsub("[[:space:]]", "", args), | ||
| gsub("[[:space:]]", "", | ||
| "--packages holdenk:spark-testing-base:1.3.0_0.0.5")) | ||
| }) | ||
|
|
||
| test_that("no package specified doesn't add packages flag", { | ||
| args <- generateSparkSubmitArgs("", "", "", "", "") | ||
| expect_equal(gsub("[[:space:]]", "", args), | ||
| "") | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,9 @@ All of the examples on this page use sample data included in R or the Spark dist | |
| <div data-lang="r" markdown="1"> | ||
| The entry point into SparkR is the `SparkContext` which connects your R program to a Spark cluster. | ||
| You can create a `SparkContext` using `sparkR.init` and pass in options such as the application name | ||
| etc. Further, to work with DataFrames we will need a `SQLContext`, which can be created from the | ||
| SparkContext. If you are working from the SparkR shell, the `SQLContext` and `SparkContext` should | ||
| already be created for you. | ||
| , any spark packages depended on, etc. Further, to work with DataFrames we will need a `SQLContext`, | ||
| which can be created from the SparkContext. If you are working from the SparkR shell, the | ||
| `SQLContext` and `SparkContext` should already be created for you. | ||
|
|
||
| {% highlight r %} | ||
| sc <- sparkR.init() | ||
|
|
@@ -62,7 +62,16 @@ head(df) | |
|
|
||
| SparkR supports operating on a variety of data sources through the `DataFrame` interface. This section describes the general methods for loading and saving data using Data Sources. You can check the Spark SQL programming guide for more [specific options](sql-programming-guide.html#manually-specifying-options) that are available for the built-in data sources. | ||
|
|
||
| The general method for creating DataFrames from data sources is `read.df`. This method takes in the `SQLContext`, the path for the file to load and the type of data source. SparkR supports reading JSON and Parquet files natively and through [Spark Packages](http://spark-packages.org/) you can find data source connectors for popular file formats like [CSV](http://spark-packages.org/package/databricks/spark-csv) and [Avro](http://spark-packages.org/package/databricks/spark-avro). | ||
| The general method for creating DataFrames from data sources is `read.df`. This method takes in the `SQLContext`, the path for the file to load and the type of data source. SparkR supports reading JSON and Parquet files natively and through [Spark Packages](http://spark-packages.org/) you can find data source connectors for popular file formats like [CSV](http://spark-packages.org/package/databricks/spark-csv) and [Avro](http://spark-packages.org/package/databricks/spark-avro). These packages can either be added by | ||
| specifying `--packages` with `spark-submit` or `sparkR` commands, or if creating context through `init` | ||
| you can specify the packages with the `packages` argument. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also add a code example here with say the CSV reader ? We could also fold it in the |
||
|
|
||
| <div data-lang="r" markdown="1"> | ||
| {% highlight r %} | ||
| sc <- sparkR.init(packages="com.databricks:spark-csv_2.11:1.0.3") | ||
| sqlContext <- sparkRSQL.init(sc) | ||
| {% endhighlight %} | ||
| </div> | ||
|
|
||
| We can see how to use data sources using an example JSON input file. Note that the file that is used here is _not_ a typical JSON file. Each line in the file must contain a separate, self-contained valid JSON object. As a consequence, a regular multi-line JSON file will most often fail. | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor:
sparkHomeis not used in this function