felixcheung commented on a change in pull request #24939: [SPARK-18569][ML][R] 
Support RFormula arithmetic, I() and spark functions
URL: https://github.com/apache/spark/pull/24939#discussion_r320054935
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/feature/RFormula.scala
 ##########
 @@ -404,6 +429,30 @@ class RFormulaModel private[feature](
       s"Label column already exists and is not of type 
${NumericType.simpleString}.")
   }
 
+  private def foldExprs(dataframe: DataFrame)(f: (DataFrame, String) => 
DataFrame): DataFrame =
+    resolvedFormula.evalExprs.foldLeft(dataframe)(f)
+
+  private def transformSelectExprs(dataframe: DataFrame): DataFrame = 
foldExprs(dataframe) {
+    case(df, colname) => df.withColumn(colname, expr(colname))
+  }
+
+  private def transformDropExprs(dataframe: DataFrame): DataFrame = 
foldExprs(dataframe) {
+    case(df, colname) => df.drop(col(s"`$colname`"))
+  }
+
+  private def transformSelectExprsSchema(schema: StructType): StructType = {
+    val spark = SparkSession.builder().getOrCreate()
+    val dummyRDD = spark.sparkContext.parallelize(Seq(Row.empty))
 
 Review comment:
   should it use 
http://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.SparkContext@emptyRDD[T](implicitevidence$8:scala.reflect.ClassTag[T]):org.apache.spark.rdd.RDD[T]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to