Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-686

add UDF substring_index

Log workAgile BoardRank to TopRank to BottomBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.3.0, 2.0.0
    • UDF
    • None

    Description

      SUBSTRING_INDEX(str,delim,count)

      Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.
      Examples:

      SELECT SUBSTRING_INDEX('www.mysql.com', '.', 3);
      --www.mysql.com
      SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
      --www.mysql
      SELECT SUBSTRING_INDEX('www.mysql.com', '.', 1);
      --www
      SELECT SUBSTRING_INDEX('www.mysql.com', '.', 0);
      --''
      SELECT SUBSTRING_INDEX('www.mysql.com', '.', -1);
      --com
      SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);
      --mysql.com
      SELECT SUBSTRING_INDEX('www.mysql.com', '.', -3);
      --www.mysql.com
      
      --#delim does not exist in str
      SELECT SUBSTRING_INDEX('www.mysql.com', 'Q', 1);
      --www.mysql.com
      
      --#delim is 2 chars
      SELECT SUBSTRING_INDEX('www||mysql||com', '||', 2);
      --www||mysql
      
      --#delim is empty string
      SELECT SUBSTRING_INDEX('www.mysql.com', '', 2);
      --''
      
      --#str is empty string
      SELECT SUBSTRING_INDEX('', '.', 2);
      --''
      
      --#null params
      SELECT SUBSTRING_INDEX(null, '.', 1);
      --null
      SELECT SUBSTRING_INDEX('www.mysql.com', null, 1);
      --null
      SELECT SUBSTRING_INDEX('www.mysql.com', '.', null);
      --null
      

      Attachments

        1. HIVE-686.patch
          10 kB
          Larry Ogrodnek
        2. HIVE-686.patch
          11 kB
          Larry Ogrodnek
        3. HIVE-686.1.patch
          18 kB
          Alexander Pivovarov
        4. HIVE-686.1.patch
          18 kB
          Alexander Pivovarov

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            apivovarov Alexander Pivovarov Assign to me
            namit Namit Jain
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment