Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> reference tuple field by name in UDF

Copy link to this message
reference tuple field by name in UDF

In my own UDF, is reference a field by index the only way to access a field?

The fields are all named and typed before passing into UDF but looks like I
can only do something like this:

       String v1 = (String)input.get(0);
       String v2 = (String)input.get(1);
       String v3 = (String)input.get(2);

instead I'd like to do something like this:

      String v1 = (String)input.get("f1");
      String v2 = (String)input.get("f2");
      String v3 = (String)input.get("f3");

since I have lots of field and I don't want to tie myself up the
positioning of the fields.

Any alternative? Thanks.