Function | Syntax | Description |
cast | cast(x as type) | Parses the data type of x .During cast execution, if a value fails to be parsed, the system terminates the entire query and analysis operation. |
try_cast | try_cast(x as type) | Parses the data type of x .During try_cast execution, if a value fails to be parsed, the system returns NULL and continues processing by skipping the value. |
typeof | typeof(x) | Returns the data type of x . |
try_cast
function to avoid query and analysis failures caused by dirty data.cast
function is used to parse the data type of x
. During cast
execution, if a value fails to be parsed, the system terminates the entire query and analysis operation.cast(x as type)
Parameter | Description |
x | The parameter value can be of any type. |
type | SQL data type. Valid values: bigint , varchar , double , boolean , timestamp , decimal , array , or map . |
type
is timestamp
, x
must be a timestamp in milliseconds (such as 1597807109000) or a time string in the ISO 8601 time format (such as 2019-12-25T16:17:01+08:00).type
parameter.* | select cast(0.01 as bigint)
__TIMESTAMP__
to TIMESTAMP
.* | select cast(TIMESTAMP as timestamp)
try_cast
function is used to parse the data type of x
. During try_cast
execution, if a value fails to be parsed, the system returns NULL
and continues processing by skipping the value.try_cast(x as type)
Parameter | Description |
x | The parameter value can be of any type. |
type | SQL data type. Valid values: bigint , varchar , double , boolean , timestamp , decimal , array , or map . |
type
parameter.* | select try_cast(remote_user as varchar)
Index Data Type | SQL Data Type |
long | bigint |
text | varchar |
double | double |
json | varchar |
Was this page helpful?