luhn_check
function
Applies to: Databricks SQL Databricks Runtime 13.3 LTS and above
Returns true
if numStr
passes the Luhn algorithm check.
The Luhn algorithm is used for example, to validate creditcard numbers.
Syntax
luhn_check(numStr)
Arguments
numStr
: An STRING expression composed of digits'0'
through'9'
.
Returns
A BOOLEAN.
If numStr
contains any character that is not a digit the result is false
.
If the input’s last digit matches the algorithm the result is true
Examples
> SELECT luhn_check('12345');
false
> SELECT luhn_check('12344');
true
> SELECT luhn_check('1234 4');
false
Related
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for