Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load data using Pig Latin.
Hadoop
data = LOAD 'input.txt' USING [1] AS (name:chararray, age:int);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using JsonLoader for plain text files.
Using TextLoader which is not a Pig built-in loader.
Using CsvLoader which is not a standard Pig loader.
✗ Incorrect
PigStorage is the default loader for text files with delimiter, commonly comma.
2fill in blank
mediumComplete the code to filter data where age is greater than 30.
Hadoop
filtered = FILTER data BY age [1] 30;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which filters ages less than 30.
Using '==' which filters ages exactly 30.
Using '<=' which includes ages less or equal to 30.
✗ Incorrect
The '>' operator filters rows where age is greater than 30.
3fill in blank
hardFix the error in the code to group data by name.
Hadoop
grouped = GROUP data BY [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by 'age' which groups by age, not name.
Grouping by 'salary' which may not exist in data.
Grouping by 'date' which is unrelated here.
✗ Incorrect
Grouping by 'name' groups all records with the same name together.
4fill in blank
hardFill both blanks to create a new relation with names and count of records.
Hadoop
result = FOREACH grouped GENERATE [1], COUNT([2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'grouped' instead of 'group' for the group key.
Counting 'grouped' which is not a bag of records.
Using 'filtered' which is unrelated here.
✗ Incorrect
'group' is the group key, and 'data' is the bag of records to count.
5fill in blank
hardFill all three blanks to order the result by group descending and store it.
Hadoop
ordered = ORDER result BY [1] [2]; STORE ordered INTO '[3]';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by count instead of group.
Using ASC instead of DESC for descending order.
Not specifying a valid output folder.
✗ Incorrect
Order by 'group' field descending and store in 'output_folder'.