StringToNull (Azure Cosmos DB)StringToNull (Azure Cosmos DB)

返回已转换为 Null 的表达式。Returns expression translated to null. 如果表达式无法转换,则返回未定义的表达式。If expression cannot be translated, returns undefined.

语法Syntax

StringToNull(<str_expr>)  

参数Arguments

str_exprstr_expr
是要解析为 null 表达式的字符串表达式。Is a string expression to be parsed as a null expression.

返回类型Return types

返回一个 Null 表达式或未定义的表达式。Returns a null expression or undefined.

示例Examples

以下示例演示 StringToNull 在不同类型中的行为方式。The following example shows how StringToNull behaves across different types.

下面是输入有效的示例。The following are examples with valid input.

只能在 "null" 之前或之后使用空格。Whitespace is allowed only before or after "null".

SELECT 
    StringToNull("null") AS n1, 
    StringToNull("  null ") AS n2,
    IS_NULL(StringToNull("null   ")) AS n3

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

[{"n1": null, "n2": null, "n3": true}]

下面是输入无效的示例。The following are examples with invalid input.

Null 值区分大小写,必须全用小写字符(即 "null")来表示。Null is case sensitive and must be written with all lowercase characters i.e. "null".

SELECT    
    StringToNull("NULL"),
    StringToNull("Null")

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

[{}]

传递的表达式将会解析为 null 表达式;以下输入不会计算为 null 类型,因此会返回未定义。The expression passed will be parsed as a null expression; these inputs do not evaluate to type null and thus return undefined.

SELECT    
    StringToNull("true"), 
    StringToNull(false), 
    StringToNull(undefined),
    StringToNull(NaN) 

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

[{}]

备注Remarks

此系统函数不会使用索引。This system function will not utilize the index.

后续步骤Next steps