Skip to content
Snippets Groups Projects
  1. Oct 20, 2016
    • Felix Cheung's avatar
      [SPARKR] fix warnings · 3180272d
      Felix Cheung authored
      ## What changes were proposed in this pull request?
      
      Fix for a bunch of test warnings that were added recently.
      We need to investigate why warnings are not turning into errors.
      
      ```
      Warnings -----------------------------------------------------------------------
      1. createDataFrame uses files for large objects (test_sparkSQL.R#215) - Use Sepal_Length instead of Sepal.Length  as column name
      
      2. createDataFrame uses files for large objects (test_sparkSQL.R#215) - Use Sepal_Width instead of Sepal.Width  as column name
      
      3. createDataFrame uses files for large objects (test_sparkSQL.R#215) - Use Petal_Length instead of Petal.Length  as column name
      
      4. createDataFrame uses files for large objects (test_sparkSQL.R#215) - Use Petal_Width instead of Petal.Width  as column name
      
      Consider adding
        importFrom("utils", "object.size")
      to your NAMESPACE file.
      ```
      
      ## How was this patch tested?
      
      unit tests
      
      Author: Felix Cheung <felixcheung_m@hotmail.com>
      
      Closes #15560 from felixcheung/rwarnings.
      3180272d
  2. Oct 12, 2016
    • Hossein's avatar
      [SPARK-17790][SPARKR] Support for parallelizing R data.frame larger than 2GB · 5cc503f4
      Hossein authored
      ## What changes were proposed in this pull request?
      If the R data structure that is being parallelized is larger than `INT_MAX` we use files to transfer data to JVM. The serialization protocol mimics Python pickling. This allows us to simply call `PythonRDD.readRDDFromFile` to create the RDD.
      
      I tested this on my MacBook. Following code works with this patch:
      ```R
      intMax <- .Machine$integer.max
      largeVec <- 1:intMax
      rdd <- SparkR:::parallelize(sc, largeVec, 2)
      ```
      
      ## How was this patch tested?
      * [x] Unit tests
      
      Author: Hossein <hossein@databricks.com>
      
      Closes #15375 from falaki/SPARK-17790.
      5cc503f4
  3. Oct 11, 2016
    • Wenchen Fan's avatar
      [SPARK-17720][SQL] introduce static SQL conf · b9a14718
      Wenchen Fan authored
      ## What changes were proposed in this pull request?
      
      SQLConf is session-scoped and mutable. However, we do have the requirement for a static SQL conf, which is global and immutable, e.g. the `schemaStringThreshold` in `HiveExternalCatalog`, the flag to enable/disable hive support, the global temp view database in https://github.com/apache/spark/pull/14897.
      
      Actually we've already implemented static SQL conf implicitly via `SparkConf`, this PR just make it explicit and expose it to users, so that they can see the config value via SQL command or `SparkSession.conf`, and forbid users to set/unset static SQL conf.
      
      ## How was this patch tested?
      
      new tests in SQLConfSuite
      
      Author: Wenchen Fan <wenchen@databricks.com>
      
      Closes #15295 from cloud-fan/global-conf.
      b9a14718
    • Yanbo Liang's avatar
      [SPARK-15153][ML][SPARKR] Fix SparkR spark.naiveBayes error when label is numeric type · 23405f32
      Yanbo Liang authored
      ## What changes were proposed in this pull request?
      Fix SparkR ```spark.naiveBayes``` error when response variable of dataset is numeric type.
      See details and how to reproduce this bug at [SPARK-15153](https://issues.apache.org/jira/browse/SPARK-15153).
      
      ## How was this patch tested?
      Add unit test.
      
      Author: Yanbo Liang <ybliang8@gmail.com>
      
      Closes #15431 from yanboliang/spark-15153-2.
      23405f32
  4. Oct 07, 2016
    • hyukjinkwon's avatar
      [SPARK-17665][SPARKR] Support options/mode all for read/write APIs and options in other types · 9d8ae853
      hyukjinkwon authored
      ## What changes were proposed in this pull request?
      
      This PR includes the changes below:
      
        - Support `mode`/`options` in `read.parquet`, `write.parquet`, `read.orc`, `write.orc`, `read.text`, `write.text`, `read.json` and `write.json` APIs
      
        - Support other types (logical, numeric and string) as options for `write.df`, `read.df`, `read.parquet`, `write.parquet`, `read.orc`, `write.orc`, `read.text`, `write.text`, `read.json` and `write.json`
      
      ## How was this patch tested?
      
      Unit tests in `test_sparkSQL.R`/ `utils.R`.
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      
      Closes #15239 from HyukjinKwon/SPARK-17665.
      9d8ae853
  5. Oct 05, 2016
    • hyukjinkwon's avatar
      [SPARK-17658][SPARKR] read.df/write.df API taking path optionally in SparkR · c9fe10d4
      hyukjinkwon authored
      ## What changes were proposed in this pull request?
      
      `write.df`/`read.df` API require path which is not actually always necessary in Spark. Currently, it only affects the datasources implementing `CreatableRelationProvider`. Currently, Spark currently does not have internal data sources implementing this but it'd affect other external datasources.
      
      In addition we'd be able to use this way in Spark's JDBC datasource after https://github.com/apache/spark/pull/12601 is merged.
      
      **Before**
      
       - `read.df`
      
        ```r
      > read.df(source = "json")
      Error in dispatchFunc("read.df(path = NULL, source = NULL, schema = NULL, ...)",  :
        argument "x" is missing with no default
      ```
      
        ```r
      > read.df(path = c(1, 2))
      Error in dispatchFunc("read.df(path = NULL, source = NULL, schema = NULL, ...)",  :
        argument "x" is missing with no default
      ```
      
        ```r
      > read.df(c(1, 2))
      Error in invokeJava(isStatic = TRUE, className, methodName, ...) :
        java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
      	at org.apache.spark.sql.execution.datasources.DataSource.hasMetadata(DataSource.scala:300)
      	at
      ...
      In if (is.na(object)) { :
      ...
      ```
      
       - `write.df`
      
        ```r
      > write.df(df, source = "json")
      Error in (function (classes, fdef, mtable)  :
        unable to find an inherited method for function ‘write.df’ for signature ‘"function", "missing"’
      ```
      
        ```r
      > write.df(df, source = c(1, 2))
      Error in (function (classes, fdef, mtable)  :
        unable to find an inherited method for function ‘write.df’ for signature ‘"SparkDataFrame", "missing"’
      ```
      
        ```r
      > write.df(df, mode = TRUE)
      Error in (function (classes, fdef, mtable)  :
        unable to find an inherited method for function ‘write.df’ for signature ‘"SparkDataFrame", "missing"’
      ```
      
      **After**
      
      - `read.df`
      
        ```r
      > read.df(source = "json")
      Error in loadDF : analysis error - Unable to infer schema for JSON at . It must be specified manually;
      ```
      
        ```r
      > read.df(path = c(1, 2))
      Error in f(x, ...) : path should be charactor, null or omitted.
      ```
      
        ```r
      > read.df(c(1, 2))
      Error in f(x, ...) : path should be charactor, null or omitted.
      ```
      
      - `write.df`
      
        ```r
      > write.df(df, source = "json")
      Error in save : illegal argument - 'path' is not specified
      ```
      
        ```r
      > write.df(df, source = c(1, 2))
      Error in .local(df, path, ...) :
        source should be charactor, null or omitted. It is 'parquet' by default.
      ```
      
        ```r
      > write.df(df, mode = TRUE)
      Error in .local(df, path, ...) :
        mode should be charactor or omitted. It is 'error' by default.
      ```
      
      ## How was this patch tested?
      
      Unit tests in `test_sparkSQL.R`
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      
      Closes #15231 from HyukjinKwon/write-default-r.
      c9fe10d4
  6. Oct 04, 2016
  7. Sep 27, 2016
    • hyukjinkwon's avatar
      [SPARK-17499][SPARKR][FOLLOWUP] Check null first for layers in spark.mlp to... · 4a833956
      hyukjinkwon authored
      [SPARK-17499][SPARKR][FOLLOWUP] Check null first for layers in spark.mlp to avoid warnings in test results
      
      ## What changes were proposed in this pull request?
      
      Some tests in `test_mllib.r` are as below:
      
      ```r
      expect_error(spark.mlp(df, layers = NULL), "layers must be a integer vector with length > 1.")
      expect_error(spark.mlp(df, layers = c()), "layers must be a integer vector with length > 1.")
      ```
      
      The problem is, `is.na` is internally called via `na.omit` in `spark.mlp` which causes warnings as below:
      
      ```
      Warnings -----------------------------------------------------------------------
      1. spark.mlp (test_mllib.R#400) - is.na() applied to non-(list or vector) of type 'NULL'
      
      2. spark.mlp (test_mllib.R#401) - is.na() applied to non-(list or vector) of type 'NULL'
      ```
      
      ## How was this patch tested?
      
      Manually tested. Also, Jenkins tests and AppVeyor.
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      
      Closes #15232 from HyukjinKwon/remove-warnnings.
      4a833956
  8. Sep 26, 2016
  9. Sep 23, 2016
    • Jeff Zhang's avatar
      [SPARK-17210][SPARKR] sparkr.zip is not distributed to executors when running sparkr in RStudio · f62ddc59
      Jeff Zhang authored
      ## What changes were proposed in this pull request?
      
      Spark will add sparkr.zip to archive only when it is yarn mode (SparkSubmit.scala).
      ```
          if (args.isR && clusterManager == YARN) {
            val sparkRPackagePath = RUtils.localSparkRPackagePath
            if (sparkRPackagePath.isEmpty) {
              printErrorAndExit("SPARK_HOME does not exist for R application in YARN mode.")
            }
            val sparkRPackageFile = new File(sparkRPackagePath.get, SPARKR_PACKAGE_ARCHIVE)
            if (!sparkRPackageFile.exists()) {
              printErrorAndExit(s"$SPARKR_PACKAGE_ARCHIVE does not exist for R application in YARN mode.")
            }
            val sparkRPackageURI = Utils.resolveURI(sparkRPackageFile.getAbsolutePath).toString
      
            // Distribute the SparkR package.
            // Assigns a symbol link name "sparkr" to the shipped package.
            args.archives = mergeFileLists(args.archives, sparkRPackageURI + "#sparkr")
      
            // Distribute the R package archive containing all the built R packages.
            if (!RUtils.rPackages.isEmpty) {
              val rPackageFile =
                RPackageUtils.zipRLibraries(new File(RUtils.rPackages.get), R_PACKAGE_ARCHIVE)
              if (!rPackageFile.exists()) {
                printErrorAndExit("Failed to zip all the built R packages.")
              }
      
              val rPackageURI = Utils.resolveURI(rPackageFile.getAbsolutePath).toString
              // Assigns a symbol link name "rpkg" to the shipped package.
              args.archives = mergeFileLists(args.archives, rPackageURI + "#rpkg")
            }
          }
      ```
      So it is necessary to pass spark.master from R process to JVM. Otherwise sparkr.zip won't be distributed to executor.  Besides that I also pass spark.yarn.keytab/spark.yarn.principal to spark side, because JVM process need them to access secured cluster.
      
      ## How was this patch tested?
      
      Verify it manually in R Studio using the following code.
      ```
      Sys.setenv(SPARK_HOME="/Users/jzhang/github/spark")
      .libPaths(c(file.path(Sys.getenv(), "R", "lib"), .libPaths()))
      library(SparkR)
      sparkR.session(master="yarn-client", sparkConfig = list(spark.executor.instances="1"))
      df <- as.DataFrame(mtcars)
      head(df)
      
      ```
      
      …
      
      Author: Jeff Zhang <zjffdu@apache.org>
      
      Closes #14784 from zjffdu/SPARK-17210.
      f62ddc59
    • WeichenXu's avatar
      [SPARK-17499][SPARKR][ML][MLLIB] make the default params in sparkR spark.mlp... · f89808b0
      WeichenXu authored
      [SPARK-17499][SPARKR][ML][MLLIB] make the default params in sparkR spark.mlp consistent with MultilayerPerceptronClassifier
      
      ## What changes were proposed in this pull request?
      
      update `MultilayerPerceptronClassifierWrapper.fit` paramter type:
      `layers: Array[Int]`
      `seed: String`
      
      update several default params in sparkR `spark.mlp`:
      `tol` --> 1e-6
      `stepSize` --> 0.03
      `seed` --> NULL ( when seed == NULL, the scala-side wrapper regard it as a `null` value and the seed will use the default one )
      r-side `seed` only support 32bit integer.
      
      remove `layers` default value, and move it in front of those parameters with default value.
      add `layers` parameter validation check.
      
      ## How was this patch tested?
      
      tests added.
      
      Author: WeichenXu <WeichenXu123@outlook.com>
      
      Closes #15051 from WeichenXu123/update_py_mlp_default.
      f89808b0
  10. Sep 22, 2016
    • Shivaram Venkataraman's avatar
      Skip building R vignettes if Spark is not built · 9f24a17c
      Shivaram Venkataraman authored
      ## What changes were proposed in this pull request?
      
      When we build the docs separately we don't have the JAR files from the Spark build in
      the same tree. As the SparkR vignettes need to launch a SparkContext to be built, we skip building them if JAR files don't exist
      
      ## How was this patch tested?
      
      To test this we can run the following:
      ```
      build/mvn -DskipTests -Psparkr clean
      ./R/create-docs.sh
      ```
      You should see a line `Skipping R vignettes as Spark JARs not found` at the end
      
      Author: Shivaram Venkataraman <shivaram@cs.berkeley.edu>
      
      Closes #15200 from shivaram/sparkr-vignette-skip.
      9f24a17c
  11. Sep 21, 2016
  12. Sep 19, 2016
  13. Sep 14, 2016
  14. Sep 13, 2016
    • junyangq's avatar
      [SPARK-17317][SPARKR] Add SparkR vignette · a454a4d8
      junyangq authored
      ## What changes were proposed in this pull request?
      
      This PR tries to add a SparkR vignette, which works as a friendly guidance going through the functionality provided by SparkR.
      
      ## How was this patch tested?
      
      Manual test.
      
      Author: junyangq <qianjunyang@gmail.com>
      Author: Shivaram Venkataraman <shivaram@cs.berkeley.edu>
      Author: Junyang Qian <junyangq@databricks.com>
      
      Closes #14980 from junyangq/SPARKR-vignette.
      a454a4d8
  15. Sep 10, 2016
  16. Sep 09, 2016
  17. Sep 08, 2016
  18. Sep 07, 2016
  19. Sep 03, 2016
    • Junyang Qian's avatar
      [SPARK-17315][SPARKR] Kolmogorov-Smirnov test SparkR wrapper · abb2f921
      Junyang Qian authored
      ## What changes were proposed in this pull request?
      
      This PR tries to add Kolmogorov-Smirnov Test wrapper to SparkR. This wrapper implementation only supports one sample test against normal distribution.
      
      ## How was this patch tested?
      
      R unit test.
      
      Author: Junyang Qian <junyangq@databricks.com>
      
      Closes #14881 from junyangq/SPARK-17315.
      abb2f921
  20. Sep 02, 2016
    • Junyang Qian's avatar
      [SPARKR][MINOR] Fix docs for sparkR.session and count · d2fde6b7
      Junyang Qian authored
      ## What changes were proposed in this pull request?
      
      This PR tries to add some more explanation to `sparkR.session`. It also modifies doc for `count` so when grouped in one doc, the description doesn't confuse users.
      
      ## How was this patch tested?
      
      Manual test.
      
      ![screen shot 2016-09-02 at 1 21 36 pm](https://cloud.githubusercontent.com/assets/15318264/18217198/409613ac-7110-11e6-8dae-cb0c8df557bf.png)
      
      Author: Junyang Qian <junyangq@databricks.com>
      
      Closes #14942 from junyangq/fixSparkRSessionDoc.
      d2fde6b7
    • Srinath Shankar's avatar
      [SPARK-17298][SQL] Require explicit CROSS join for cartesian products · e6132a6c
      Srinath Shankar authored
      ## What changes were proposed in this pull request?
      
      Require the use of CROSS join syntax in SQL (and a new crossJoin
      DataFrame API) to specify explicit cartesian products between relations.
      By cartesian product we mean a join between relations R and S where
      there is no join condition involving columns from both R and S.
      
      If a cartesian product is detected in the absence of an explicit CROSS
      join, an error must be thrown. Turning on the
      "spark.sql.crossJoin.enabled" configuration flag will disable this check
      and allow cartesian products without an explicit CROSS join.
      
      The new crossJoin DataFrame API must be used to specify explicit cross
      joins. The existing join(DataFrame) method will produce a INNER join
      that will require a subsequent join condition.
      That is df1.join(df2) is equivalent to select * from df1, df2.
      
      ## How was this patch tested?
      
      Added cross-join.sql to the SQLQueryTestSuite to test the check for cartesian products. Added a couple of tests to the DataFrameJoinSuite to test the crossJoin API. Modified various other test suites to explicitly specify a cross join where an INNER join or a comma-separated list was previously used.
      
      Author: Srinath Shankar <srinath@databricks.com>
      
      Closes #14866 from srinathshankar/crossjoin.
      e6132a6c
    • Felix Cheung's avatar
      [SPARK-17376][SPARKR] followup - change since version · eac1d0e9
      Felix Cheung authored
      ## What changes were proposed in this pull request?
      
      change since version in doc
      
      ## How was this patch tested?
      
      manual
      
      Author: Felix Cheung <felixcheung_m@hotmail.com>
      
      Closes #14939 from felixcheung/rsparkversion2.
      eac1d0e9
    • Felix Cheung's avatar
      [SPARKR][DOC] regexp_extract should doc that it returns empty string when match fails · 419eefd8
      Felix Cheung authored
      ## What changes were proposed in this pull request?
      
      Doc change - see https://issues.apache.org/jira/browse/SPARK-16324
      
      ## How was this patch tested?
      
      manual check
      
      Author: Felix Cheung <felixcheung_m@hotmail.com>
      
      Closes #14934 from felixcheung/regexpextractdoc.
      419eefd8
    • Felix Cheung's avatar
      [SPARK-17376][SPARKR] Spark version should be available in R · 812333e4
      Felix Cheung authored
      ## What changes were proposed in this pull request?
      
      Add sparkR.version() API.
      
      ```
      > sparkR.version()
      [1] "2.1.0-SNAPSHOT"
      ```
      
      ## How was this patch tested?
      
      manual, unit tests
      
      Author: Felix Cheung <felixcheung_m@hotmail.com>
      
      Closes #14935 from felixcheung/rsparksessionversion.
      812333e4
    • wm624@hotmail.com's avatar
      [SPARK-16883][SPARKR] SQL decimal type is not properly cast to number when... · 0f30cded
      wm624@hotmail.com authored
      [SPARK-16883][SPARKR] SQL decimal type is not properly cast to number when collecting SparkDataFrame
      
      ## What changes were proposed in this pull request?
      
      (Please fill in changes proposed in this fix)
      
      registerTempTable(createDataFrame(iris), "iris")
      str(collect(sql("select cast('1' as double) as x, cast('2' as decimal) as y  from iris limit 5")))
      
      'data.frame':	5 obs. of  2 variables:
       $ x: num  1 1 1 1 1
       $ y:List of 5
        ..$ : num 2
        ..$ : num 2
        ..$ : num 2
        ..$ : num 2
        ..$ : num 2
      
      The problem is that spark returns `decimal(10, 0)` col type, instead of `decimal`. Thus, `decimal(10, 0)` is not handled correctly. It should be handled as "double".
      
      As discussed in JIRA thread, we can have two potential fixes:
      1). Scala side fix to add a new case when writing the object back; However, I can't use spark.sql.types._ in Spark core due to dependency issues. I don't find a way of doing type case match;
      
      2). SparkR side fix: Add a helper function to check special type like `"decimal(10, 0)"` and replace it with `double`, which is PRIMITIVE type. This special helper is generic for adding new types handling in the future.
      
      I open this PR to discuss pros and cons of both approaches. If we want to do Scala side fix, we need to find a way to match the case of DecimalType and StructType in Spark Core.
      
      ## How was this patch tested?
      
      (Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
      
      Manual test:
      > str(collect(sql("select cast('1' as double) as x, cast('2' as decimal) as y  from iris limit 5")))
      'data.frame':	5 obs. of  2 variables:
       $ x: num  1 1 1 1 1
       $ y: num  2 2 2 2 2
      R Unit tests
      
      Author: wm624@hotmail.com <wm624@hotmail.com>
      
      Closes #14613 from wangmiao1981/type.
      0f30cded
  21. Aug 31, 2016
  22. Aug 29, 2016
    • Shivaram Venkataraman's avatar
      [SPARK-16581][SPARKR] Make JVM backend calling functions public · 736a7911
      Shivaram Venkataraman authored
      ## What changes were proposed in this pull request?
      
      This change exposes a public API in SparkR to create objects, call methods on the Spark driver JVM
      
      ## How was this patch tested?
      
      (Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
      
      Unit tests, CRAN checks
      
      Author: Shivaram Venkataraman <shivaram@cs.berkeley.edu>
      
      Closes #14775 from shivaram/sparkr-java-api.
      736a7911
    • Junyang Qian's avatar
      [SPARKR][MINOR] Fix LDA doc · 6a0fda2c
      Junyang Qian authored
      ## What changes were proposed in this pull request?
      
      This PR tries to fix the name of the `SparkDataFrame` used in the example. Also, it gives a reference url of an example data file so that users can play with.
      
      ## How was this patch tested?
      
      Manual test.
      
      Author: Junyang Qian <junyangq@databricks.com>
      
      Closes #14853 from junyangq/SPARKR-FixLDADoc.
      6a0fda2c
  23. Aug 26, 2016
    • Junyang Qian's avatar
      [SPARKR][MINOR] Fix example of spark.naiveBayes · 18832162
      Junyang Qian authored
      ## What changes were proposed in this pull request?
      
      The original example doesn't work because the features are not categorical. This PR fixes this by changing to another dataset.
      
      ## How was this patch tested?
      
      Manual test.
      
      Author: Junyang Qian <junyangq@databricks.com>
      
      Closes #14820 from junyangq/SPARK-FixNaiveBayes.
      18832162
  24. Aug 24, 2016
    • Junyang Qian's avatar
      [SPARKR][MINOR] Add installation message for remote master mode and improve other messages · 3a60be4b
      Junyang Qian authored
      ## What changes were proposed in this pull request?
      
      This PR gives informative message to users when they try to connect to a remote master but don't have Spark package in their local machine.
      
      As a clarification, for now, automatic installation will only happen if they start SparkR in R console (rather than from sparkr-shell) and connect to local master. In the remote master mode, local Spark package is still needed, but we will not trigger the install.spark function because the versions have to match those on the cluster, which involves more user input. Instead, we here try to provide detailed message that may help the users.
      
      Some of the other messages have also been slightly changed.
      
      ## How was this patch tested?
      
      Manual test.
      
      Author: Junyang Qian <junyangq@databricks.com>
      
      Closes #14761 from junyangq/SPARK-16579-V1.
      3a60be4b
    • Junyang Qian's avatar
      [SPARKR][MINOR] Add more examples to window function docs · 18708f76
      Junyang Qian authored
      ## What changes were proposed in this pull request?
      
      This PR adds more examples to window function docs to make them more accessible to the users.
      
      It also fixes default value issues for `lag` and `lead`.
      
      ## How was this patch tested?
      
      Manual test, R unit test.
      
      Author: Junyang Qian <junyangq@databricks.com>
      
      Closes #14779 from junyangq/SPARKR-FixWindowFunctionDocs.
      18708f76
    • Felix Cheung's avatar
      [MINOR][SPARKR] fix R MLlib parameter documentation · 945c04bc
      Felix Cheung authored
      ## What changes were proposed in this pull request?
      
      Fixed several misplaced param tag - they should be on the spark.* method generics
      
      ## How was this patch tested?
      
      run knitr
      junyangq
      
      Author: Felix Cheung <felixcheung_m@hotmail.com>
      
      Closes #14792 from felixcheung/rdocmllib.
      945c04bc
Loading