Notes on Pig code format

Source: Internet
Author: User

Notes on Pig code format

Notes on Pig code format

1, % default file test.txt do not use quotation marks, neither ''nor. 'File' is not recognized

2, equal sign = pay attention to both sides. It must be empty before and after.

Therefore, it is best to keep the format. There are spaces on both sides of the equal sign. For example, A = load '$ file' as (date, web, name, food );

Because the compiler determines the table name and uses space to split the table, no space is required, for example, C = cogroup A by $0, B by $1; execution error because the name of table C cannot be parsed, it is resolved to "C =", and C = cogroup can be used. In Pig parsing, tables must be separated by spaces.

3. the keywords are case-insensitive and can be used. However, we recommend that you keep them in uppercase.

The variable is case sensitive. Try to be concise and use more than _, but not too long.

4. You must run commands such as dump or store to read the table content. Otherwise, the code is compiled only.

% Default file test.txt

A = load '$ file' as (date, web, name, food );

B = load '$ file' as (date, web, name, food );

C = cogroup A by $0, B by $1;

Describe C;

Using strate C;

Dump C;

Note: After the load command is written, it will not be executed immediately (for example, executing describe A only generates A data structure and will not read data from the file). Instead, it will wait for the mongostrate, and dump commands, to read data to A and B. Therefore, an error is reported after the dump and mongostrate commands are executed.

5. jion: Perform the jion link to put the size smaller on the right. Because one entry on the left is taken and compared on the right.

6. The underlying map and reduce occur in data operations. parallel can only define map.

Installation and testing of Pig

Pig installation and configuration tutorial

Pig installation and deployment and testing in MapReduce Mode

Install Pig and test in local mode.

Installation configuration and basic use of Pig

Hadoop Pig advanced syntax

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.