Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,24 @@ class ALSSuite extends MLTest with DefaultReadWriteTest with Logging {
}

val msg = "ALS only supports non-Null values"
withClue("Invalid Long: out of range") {
val df = sc.parallelize(Seq(
(1231000000000L, 12L, 0.5),
(1112L, 21L, 1.0)
)).toDF("item", "user", "rating")
val e = intercept[Exception] { new ALS().setMaxIter(1).fit(df) }
assert(e.getMessage.contains(msg))
}
withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
withClue("Invalid Long: out of range") {
val df = sc.parallelize(Seq(
(1231000000000L, 12L, 0.5),
(1112L, 21L, 1.0)
)).toDF("item", "user", "rating")
val e = intercept[Exception] { new ALS().setMaxIter(1).fit(df) }
assert(e.getMessage.contains(msg))
}

withClue("Invalid Double: out of range") {
val df = sc.parallelize(Seq(
(1231000000000.0, 12.0, 0.5),
(111.0, 21.0, 1.0)
)).toDF("item", "user", "rating")
val e = intercept[Exception] { new ALS().setMaxIter(1).fit(df) }
assert(e.getMessage.contains(msg))
withClue("Invalid Double: out of range") {
val df = sc.parallelize(Seq(
(1231000000000.0, 12.0, 0.5),
(111.0, 21.0, 1.0)
)).toDF("item", "user", "rating")
val e = intercept[Exception] { new ALS().setMaxIter(1).fit(df) }
assert(e.getMessage.contains(msg))
}
}

withClue("Invalid Double: fractional part") {
Expand All @@ -275,18 +277,20 @@ class ALSSuite extends MLTest with DefaultReadWriteTest with Logging {
assert(e.getMessage.contains(msg))
}

withClue("Invalid Decimal: out of range") {
val df = sc.parallelize(Seq(
(1231000000000.0, 12L, 0.5),
(1112.0, 21L, 1.0)
)).toDF("item", "user", "rating")
.select(
col("item").cast(DecimalType(15, 2)).as("item"),
col("user").cast(DecimalType(15, 2)).as("user"),
col("rating")
)
val e = intercept[Exception] { new ALS().setMaxIter(1).fit(df) }
assert(e.getMessage.contains(msg))
withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
withClue("Invalid Decimal: out of range") {
val df = sc.parallelize(Seq(
(1231000000000.0, 12L, 0.5),
(1112.0, 21L, 1.0)
)).toDF("item", "user", "rating")
.select(
col("item").cast(DecimalType(15, 2)).as("item"),
col("user").cast(DecimalType(15, 2)).as("user"),
col("rating")
)
val e = intercept[Exception] { new ALS().setMaxIter(1).fit(df) }
assert(e.getMessage.contains(msg))
}
}

withClue("Invalid Decimal: fractional part") {
Expand Down