Hiveql - RIGHT() LEFT() Function

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

Is there a function in Hiveql that is equivalent to Right() or Left() fuction form TSQL? For example, RIGHT(col1,10) to get the first 10 characters from col1.

thank you

回答1:

There is no right or left function but you can implement same with substr like

left (column, nchar) = substr(column, 0, nchar)  right  (column, nchar) = substr (column, -nchar) 


回答2:

This works for me for right function: substr (col, -nchar) = right(col, nchar).

hive> select substr('adbcefghij',-4); ghij Time taken: 40.839 seconds, Fetched: 1 row(s) 

Hope this helps.



回答3:

right(column, nchar) = substr(column, (length(column)-nchar+1), nchar)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!