'RIGHT() / LEFT() functions

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



Solution 1:[1]

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

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

Solution 2:[2]

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

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
Solution 2