retronym commented on a change in pull request #30455:
URL: https://github.com/apache/spark/pull/30455#discussion_r534630859



##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/RFormulaParser.scala
##########
@@ -298,7 +299,10 @@ private[ml] object RFormulaParser extends RegexParsers {
   private val expr = (sum | term)
 
   private val formula: Parser[ParsedRFormula] =
-    (label ~ "~" ~ expr) ^^ { case r ~ "~" ~ t => ParsedRFormula(r, 
t.asTerms.terms) }
+    (label ~ "~" ~ expr) ^^ {
+      case r ~ "~" ~ t => ParsedRFormula(r, t.asTerms.terms)

Review comment:
       For future reference, a slightly cleaner way to express this in a 
warning free way is:
   
   ```
   ((label <~ "~") ~ expr ) ^^ {
     case r ~ t => ParsedRFormula(r, t.asTerms.terms)
   }
   ```
   
   It also avoids duplicating the `"~"` token in the parser and the action.

##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/RFormulaParser.scala
##########
@@ -298,7 +299,10 @@ private[ml] object RFormulaParser extends RegexParsers {
   private val expr = (sum | term)
 
   private val formula: Parser[ParsedRFormula] =
-    (label ~ "~" ~ expr) ^^ { case r ~ "~" ~ t => ParsedRFormula(r, 
t.asTerms.terms) }
+    (label ~ "~" ~ expr) ^^ {
+      case r ~ "~" ~ t => ParsedRFormula(r, t.asTerms.terms)

Review comment:
       For future reference, a slightly cleaner way to express this in a 
warning free way is:
   
   ```scala
   ((label <~ "~") ~ expr ) ^^ {
     case r ~ t => ParsedRFormula(r, t.asTerms.terms)
   }
   ```
   
   It also avoids duplicating the `"~"` token in the parser and the action.




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



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

Reply via email to