pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Pig Wiki] Update of "PigLatin" by OlgaN
Date Tue, 16 Oct 2007 19:27:02 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Pig Wiki" for change notification.

The following page has been changed by OlgaN:
http://wiki.apache.org/pig/PigLatin

------------------------------------------------------------------------------
  == Data Items ==
  Data can be referred to in various powerful and convenient ways in Pig. Any data referred
to is called a Data Item. We will illustrate all these ways by using the following example
tuple.
  
- `t = < 1, {<2,3>,<4,6>,<5,7>}, ['yahoo':'search']>`
+ `t = < 1, {<2,3>,<4,6>,<5,7>}, ['apache':'hadoop']>`
  
  Thus, ''t'' has 3 fields. Let these fields have names f1, f2, f3. Field f1 is an atom with
value 1. Field f2 is a bag having 3 tuples. Field f3 is a data map having 1 key.
  
  The following table lists the various methods of referring to data.
  
- || Method of Referring to Data || Example || Value for example tuple ''t'' || Notes ||
+ || '''Method of Referring to Data''' || '''Example''' || '''Value for example tuple ''t''
''' || '''Notes''' ||
- || '''Constant''' || ''' '1.0' ''', or ''' 'yahoo.com' ''', or ''' 'blah' ''' || Value constant
irrespective of ''t'' || ||
+ || Constant || '1.0', or 'apache.org', or 'blah'|| Value constant irrespective of ''t''
|| ||
+ || Field referred to by position || $0 || Data Atom '1' || In Pig, positions start at 0
and not 1 ||
+ || Field referred to by name || f2 || Bag {<2,3>,<4,6>,<5,7>} || ||
+ || Projection of another data item || f2.$0 || Bag {<2>,<4>,<5>} - the
bag f2 projected to the first field || ||
+ || Map Lookup against another data item || f3#'apache' || Data Atom 'pig' || User's responsibility
to ensure that a lookup is written only against a  data map, otherwise a runtime error is
thrown. If the key being looked up does not exist, a Data Atom with an empty string is returned
||
+ || Function applied to another data item || SUM(f2.$0) || 2+4+5 = 11 || SUM is a builtin
Pig function. See PigFunctions for how to write your own functions ||
+ || Infix Expression of other data items || COUNT(f2) + f1 / '2.0' || 3 + 1 / 2.0 = 3.5 ||
||
  

Mime
View raw message