zhengruifeng 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_r351074594
##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/RFormula.scala
##########
@@ -442,11 +487,16 @@ object RFormulaModel extends MLReadable[RFormulaModel] {
val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
val dataPath = new Path(path, "data").toString
- val data = sparkSession.read.parquet(dataPath).select("label", "terms",
"hasIntercept").head()
+ val df = sparkSession.read.parquet(dataPath)
+ val columns = Seq("label", "terms", "hasIntercept", "evalExprs")
+ val data = df.select(columns.intersect(df.columns).map(df(_)): _*)
+ .head()
val label = data.getString(0)
val terms = data.getAs[Seq[Seq[String]]](1)
val hasIntercept = data.getBoolean(2)
- val resolvedRFormula = ResolvedRFormula(label, terms, hasIntercept)
+ // Check for old saved models which do not have evalExprs.
Review comment:
Here I suggest use method `VersionUtils.majorMinorVersion`
```scala
val (major, minor) = VersionUtils.majorMinorVersion(metadata.sparkVersion)
if (major.toInt < 3) {
//for old models
} else {
//for new models
}
```
----------------------------------------------------------------
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]