You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Sunitha Muralidharan (JIRA)" <ji...@apache.org> on 2012/09/17 13:06:07 UTC

[jira] [Commented] (PIG-2880) Pig current releases lack a UDF charAt.This UDF returns the char value at the specified index.

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

Sunitha Muralidharan commented on PIG-2880:
-------------------------------------------

Can we define a new UDF as follows

package pigudf;

import java.io.IOException;

import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;

public class CharAt extends EvalFunc<String> {

	@Override
	public String exec(Tuple input) throws IOException {
		String str=(String) input.get(0);//string input
		int index=(Integer) input.get(1);//index 
		
		return str.charAt(index)+"";
	}

}


                
> Pig current releases lack a UDF charAt.This UDF returns the char value at the specified index.
> ----------------------------------------------------------------------------------------------
>
>                 Key: PIG-2880
>                 URL: https://issues.apache.org/jira/browse/PIG-2880
>             Project: Pig
>          Issue Type: New Feature
>          Components: piggybank
>    Affects Versions: 0.10.0
>            Reporter: Sabir Ayappalli
>
> Pig current releases lack a UDF charAt.This UDF returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira