vinodkc commented on code in PR #39747:
URL: https://github.com/apache/spark/pull/39747#discussion_r1091322757
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -3039,3 +3039,43 @@ case class SplitPart (
partNum = newChildren.apply(2))
}
}
+
+/**
+ * Function to check if a given number string is a valid Luhn number. Returns
true, if the number
+ * string is a valid Luhn number, false otherwise.
+ */
+@ExpressionDescription(
+ usage = """
+ _FUNC_(str ) - Checks that a string of digits is valid according to the
Luhn algorithm.
+ This checksum function is widely applied on credit card numbers and
government identification
+ numbers to distinguish valid numbers from mistyped, incorrect numbers.
Review Comment:
To check newlines, I tried following tests
`spark-sql> desc function luhn_check;`
```
Function: luhn_check
Class: org.apache.spark.sql.catalyst.expressions.Luhncheck
Usage:
luhn_check(str ) - Checks that a string of digits is valid according to
the Luhn algorithm.
This checksum function is widely applied on credit card numbers and
government identification
numbers to distinguish valid numbers from mistyped, incorrect numbers.
```
I did the same test on other builtin functions like `substring_index`,
`rpad`
```
spark-sql> desc function substring_index;
Function: substring_index
Class: org.apache.spark.sql.catalyst.expressions.SubstringIndex
Usage:
substring_index(str, delim, count) - Returns the substring from `str`
before `count` occurrences of the delimiter `delim`.
If `count` is positive, everything to the left of the final delimiter
(counting from the
left) is returned. If `count` is negative, everything to the right of
the final delimiter
(counting from the right) is returned. The function substring_index
performs a case-sensitive match
when searching for `delim`.
```
Please suggest, if it is not suggested to add new lines, I can change the
function doc
--
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]