IS_DEFINED (Azure Cosmos DB)IS_DEFINED (Azure Cosmos DB)

返回一个布尔,它指示属性是否已经分配了值。Returns a Boolean indicating if the property has been assigned a value.

语法Syntax

IS_DEFINED(<expr>)  

参数Arguments

exprexpr
是任何表达式。Is any expression.

返回类型Return types

返回一个布尔表达式。Returns a Boolean expression.

示例Examples

以下示例检查指定的 JSON 文档中是否存在某个属性。The following example checks for the presence of a property within the specified JSON document. 第一个示例返回 true,因为“a” 存在;第二个示例返回 false,因为“b”不存在。The first returns true since "a" is present, but the second returns false since "b" is absent.

SELECT IS_DEFINED({ "a" : 5 }.a) AS isDefined1, IS_DEFINED({ "a" : 5 }.b) AS isDefined2 

下面是结果集。Here is the result set.

[{"isDefined1":true,"isDefined2":false}]  

备注Remarks

此系统函数将从范围索引中获益。This system function will benefit from a range index.

后续步骤Next steps