[ https://issues.apache.org/jira/browse/PIG-1885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13003968#comment-13003968 ]
Deepak Kumar V commented on PIG-1885: ------------------------------------- There are few more cases that needs to be handled. a) beginindex is -ve Current Behavior: SUBSTRING throws ExceException because of java.lang.StringIndexOutOfBoundsException b) beginindex > endindex Current Behavior: SUBSTRING throws ExceException because of java.lang.StringIndexOutOfBoundsException c) beginindex > string length -- bug reported Current Behavior: SUBSTRING throws ExceException because of java.lang.StringIndexOutOfBoundsException d) endindex is -ve Current Behavior: SUBSTRING throws ExceException because of java.lang.StringIndexOutOfBoundsException SUBSTRING.java can be modified to return null in all above cases as follows if(beginindex < 0 || beginindex > source.length() || beginindex > endindex) { return null; }else { return source.substring(beginindex, Math.min(source.length(), endindex)); } In case no one is working on this defect, reassign to me. > 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 > Priority: Minor > > 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