IS_BOOL (Azure Cosmos DB)

Returns a Boolean value indicating if the type of the specified expression is a Boolean.

Syntax

IS_BOOL(<expr>)  

Arguments

expr
Is any expression.

Return types

Returns a Boolean expression.

Examples

The following example checks objects of JSON Boolean, number, string, null, object, array, and undefined types using the IS_BOOL function.

SELECT   
    IS_BOOL(true) AS isBool1,   
    IS_BOOL(1) AS isBool2,  
    IS_BOOL("value") AS isBool3,   
    IS_BOOL(null) AS isBool4,  
    IS_BOOL({prop: "value"}) AS isBool5,   
    IS_BOOL([1, 2, 3]) AS isBool6,  
    IS_BOOL({prop: "value"}.prop2) AS isBool7  

Here is the result set.

[{"isBool1":true,"isBool2":false,"isBool3":false,"isBool4":false,"isBool5":false,"isBool6":false,"isBool7":false}]

Remarks

This system function will benefit from a range index.

Next steps