Book Image

Mastering Hadoop

By : Sandeep Karanth
Book Image

Mastering Hadoop

By: Sandeep Karanth

Overview of this book

Table of Contents (21 chapters)
Mastering Hadoop
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Complex data types in Pig


Pig has primitive data types such as int, long, float, double, chararray, and bytearray. In addition, Pig also supports complex data types. Inputs and outputs to Pig's relational operators are specified using these complex data types. In some cases, the behavior of the operators depends on the complex data type used. These complex data types are as follows:

  • Map: This data type should not be confused with the map function of MapReduce. The Map data type is an associative array data type that stores a chararray key and its associated value. There is no restriction on the data type of the value in a map. It can be a complex type too. If the type of the value cannot be determined, Pig defaults to the bytearray data type. The key and value association is syntactically done via the # symbol. The key values within a map have to be unique:

    [key#value, key1#value1…]

  • Tuple: A Tuple data type is a collection of data values. They are of fixed length and are ordered. They can...