Function | Syntax | Description |
Function 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. |
Function 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. |
from_unixtime(__TIMESTAMP__/1000, 'Asia/Shanghai')) or manually add a time zone offset (for example, cast(__TIMESTAMP__+8*60*60*1000 as timestamp) or cast(__TIMESTAMP__ as timestamp)+ INTERVAL 8 HOUR).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?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback