Github user MLnick commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17059#discussion_r103674659
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/recommendation/ALSSuite.scala ---
    @@ -205,6 +206,69 @@ class ALSSuite
         assert(decompressed.toSet === expected)
       }
     
    +  test("CheckedCast") {
    +    val checkedCast = new ALS().checkedCast
    +    val df = spark.sqlContext.range(1)
    +
    +    withClue("Valid Integer Ids") {
    +      df.select(checkedCast( lit(123) )).collect()
    +    }
    +
    +    withClue("Valid Long Ids") {
    +      df.select(checkedCast( lit(1231L) )).collect()
    +    }
    +
    +    withClue("Valid Decimal Ids") {
    +      df.select(checkedCast( lit(123).cast(DecimalType(15, 2)) )).collect()
    +    }
    +
    +    withClue("Valid Double Ids") {
    +      df.select(checkedCast( lit(123.0) )).collect()
    +    }
    +
    +    withClue("Invalid Long: out of range") {
    +      val e: SparkException = intercept[SparkException] {
    +        df.select(checkedCast( lit(1231000000000L) )).collect()
    +      }
    +      assert(e.getMessage.contains("either out of Integer range or 
contained a fractional part"))
    --- End diff --
    
    May as well factor this string out to a `val`.


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

Reply via email to