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

    https://github.com/apache/spark/pull/17483#discussion_r109082276
  
    --- Diff: R/pkg/R/catalog.R ---
    @@ -0,0 +1,478 @@
    +#
    +# 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.
    +#
    +
    +# catalog.R: SparkSession catalog functions
    +
    +#' Create an external table
    +#'
    +#' Creates an external table based on the dataset in a data source,
    +#' Returns a SparkDataFrame associated with the external table.
    +#'
    +#' The data source is specified by the \code{source} and a set of 
options(...).
    +#' If \code{source} is not specified, the default data source configured by
    +#' "spark.sql.sources.default" will be used.
    +#'
    +#' @param tableName a name of the table.
    +#' @param path the path of files to load.
    +#' @param source the name of external data source.
    +#' @param schema the schema of the data for certain data source.
    +#' @param ... additional argument(s) passed to the method.
    +#' @return A SparkDataFrame.
    +#' @rdname createExternalTable
    +#' @export
    +#' @examples
    +#'\dontrun{
    +#' sparkR.session()
    +#' df <- createExternalTable("myjson", path="path/to/json", source="json", 
schema)
    +#' }
    +#' @name createExternalTable
    +#' @method createExternalTable default
    +#' @note createExternalTable since 1.4.0
    +createExternalTable.default <- function(tableName, path = NULL, source = 
NULL, schema = NULL, ...) {
    +  sparkSession <- getSparkSession()
    +  options <- varargsToStrEnv(...)
    +  if (!is.null(path)) {
    +    options[["path"]] <- path
    +  }
    +  catalog <- callJMethod(sparkSession, "catalog")
    +  if (!is.null(schema)) {
    +    sdf <- callJMethod(catalog, "createExternalTable", tableName, source, 
options)
    +  } else {
    +    sdf <- callJMethod(catalog, "createExternalTable", tableName, source, 
schema$jobj, options)
    +  }
    +  dataFrame(sdf)
    +}
    +
    +createExternalTable <- function(x, ...) {
    --- End diff --
    
    yes, I'm aware. I'm not sure if we need to make changes to SQLContext - 
schema is required for json source but it's ok in Scala to use createTable 
instead.
    
    It makes sense to add in R here though because
    - there is no createTable method
    - createTable just sounds too generic and too much like existing R method, 
that I wasn't sure it's a good idea to add in R
    - createExternalTable since 2.0 is decoupled from SQLContext or 
SparkSession - it doesn't take either as parameter and it's calling on catalog



---
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]

Reply via email to