Database Reference
In-Depth Information
Table 16-6. Pig Latin types
Category Type
Description
Literal example
Boolean
boolean
True/false value
true
Numeric
32-bit signed integer
int
1
64-bit signed integer
long
1L
32-bit floating-point number
float
1.0F
64-bit floating-point number
double
1.0
biginteger
Arbitrary-precision integer
'10000000000'
bigdecimal
Arbitrary-precision signed decimal num-
ber
'0.110001000000000000000001'
Text
chararray
Character array in UTF-16 format
'a'
Binary
bytearray
Byte array
Not supported
Temporal
datetime
Date and time with time zone
Not supported, use
ToDate
built-in
function
Complex
Sequence of fields of any type
tuple
(1,'pomegranate')
Unordered collection of tuples, possibly
with duplicates
bag
{(1,'pomegranate'),(2)}
Set of key-value pairs; keys must be
character arrays, but values may be any
type
map
['a'#'pomegranate']
The complex types are usually loaded from files or constructed using relational operators.
Be aware, however, that the literal form in
Table 16-6
is used when a constant value is
created from within a Pig Latin program. The raw form in a file is usually different when
using the standard
PigStorage
loader. For example, the representation in a file of the
marks), and with a suitable schema, this would be loaded as a relation with a single field
and row, whose value was the bag.
Pig provides the built-in functions
TOTUPLE
,
TOBAG
, and
TOMAP
, which are used for
turning expressions into tuples, bags, and maps.
Although relations and bags are conceptually the same (unordered collections of tuples),
in practice Pig treats them slightly differently. A relation is a top-level construct, whereas
a bag has to be contained in a relation. Normally you don't have to worry about this, but