You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2023/06/27 12:00:29 UTC
[GitHub] [spark] LuciferYang commented on a diff in pull request #41724: [SPARK-43493][SPARK-43769][SPARK-43773][FOLLOWUP] Strengthen type checking and better comply with Connect specifications
LuciferYang commented on code in PR #41724:
URL: https://github.com/apache/spark/pull/41724#discussion_r1243617728
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -2164,9 +2164,18 @@ case class Levenshtein(
if (children.length > 3 || children.length < 2) {
throw QueryCompilationErrors.wrongNumArgsError(
toSQLId(prettyName), Seq(2, 3), children.length)
- } else {
- super.checkInputDataTypes()
}
+ threshold match {
+ case Some(e) if e.foldable && e.eval().asInstanceOf[Int] < 0 =>
+ return DataTypeMismatch(
+ errorSubClass = "VALUE_OUT_OF_RANGE",
+ messageParameters = Map(
+ "exprName" -> toSQLId("threshold"),
+ "valueRange" -> s"[0, ${Int.MaxValue}]",
+ "currentValue" -> toSQLValue(e.eval().asInstanceOf[Int], IntegerType)))
Review Comment:
nit: Is it possible to calculate `e.eval().asInstanceOf[Int]` only once?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org