isnum()
The isnum() function checks whether the value passed as an argument is a numeric type and returns a boolean.
Syntax
isnum(EXPR)
Parameters
EXPR- A field name or expression whose type to check.
Description
The isnum() function returns true if the result of evaluating EXPR is a numeric type (32-bit integer, 64-bit integer, 64-bit double, etc.), and false otherwise.
If the result of evaluating EXPR is null, returns false because null is not a numeric value.
Error codes
N/A
Usage examples
To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.
-
Checking the integer-type
statusfieldtable limit=5 WEB_APACHE_SAMPLE | eval result = isnum(status) | fields status, result | # result: true -
Checking the string-type
methodfieldtable limit=5 WEB_APACHE_SAMPLE | eval result = isnum(method) | fields method, result | # result: false -
NULL input
json "{'val': null}" | eval result = isnum(val) | # result: false
Compatibility
The isnum() function has been available since before Sonar 4.0.