Github user felixcheung commented on a diff in the pull request:
https://github.com/apache/spark/pull/13885#discussion_r68496462
--- Diff: R/pkg/R/SQLContext.R ---
@@ -110,11 +110,46 @@ infer_type <- function(x) {
}
}
-getDefaultSqlSource <- function() {
+#' Get Runtime Config from the current active SparkSession
+#'
+#' Get Runtime Config from the current active SparkSession.
+#' To change SparkSession Runtime Config, please see `sparkR.session()`.
+#'
+#' @param key (optional) The key of the config to get, if omitted, all
config is returned
+#' @param defaultValue (optional) The default value of the config to
return if they config is not
+#' set, if omitted, the call fails if the config key is not set
+#' @return a list of config values with keys as their names
+#' @rdname sparkR.conf
+#' @name sparkR.conf
+#' @export
+#' @examples
+#'\dontrun{
+#' sparkR.session()
+#' allConfigs <- sparkR.conf()
+#' masterValue <- unlist(sparkR.conf("spark.master"))
+#' namedConfig <- sparkR.conf("spark.executor.memory", "0g")
+#' }
+#' @note sparkR.conf since 2.0.0
+sparkR.conf <- function(key, defaultValue) {
sparkSession <- getSparkSession()
- conf <- callJMethod(sparkSession, "conf")
- source <- callJMethod(conf, "get", "spark.sql.sources.default",
"org.apache.spark.sql.parquet")
- source
+ if (missing(key)) {
+ m <- callJStatic("org.apache.spark.sql.api.r.SQLUtils",
"getSessionConf", sparkSession)
+ as.list(m, all.names = TRUE, sorted = TRUE)
+ } else {
+ conf <- callJMethod(sparkSession, "conf")
+ value <- if (missing(defaultValue)) {
+ callJMethod(conf, "get", key) # throws if key not found
--- End diff --
Done
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]