Right characters from hive string

In hive there are no commands for getting the Left and Right part of a string.

For Left it is not hard to find a workaround:

SELECT SUBSTR('abcdefgh',1,2);
ab

What is the most elegant way to extract the two right hand side characters of the string?

Answers


Apparently it is possible to use negative numbers inside SUBSTR, as such you can get the relevant substring as follows:

SELECT SUBSTR('abcdefgh',-2,2);
gh

Need Your Help

Impliment cron script in yii2 rest api

cron yii2

i am using Advance Api template in yii2 . i need cron script which call

Getting a generic method to infer the type parameter from the runtime type

c# generics overloading extension-methods

I have some extension methods for an abstract base class, let's say Pet, that themselves call a generic method that takes in that type parameter.