Search code examples
hadoopuser-defined-functionsclouderaimpala

impala string function to extract text after a given separator


Say I have a string of variable length such as:

'633000000HIQWA4:005160000UT334'
'00YYSKSG004:00YJDJJDA3443'
'300SGDK112WA4:00KFJJD900'

which impala string function to use to extract text after : for e.g.:

'005160000UT334'
'00YJDJJDA3443'
'00KFJJD900'

Solution

  • Use split_part(string source, string delimiter, bigint n) function. The value of n would be as the fields are numbered starting from 1.

    select split_part('633000000HIQWA4:005160000UT334',':',2);
    
    +----------------------------------------------------+
    | split_part('633000000HIQWA4:005160000UT334',':',2) |
    +----------------------------------------------------+
    | 005160000UT334                                     |
    +----------------------------------------------------+