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

Jonathan Holloway commented on PIG-1896:
----------------------------------------

I did attach this as a patch as well after the initial issue was added - I 
didn't have permission to remove the old comment - see pigcastutils.patch.  

Makes sense from a function name point of view - I can add unit tests as well.

Utf8StorageConverter has:

private Object bytesToObject(byte[] b, ResourceFieldSchema fs) throws 
IOException

which, I agree, is very similar - it also handles datatypes - I just wanted 
something to return the raw object for the basic types and default to String 
for the others.  The default case with bytesToObject throws an exception for 
other types - I don't know whether you could add a public wrapper method around 
this to do what I have in the patch above.  Up to you though, if you think the 
change to CastUtils is relevant then let me know and I'll add the unit tests... 

> CastUtils - Converting Pig DataTypes to Java Data Types
> -------------------------------------------------------
>
>                 Key: PIG-1896
>                 URL: https://issues.apache.org/jira/browse/PIG-1896
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0
>            Reporter: Jonathan Holloway
>            Priority: Minor
>         Attachments: PIG-1896.patch, pigcastutils.patch
>
>
> I ran into an issue with parsing log lines whereby I had to generate a schema 
> in a user defined function.  Part of that involved converting various values 
> into their associated data types, but I couldn't see a way to do it via Pig.  
> Enclosed is a patch to convert org.apache.pig.data.DataType into an 
> associated Java datatype falling back to a String by default - should go into 
> CastUtils.  Any comments/criticism, please let me know.

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

Reply via email to