Github user grzegorz-chilkiewicz commented on a diff in the pull request:
https://github.com/apache/spark/pull/10741#discussion_r49697177
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/feature/StopWordsRemoverSuite.scala ---
@@ -89,4 +89,22 @@ class StopWordsRemoverSuite
.setCaseSensitive(true)
testDefaultReadWrite(t)
}
+
+ test("StopWordsRemover output column already exists") {
+ val outpuCol = "expected"
+ val remover = new StopWordsRemover()
+ .setInputCol("raw")
+ .setOutputCol(outpuCol)
+ .setCaseSensitive(true)
+ val dataSet = sqlContext.createDataFrame(Seq(
+ (Seq("A"), Seq("A")),
+ (Seq("The", "the"), Seq("The"))
+ )).toDF("raw", outpuCol)
+
+ val thrown = intercept[IllegalArgumentException] {
+ testStopWordsRemover(remover, dataSet)
+ }
+ assert(thrown.getClass === classOf[IllegalArgumentException])
--- End diff --
I tried to take pattern from:
github.com/apache/spark/blob/master/core/src/test/scala/org/apache/spark/FailureSuite.scala#L100-L106
I think this check theoretically could be useful:
https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html
is non-abstract class and have subclasses,
intercept can catch e.g. PatternSyntaxException, which is not what we
should treat as a test success.
But of course, PatternSyntaxException is very unlikely to have message
"requirement failed: Column ${outpuCol} already exists."
Am I correct?
Maybe "assert(thrown.getClass === classOf[IllegalArgumentException])" line
should stay?
---
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]