tajo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "KyoungBok Lee (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (TAJO-343) Implement locate function
Date Sat, 07 Dec 2013 13:13:35 GMT

    [ https://issues.apache.org/jira/browse/TAJO-343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13842132#comment-13842132
] 

KyoungBok Lee edited comment on TAJO-343 at 12/7/13 1:13 PM:
-------------------------------------------------------------

Hyunsik Choi, I have a question.
# If *pos* is a negative integer, what should be returned? null or 0?
# If *substr* is the empty string(""),  how process this case?

※ locate() seems to be mysql's function. right? Then,
function signature is bellow.
{code}
int4 locate(substr text, string text, [, pos])

SELECT locate('bar', 'foobarbar', 5);
-> 7
{code}
And, result is bellow case by case.
{code}
mysql> select locate('bar', 'foobarbar', 5) as col1;
+------+
| col1 |
+------+
|    7 |
+------+
1 row in set (0.00 sec)

mysql> select locate('bar', 'foobarbar') as col1;
+------+
| col1 |
+------+
|    4 |
+------+
1 row in set (0.00 sec)

mysql> select locate('', 'foobarbar') as col1;
+------+
| col1 |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

mysql> select locate('bar', 'foobarbar', -1) as col1;
+------+
| col1 |
+------+
|    0 |
+------+
1 row in set (0.00 sec)
{code}

Anyway, I will implement as requested now.


was (Author: deepblue.kblee):
Hyunsik Choi, I have a question.
If *pos* is a negative integer, what should be returned? null or 0?

> Implement locate function
> -------------------------
>
>                 Key: TAJO-343
>                 URL: https://issues.apache.org/jira/browse/TAJO-343
>             Project: Tajo
>          Issue Type: New Feature
>          Components: operator/function/udf
>            Reporter: Hyunsik Choi
>            Assignee: KyoungBok Lee
>            Priority: Minor
>             Fix For: 0.8-incubating
>
>
> h3. Function definition
> {code}
> int4 locate(string text, substr text, [, pos])
> {code}
> h3. Description
> Returns the position of the first occurance of substr in str after position pos
>  * The result is one-based index.
>  * If string or substr is null, the result should be null.
>  * *pos* is one-based index.
>  * *pos* cannot be a negative integer.
>  * If 0 is given to *pos*, the function considers that pos is 1.
>  * If there is no pos, the function considers that pos is 1.
>  * If there is no matched substring, the result should be 0.
> h3. Example
> {code}
> SELECT locate('foobarbar', 'bar',5);
> -> 7
> {code}



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message