Does Hive have a String split function?

前端 未结 3 947
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 05:48

I am looking for a in-built String split function in Hive? e.g. if String is:

A|B|C|D|E

Then I want to have a function like:



        
3条回答
  •  有刺的猬
    2020-12-13 06:41

    Just a clarification on the answer given by Bkkbrad.

    I tried this suggestion and it did not work for me.

    For example,

    split('aa|bb','\\|')
    

    produced:

    ["","a","a","|","b","b",""]
    

    But,

    split('aa|bb','[|]')
    

    produced the desired result:

    ["aa","bb"]
    

    Including the metacharacter '|' inside the square brackets causes it to be interpreted literally, as intended, rather than as a metacharacter.

    For elaboration of this behaviour of regexp, see: http://www.regular-expressions.info/charclass.html

提交回复
热议问题