MaxGekk commented on code in PR #41169:
URL: https://github.com/apache/spark/pull/41169#discussion_r1196017647
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -2134,30 +2134,145 @@ case class OctetLength(child: Expression)
* A function that return the Levenshtein distance between the two given
strings.
*/
@ExpressionDescription(
- usage = "_FUNC_(str1, str2) - Returns the Levenshtein distance between the
two given strings.",
+ usage = """
+ _FUNC_(str1, str2) - Returns the Levenshtein distance between the two
given strings.
+ If threshold is set and distance more than it, return -1.""",
Review Comment:
Please, add the parameter that you mentioned: `_FUNC_(str1, str2[,
threshold])`
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -2134,30 +2134,145 @@ case class OctetLength(child: Expression)
* A function that return the Levenshtein distance between the two given
strings.
*/
@ExpressionDescription(
- usage = "_FUNC_(str1, str2) - Returns the Levenshtein distance between the
two given strings.",
+ usage = """
+ _FUNC_(str1, str2) - Returns the Levenshtein distance between the two
given strings.
+ If threshold is set and distance more than it, return -1.""",
examples = """
Examples:
> SELECT _FUNC_('kitten', 'sitting');
3
+ > SELECT _FUNC_('kitten', 'sitting', 2);
+ -1
""",
since = "1.5.0",
group = "string_funcs")
-case class Levenshtein(left: Expression, right: Expression) extends
BinaryExpression
- with ImplicitCastInputTypes with NullIntolerant {
+case class Levenshtein(
+ left: Expression,
+ right: Expression,
+ threshold: Option[Expression] = None)
+ extends Expression
Review Comment:
How about to extend `TernaryExpression`, see for instance:
https://github.com/apache/spark/blob/e37c74b3ef40aebd33ca9338210300a1ed1164f8/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala#L1974-L1979
Or there are some reasons to don't do that?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]