Friday, 23 December 2022

Hive: ucase: Return the string in upper case

Signature

ucase(string str)
hive> SELECT ucase('Hello');
OK
_c0
HELLO
Time taken: 0.04 seconds, Fetched: 1 row(s)

 

Previous                                                    Next                                                    Home

Hive: trim: trim all trailing and leading spaces

Signature

trim(string str)

Trim all trailing and leading spaces.

hive> SELECT concat(trim('    Hello    '), 'World');
OK
_c0
HelloWorld


Previous                                                    Next                                                    Home

Hive: substring: return sub string

Signature

substring(string sourceStr, int startPosition [,int length])

Return substring from start position to length number of characters. If the length is not specified, then it considers size of string as length.

hive> SELECT substring('Hello World', 4, 5);
OK
_c0
lo Wo
Time taken: 0.039 seconds, Fetched: 1 row(s)
hive> ;
hive> SELECT substring('Hello World', 4);
OK
_c0
lo World
Time taken: 0.038 seconds, Fetched: 1 row(s)


Previous                                                    Next                                                    Home

Hive: substr: return sub string

Signature

substr(string sourceStr, int startPosition [,int length])

Return substring from start position to length number of characters. If the length is not specified, then it considers size of string as length.


hive> SELECT substr('Hello World', 4, 5);
OK
_c0
lo Wo
Time taken: 0.051 seconds, Fetched: 1 row(s)
hive> ;
hive> ;
hive> SELECT substr('Hello World', 4);
OK
_c0
lo World
Time taken: 0.046 seconds, Fetched: 1 row(s)

  

Previous                                                    Next                                                    Home

Hive: split: Split the string by a separator

Signature

split(string str, string separator)

 

Split the string by a separator and return array of strings as output.

hive> SELECT split('ram,23,india', ',');
OK
_c0
["ram","23","india"]
Time taken: 0.039 seconds, Fetched: 1 row(s)

 


Previous                                                    Next                                                    Home

Hive: space: return n number of spaces

Signature

space(int n)

Return ‘n’ number of spaces.

hive> SELECT concat('Hello', space(10), 'world');
OK
_c0
Hello          world
Time taken: 0.039 seconds, Fetched: 1 row(s)

 

Previous                                                    Next                                                    Home

Hive: rtrim: Remove right side trailing spaces

Signature

rtrim(string str)

 

Remove all the right side trailing spaces in a string.

hive> SELECT concat(rtrim('  Hello    '), 'world');
OK
_c0
  Helloworld
Time taken: 0.049 seconds, Fetched: 1 row(s)

 

 

Previous                                                    Next                                                    Home