[ 
https://issues.apache.org/jira/browse/PIG-1885?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Deepak Kumar V updated PIG-1885:
--------------------------------

    Fix Version/s: 0.9.0
     Release Note: Fix has been tested with 0.9.0 source.
           Status: Patch Available  (was: Open)

Following scenarios are tested

grunt> a = load 'substrinput.txt' as (data:chararray);   
grunt> dump a;                                        
(abcde)
()
(fghi)

1) beginindex == endindex
grunt> a = load 'substrinput.txt' as (data:chararray);
grunt> b = foreach a generate SUBSTRING(data,0,0);    
grunt> dump b;
Output(s):
Successfully stored records in: "file:/tmp/temp1752997904/tmp55103794"
()
()
()

2) beginindex < endindex  - normal scenario 
grunt> b = foreach a generate SUBSTRING(data,0,3);
grunt> dump b;                                    
Output(s):
Successfully stored records in: "file:/tmp/temp1752997904/tmp-314465179"
(abc)
()
(fgh)

3) beginindex is -ve
grunt> b = foreach a generate SUBSTRING(data,-1,3);
grunt> dump b;                                     
Output(s):
Successfully stored records in: "file:/tmp/temp1752997904/tmp286819157"
()
()
()

4) beginindex > String length.
grunt> b = foreach a generate SUBSTRING(data,8,3); 
grunt> dump b;                                    
Output(s):
Successfully stored records in: "file:/tmp/temp1752997904/tmp-900213360"
()
()
()

5) beginindex > endindex
grunt> b = foreach a generate SUBSTRING(data,2,0);
grunt> dump b;                                    
Output(s):
Successfully stored records in: "file:/tmp/temp1752997904/tmp-834743686"
()
()
()

5) beginindex is correct endindex > string length.
grunt> b = foreach a generate SUBSTRING(data,0,9);
grunt> dump b;                                    
Output(s):
Successfully stored records in: "file:/tmp/temp1752997904/tmp243973324"
(abcde)
()
(fghi)

6) beginindex is correct and endindex is -ve
grunt> b = foreach a generate SUBSTRING(data,0,-2);   
grunt> dump b;
Output(s):
Successfully stored records in: "file:/tmp/temp970048830/tmp1979923245"
()
()
()
grunt> quit


> SUBSTRING fails when input length less than start
> -------------------------------------------------
>
>                 Key: PIG-1885
>                 URL: https://issues.apache.org/jira/browse/PIG-1885
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Alan Gates
>            Assignee: Deepak Kumar V
>            Priority: Minor
>             Fix For: 0.9.0
>
>         Attachments: PIG-1885.txt
>
>
> SUBSTRING throws an error if it gets a string which has a length less than 
> its start value.  For example, SUBSTRING(x, 100, 120) will fail with any 
> chararray of length less than 100.  It should return null instead.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to