The padding functions are used to fill the left or right side of a string with a specific set of characters. These functions are useful for formatting the output of a query. It is necessary to specify the padding length, which is a number representing the total length of the string returned after padding.
- Note: The below specified functions are common in both Apache Hive & Apache Impala.
Apache Hive provides LPAD and RPAD features that are similar in functionality to those that available in relational database systems.
SELECT LPAD(‘bigdatansql’,19, ‘https: //’);
This returns https://bigdatansql as output.
SELECT LPAD(289,10,0);
This returns 0000000289 as output to make it 10 characters in length as provided.
SELECT RPAD(‘bigdatansql’,15,’.com’);
This returns bigdatansql.com as output to make it 15 characters in length as provided.
Refer to the below screenshot.
Hope you find this article helpful.
Please click on the follow button to receive updates on latest posts.
4 comments