Load Data:: Pig Copy Code

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

While I can provide you with an example Pig Latin script for filtering student IDs above 500

and less
than 1000, creating a visual diagram of the execution isn't feasible here. However, I can guide you
through the Pig Latin script and explain the steps.

Assuming you have a dataset named students with fields like StuID, StuName, and other attributes,
here's an example Pig Latin script:

pig Copy code

-- Load the data students = LOAD 'path/to/your/dataset' USING PigStorage(',') AS


(StuID: int, StuName: chararray, ...); -- Filter the data based on StuID criteria
filtered_students = FILTER students BY StuID > 500 AND StuID < 1000; -- Store the
result STORE filtered_students INTO 'output_path';

Let's break down the script:

Load Data:
LOAD 'path/to/your/dataset' USING PigStorage(',') AS (StuID: int, StuName: chararray,
...);
Loads the data from a specified path, assuming a CSV format with fields separated by commas.
Adjust the schema based on your actual dataset.
Filter Data:
filtered_students = FILTER students BY StuID > 500 AND StuID < 1000;
Filters the loaded data to include only those records where StuID is greater than 500 and less
than 1000.
Store Result:
STORE filtered_students INTO 'output_path';
Stores the filtered result into the specified output path.

To execute this script, you can use the Pig interpreter or run it in batch mode. For example:

bash Copy code

pig -x local your_script.pig

Replace your_script.pig with the actual filename containing your Pig Latin script.

Remember to replace 'path/to/your/dataset' with the actual path to your dataset and adjust the
field names based on your dataset structure.

While I can't provide a visual diagram here, you can visualize the execution flow in your mind. Pig
Latin scripts are designed to be expressive and resemble a series of data transformations. Each
operation like LOAD, FILTER, or STORE represents a step in the data processing pipeline.

You might also like