spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] ozancicek commented on a change in pull request #24939: [SPARK-18569][ML][R] Support RFormula arithmetic, I() and spark functions
Date Wed, 04 Sep 2019 13:56:02 GMT
ozancicek 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_r320772910
 
 

 ##########
 File path: mllib/src/test/scala/org/apache/spark/ml/feature/RFormulaParserSuite.scala
 ##########
 @@ -198,4 +198,31 @@ class RFormulaParserSuite extends SparkFunSuite {
         "Petal.Length:Petal.Width"),
       schema)
   }
+
+  test("parse skip whitespace") {
+    val schema = (new StructType)
+      .add("a", "int", true)
+      .add("b", "long", false)
+      .add("c", "string", true)
+    checkParse(" ~a+  b :  c  ", "", Seq("a", "b:c"))
+    checkParse(" ~ a  *     b", "", Seq("a", "b", "a:b"))
+    checkParse("~ (  a +b  )^  2", "", Seq("a", "b", "a:b"))
+    checkParse("~  .  ^ 2  - a-b  -  c", "", Seq("a:b", "a:c", "b:c"), schema)
+    checkParse("~ ( a) *  ( (  (b ) : c )  )", "", Seq("a", "b:c", "a:b:c"))
+  }
+
+  test("parse functions") {
+    checkParse("y ~ I(a+b) + c", "y", Seq("a+b", "c"))
+    checkParse("y ~ I(a+b)*c", "y", Seq("a+b", "c", "a+b:c"))
+    checkParse("y ~ (I((a+b)) + c)^2", "y", Seq("(a+b)", "c", "(a+b):c"))
+    checkParse("y ~ I(log(a)*(log(a)*2)) + b", "y", Seq("log(a)*(log(a)*2)", "b"))
+    checkParse("y ~ exp(a) + (b + c)", "y", Seq("exp(a)", "b", "c"))
+    checkParse("log(y) ~ a + log(b)", "log(y)", Seq("a", "log(b)"))
+    checkParse("I(c+d) ~ a + log(b)", "c+d", Seq("a", "log(b)"))
 
 Review comment:
   also added tests for those functions

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message