Impala - Check if a string is a number

5.8k views Asked by At

Is there any way to check if a string is a number in Impala? like is_numeric is SQL?

2

There are 2 answers

0
M.C.G On

This did work for me:

select
  case
    when cast(mycol as double) is not null
    then 'numeric'
    else 'string'
  end
from mytable
0
adam.r On

The 'regep_like' function is helpful here. For instance, the following will select integers:

select * from table where regexp_like(field,'^[[:digit:]]+$')