[ 
https://issues.apache.org/jira/browse/SPARK-10903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14964570#comment-14964570
 ] 

Felix Cheung commented on SPARK-10903:
--------------------------------------

Something to do with the namespace
{code}
> methods("createDataFrame")
no methods found
> get0("createDataFrame")
function (sqlContext, data, schema = NULL, samplingRatio = 1)
...
<environment: namespace:SparkR>
{code}

I assume you are typing in the code? That seems to allow UseMethod to find it. 
Whereas when the method is from the package it doesn't.

Ok this works but it's "custom dispatch code":
{code}
createDataFrame <- function(x, ...) {
  if (class(x) == "jobj") {
    f <- get0("createDataFrame.jobj")
  } else {
    f <- get0("createDataFrame.default")
  }
  f(x, ...)
}
createDataFrame.jobj <- function(sqlContext, data, schema = NULL, samplingRatio 
= 1.0) {
  #createDataFrame.default(data, schema, samplingRatio)
}

createDataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0) {
{code}

Not sure why methods/UseMethod doesn't work but get0 does.


> Make sqlContext global 
> -----------------------
>
>                 Key: SPARK-10903
>                 URL: https://issues.apache.org/jira/browse/SPARK-10903
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SparkR
>            Reporter: Narine Kokhlikyan
>            Priority: Minor
>
> Make sqlContext global so that we don't have to always specify it.
> e.g. createDataFrame(iris) instead of createDataFrame(sqlContext, iris)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to