[
https://issues.apache.org/jira/browse/TAJO-341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
hyoungjunkim updated TAJO-341:
------------------------------
Attachment: TAJO-341.patch
I implemented substr function and add testcase testSubstr() in
TestStringOperatorsAndFunctions class.
Please review this. Thank you.
There is some issues.
- TestStringOperatorsAndFunctions.testSubstr() has serval testcase which
contains multi-bytes charset like korean.
- If there is a minus value in function argument, next error occurred.
{code}
select substr('abcdef', -1, 100) as col1
org.apache.tajo.engine.parser.SQLSyntaxError: ERROR: syntax error at or near
'substr'
LINE 1:7 select substr('abcdef', -1, 100) as col1
^^^^^^
at org.apache.tajo.engine.parser.SQLAnalyzer.parse(SQLAnalyzer.java:64)
at
org.apache.tajo.engine.eval.ExprTestBase.getRawTargets(ExprTestBase.java:78)
at
org.apache.tajo.engine.eval.ExprTestBase.testEval(ExprTestBase.java:123)
at
org.apache.tajo.engine.eval.ExprTestBase.testSimpleEval(ExprTestBase.java:91)
at
org.apache.tajo.engine.function.TestStringOperatorsAndFunctions.testSubstr(TestStringOperatorsAndFunctions.java:213)
{code}
> Implement substr function
> -------------------------
>
> Key: TAJO-341
> URL: https://issues.apache.org/jira/browse/TAJO-341
> Project: Tajo
> Issue Type: New Feature
> Components: operator/function/udf
> Reporter: Hyunsik Choi
> Assignee: hyoungjunkim
> Priority: Minor
> Fix For: 0.8-incubating
>
> Attachments: TAJO-341.patch
>
>
> h3. Function Definition
> {code}
> text substr(string text, from int4 [, count int4])
> {code}
> h3. Description
> * It extracts substring (same as substring(string from from for count)).
> * If string is null, the result also should be null.
> * Note that *from* is one based index.
> * *from* can be negative integer.
> * *count* can be omitted. If then, all string after *from* will be returned.
> * *count* cannot be negative integer.
> * If *count* is 0, the result should be '' instead of null.
> h3. Example and Sementic
> {code}
> hyunsik=> select substr('abcdef', 3, 2);
> substr
> --------
> cd
> (1 row)
> hyunsik=> select substr('abcdef',3) ;
> substr
> --------
> cdef
> (1 row)
> hyunsik=> select substr('abcdef',1,1) ;
> substr
> --------
> a
> (1 row)
> hyunsik=> select substr('abcdef',0,1) ;
> substr
> --------
>
> (1 row)
> hyunsik=> select substr('abcdef',0,2) ;
> substr
> --------
> a
> (1 row)
> {code}
--
This message was sent by Atlassian JIRA
(v6.1#6144)