Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-38776][MLLIB][TESTS][FOLLOWUP] Disable ANSI_ENABLED more for Out of Range failures #36054

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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