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: