Hive
  1. Hive
  2. HIVE-3559

UDF RIGHT(string,position) to HIVE

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 0.9.0
    • Fix Version/s: None
    • Component/s: UDF
    • Labels:
      None

      Description

      Introduction

      UDF (User Defined Function) to obtain the rightmost 'n' characters from a string in HIVE.

      Relevance

      Current releases of Hive lacks a function which would returns the rightmost len characters from the string str, or NULL if any argument is NULL. The function LEFT(string,length) would return the rightmost 'length' characters from the string 'string' , or NULL if any argument is NULL which would be useful while using HiveQL. This would find its use in all the technical aspects where the concept of strings are used.

      Functionality :-

      Function Name: RIGHT(string,length)

      Returns the rightmost 'length' characters from the string or NULL if any argument is NULL.
      Example: hive>SELECT LEFT('https://www.irctc.com',3);
      -> 'com'

      Usage :-
      Case 1: To query a table to find details based on an https request
      Table :-Transaction
      Request_id|date|period_id|url_name

      0001|01/07/2012|110001|https://www.irctc.com

      0002|02/07/2012|110001|https://nextstep.tcs.com

      0003|03/07/2012|110001|https://www.hdfcbank.com

      0005|01/07/2012|110001|http://www.lmnm.org

      0006|08/07/2012|110001|http://nextstart.gov

      0007|10/07/2012|110001|https://netbanking.icicibank.com

      0012|21/07/2012|110001|http://www.people.nic

      0026|08/07/2012|110001|http://nextprobs.gov

      00023|25/07/2012|110001|https://netbanking.canarabank.com

      Query : select * from transaction where RIGHT(url_name,3)='com';

      Result :-
      0001|01/07/2012|110001|https://www.irctc.com
      0002|02/07/2012|110001|https://nextstep.tcs.com
      0003|03/07/2012|110001|https://www.hdfcbank.com
      0007|10/07/2012|110001|https://netbanking.icicibank.com
      00023|25/07/2012|110001|https://netbanking.canarabank.com

      1. udf_right.q
        0.2 kB
        Meenu K Chandran
      2. udf_right.q.out
        2 kB
        Meenu K Chandran
      3. HIVE-3559.1.patch.txt
        6 kB
        Meenu K Chandran

        Activity

        Vinaya Varghese created issue -
        Ashutosh Chauhan made changes -
        Field Original Value New Value
        Fix Version/s 0.10.0 [ 12320745 ]
        Meenu K Chandran made changes -
        Attachment HIVE-3559.1.patch.txt [ 12567567 ]
        Attachment udf_right.q.out [ 12567568 ]
        Attachment udf_right.q [ 12567569 ]
        Carl Steinbach made changes -
        Assignee Meenu K Chandran [ meenu ]

          People

          • Assignee:
            Meenu K Chandran
            Reporter:
            Vinaya Varghese
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development