Return-Path: X-Original-To: apmail-hive-issues-archive@minotaur.apache.org Delivered-To: apmail-hive-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 231D018F5E for ; Tue, 9 Jun 2015 08:30:02 +0000 (UTC) Received: (qmail 69337 invoked by uid 500); 9 Jun 2015 08:30:02 -0000 Delivered-To: apmail-hive-issues-archive@hive.apache.org Received: (qmail 69261 invoked by uid 500); 9 Jun 2015 08:30:02 -0000 Mailing-List: contact issues-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list issues@hive.apache.org Received: (qmail 69102 invoked by uid 99); 9 Jun 2015 08:30:02 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jun 2015 08:30:02 +0000 Date: Tue, 9 Jun 2015 08:30:01 +0000 (UTC) From: "Damien Carol (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HIVE-686) add UDF substring_index MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HIVE-686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Damien Carol updated HIVE-686: ------------------------------ 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: {code:sql} 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 {code} {code:sql} --#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); --'' {code} {code:sql} --#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 {code} was: 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: {code} 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 {code} {code} --#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); --'' {code} {code} --#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 {code} > add UDF substring_index > ----------------------- > > Key: HIVE-686 > URL: https://issues.apache.org/jira/browse/HIVE-686 > Project: Hive > Issue Type: New Feature > Components: UDF > Reporter: Namit Jain > Assignee: Alexander Pivovarov > Fix For: 1.3.0, 2.0.0 > > Attachments: HIVE-686.1.patch, HIVE-686.1.patch, HIVE-686.patch, HIVE-686.patch > > > 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: > {code:sql} > 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 > {code} > {code:sql} > --#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); > --'' > {code} > {code:sql} > --#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 > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)