TO_NULLABLE (Lakehouse v1)
Converts a value to its nullable equivalent.
When you apply this function to a value, it checks if the value is already able to hold NULL values or not. If the value is already able to hold NULL values, the function will return the value without making any changes.
However, if the value is not able to hold NULL values, the TO_NULLABLE function will modify the value to make it able to hold NULL values. It does this by wrapping the value in a structure that can hold NULL values, which means the value can now hold NULL values in the future.
Analyze Syntax
Section titled “Analyze Syntax”func.to_nullable(x);Analyze Examples
Section titled “Analyze Examples”func.typeof(3), func.to_nullable(3), func.typeof(func.to_nullable(3))
func.typeof(3) | func.to_nullable(3) | func.typeof(func.to_nullable(3)) |-----------------+---------------------+----------------------------------+TINYINT UNSIGNED | 3 | TINYINT UNSIGNED NULL |SQL Syntax
Section titled “SQL Syntax”TO_NULLABLE(x);Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
| x | The original value. |
Return Type
Section titled “Return Type”Returns a value of the same data type as the input value, but wrapped in a nullable container if the input value is not already nullable.
SQL Examples
Section titled “SQL Examples”SELECT typeof(3), TO_NULLABLE(3), typeof(TO_NULLABLE(3));
typeof(3) |to_nullable(3)|typeof(to_nullable(3))|----------------+--------------+----------------------+TINYINT UNSIGNED| 3|TINYINT UNSIGNED NULL |