Pig datatypes could be categorized into following two categories:
- Scalar/Simple
- Complex
Scalar Types
Data Type | Description | Example |
int | 4-byte signed integer. Mapped to java.lang.Integer | 10 |
long | 8-byte signed integer. Mapped to java.lang.Long | 10L |
float | 4-byte floating point number. Mapped to java.lang.Float | 10.5F or 1050.0F |
double | 8-byte double number. Mapped to java.lang.Double | 10.5 or 1050.0 |
chararray | Array of character. Mapped to java.lang.String | hello world |
bytearray | Array of bytes. Wraps a java byte[] array | |
boolean | Boolean values | true/false |
datetime | Datetime values |
Complex Types
Data Type | Description | Example |
map | Set of key-value pairs | [‘name’#’john’, ‘age’#30,’id’#3783] |
tuple | Ordered collection of elements | (john, 30, 3783) |
bag | Unordered collection of tuples | {(john, 30, 3783),(kate, 29, 4121)} |
Map:
- A map in Pig is a chararray to data element mapping, where that element can be any Pig type, including a complex type.
- The chararray is called a key and is used as an index to find the element, referred to as the value.
- As pig is not aware of the return type of the value, it will assume it as of type bytearray. If you know the type then you could cast the value to that particular pig type or pig smartly convert it to matched pig type at runtime by checking for the value usage in the script.
Map type is formed by enclosing the data in square parenthesis and putting a hash symbol between key and value as: [‘name’#’john’, ‘age’#30,’id’#3783]
Tuple:
- A tuple is a fixed-length, ordered collection of Pig data elements.
- Tuples are divided into fields, with each field containing one data element.
- These elements can be of any type—they do not all need to be the same type.
- A tuple is analogous to a row in SQL, with the fields being SQL columns.
- Because tuples are ordered, it is possible to refer to the fields by position. A tuple can, but is not required to, have a schema associated with it that describes each field’s type and provides a name for each field.
- Tuple type is enclosed with parentheses and the element values are separated with a comma.
For ex. (john, 30, 3783) is a tuple with three fields.
Bag:
- A bag is an unordered collection of tuples.
- It has no order, it is not possible to reference tuples in a bag by position.
- Bag types are created by enclosing various comma separated tuples in curly parenthesis.
For example, {(john, 30, 3783),(kate, 29, 4121)} constructs a bag with two tuples, each with three fields.
Related Posts
Share this:
ネット通販ショップ
ブランドコピー品の大SALE–ネット通販ショップ
当店はブランドコピーのスーパーコピー品通販専門店です。
商品は全てよい材料と優れた品質で作ります!
ヴィトンスーパーコピー、シャネルコピー、
スーパーコピーバッグ、ブランド財布 コピー、
時計スーパーコピーなど人気ブランド品が豊富に取り揃えています。
品質保証&届け保証します!
どうぞご安心にご利用ください。
ロレックス時計コピー https://www.watcher020.com/watch/menu-pid-45.html