Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13635#discussion_r67388232
  
    --- Diff: R/pkg/R/sparkR.R ---
    @@ -270,27 +291,97 @@ sparkRSQL.init <- function(jsc = NULL) {
     #'}
     
     sparkRHive.init <- function(jsc = NULL) {
    -  if (exists(".sparkRHivesc", envir = .sparkREnv)) {
    -    return(get(".sparkRHivesc", envir = .sparkREnv))
    +  .Deprecated("sparkR.session.getOrCreate")
    +
    +  if (exists(".sparkRsession", envir = .sparkREnv)) {
    +    return(get(".sparkRsession", envir = .sparkREnv))
       }
     
    -  # If jsc is NULL, create a Spark Context
    -  sc <- if (is.null(jsc)) {
    -    sparkR.init()
    -  } else {
    -    jsc
    +  # Default to without Hive support for backward compatibility.
    +  sparkR.session.getOrCreate(enableHiveSupport = TRUE)
    +}
    +
    +#' Get the existing SparkSession or initialize a new SparkSession.
    +#'
    +#' Additional Spark properties can be set (...), and these named 
parameters take priority over
    +#' over values in master, appName, named lists of sparkConfig.
    +#'
    +#' @param master The Spark master URL
    +#' @param appName Application name to register with cluster manager
    +#' @param sparkHome Spark Home directory
    +#' @param sparkConfig Named list of Spark configuration to set on worker 
nodes
    +#' @param sparkExecutorConfig Named list of Spark configuration to be used 
when launching executors
    +#' @param sparkJars Character vector of jar files to pass to the worker 
nodes
    +#' @param sparkPackages Character vector of packages from 
spark-packages.org
    +#' @param enableHiveSupport Enable support for Hive; once set, this cannot 
be turned off on an
    +#'        existing session
    +#' @export
    +#' @examples
    +#'\dontrun{
    +#' sparkR.session.getOrCreate()
    +#' df <- read.json(path)
    +#'
    +#' sparkR.session.getOrCreate("local[2]", "SparkR", "/home/spark")
    +#' sparkR.session.getOrCreate("yarn-client", "SparkR", "/home/spark",
    +#'                            list(spark.executor.memory="4g"),
    +#'                            list(LD_LIBRARY_PATH="/directory of JVM 
libraries (libjvm.so) on workers/"),
    +#'                            c("one.jar", "two.jar", "three.jar"),
    +#'                            c("com.databricks:spark-avro_2.10:2.0.1"))
    +#' sparkR.session.getOrCreate(spark.master = "yarn-client",
    +#'                            spark.executor.memory = "4g")
    +#'}
    +#' @note since 2.0.0
    +
    +sparkR.session.getOrCreate <- function(
    +  master = "",
    +  appName = "SparkR",
    +  sparkHome = Sys.getenv("SPARK_HOME"),
    +  sparkConfig = list(),
    +  sparkExecutorConfig = list(),
    +  sparkJars = "",
    +  sparkPackages = "",
    +  enableHiveSupport = TRUE,
    --- End diff --
    
    right, i think it behaves like python in that it does not throw exception. 
Scala's `SparkSession.enableHiveSupport()` does throw.
    but correct, we would be having a different default than Scala or Python 
(as explained above)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to