'Impala - Check if a string is a number
Is there any way to check if a string is a number in Impala?
like is_numeric
is SQL?
Solution 1:[1]
This did work for me:
select
case
when cast(mycol as double) is not null
then 'numeric'
else 'string'
end
from mytable
Solution 2:[2]
The 'regep_like' function is helpful here. For instance, the following will select integers:
select * from table where regexp_like(field,'^[[:digit:]]+$')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | astentx |
Solution 2 | adam.r |