Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12836#discussion_r62602912
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala 
---
    @@ -145,16 +145,50 @@ private[sql] object SQLUtils {
           packageNames: Array[Byte],
           broadcastVars: Array[Object],
           schema: StructType): DataFrame = {
    -    val bv = broadcastVars.map(x => x.asInstanceOf[Broadcast[Object]])
    -    val realSchema =
    -      if (schema == null) {
    -        SERIALIZED_R_DATA_SCHEMA
    -      } else {
    -        schema
    -      }
    +    val bv = broadcastVars.map(_.asInstanceOf[Broadcast[Object]])
    +    val realSchema = if (schema == null) SERIALIZED_R_DATA_SCHEMA else 
schema
         df.mapPartitionsInR(func, packageNames, bv, realSchema)
       }
     
    +  /**
    +   * The helper function for gapply() on R side.
    +   */
    +  def gapply(
    +      df: DataFrame,
    +      func: Array[Byte],
    +      packageNames: Array[Byte],
    +      broadcastVars: Array[Object],
    +      schema: StructType,
    +      col: String): DataFrame = {
    +    val realSchema = if (schema == null) SERIALIZED_R_DATA_SCHEMA else 
schema
    +    val dfSchema = df.select(df(col)).schema
    +    if (dfSchema.length == 0) throw new IllegalArgumentException(s"Invaid 
column name $col")
    +    val dataType = dfSchema(0).dataType
    +    val sqlContext = df.sqlContext
    +
    +    import sqlContext.implicits._
    +
    --- End diff --
    
    The following logic is not necessary.


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