IS_PRIMITIVE (Azure Cosmos DB)

APPLIES TO: SQL API

Returns a Boolean value indicating if the type of the specified expression is a primitive (string, Boolean, numeric, or null).

Syntax

IS_PRIMITIVE(<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_PRIMITIVE function.

SELECT   
           IS_PRIMITIVE(true) AS isPrim1,   
           IS_PRIMITIVE(1) AS isPrim2,  
           IS_PRIMITIVE("value") AS isPrim3,   
           IS_PRIMITIVE(null) AS isPrim4,  
           IS_PRIMITIVE({prop: "value"}) AS isPrim5,   
           IS_PRIMITIVE([1, 2, 3]) AS isPrim6,  
           IS_PRIMITIVE({prop: "value"}.prop2) AS isPrim7  

Here is the result set.

[{"isPrim1": true, "isPrim2": true, "isPrim3": true, "isPrim4": true, "isPrim5": false, "isPrim6": false, "isPrim7": false}]  

Remarks

This system function will benefit from a range index.

Next steps