📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

STRIP_NULL_VALUE



Converts a JSON null value to a SQL NULL value. All other variant values are passed unchanged.

Syntax

STRIP_NULL_VALUE(<variant_expr>)

Arguments

An expression of type VARIANT.

Return Type

  • If the expression is a JSON null value, the function returns a SQL NULL.
  • If the expression is not a JSON null value, the function returns the input value.

Examples

SELECT STRIP_NULL_VALUE(PARSE_JSON('null')) AS value; ╭───────╮ │ value │ ├───────┤ │ NULL │ ╰───────╯ SELECT STRIP_NULL_VALUE(PARSE_JSON('{"name": "Alice", "age": 30, "city": null}')) AS value; ╭───────────────────────────────────────╮ │ value │ ├───────────────────────────────────────┤ │ {"age":30,"city":null,"name":"Alice"} │ ╰───────────────────────────────────────╯

Was this page helpful?