Interview Questions   Tutorials   Discussions   Programs   Videos   

Pig - PIG script usage with example

    Next Topic



288
views
asked marvit November 23, 2014 06:48 AM  

PIG script usage with examples:


           

1 Answers



 
answered By Experts-976   0  

PIG script usage with examples:

1. DDL Operations

  1. load : refer an input file

    grunt> A = load 'input/sample.txt' using PigStorage() as
    (make:chararray,country:chararray, year:int, sale: int);
    grunt> DUMP A;
    
  2. Store : Stores or saves results to the file system.

    grunt> B = distinct A; grunt>
    store B into ‘/input/out.txt’ using
    PigStorage();
    

2. DML Operations

  1. foreach : Generates data transformations based on columns of data Syntax : alias = FOREACH { block | nested_block }; where, alias = The name of relation (outer bag).

    grunt> X = FOREACH A GENERATE make,$2;
    
    
    grunt> DUMP X;
    
flag   
   add comment

Your answer

Join with account you already have

FF

Preview

 Write A Tutorials
Online-Classroom Classes
www.writeabc.com


  1 person following this question

  1 person following this tag

  Question tags

pig × 1

Asked 3 years and 18 days ago ago
Number of Views -288
Number of Answers -1
Last updated
3 years and 18 days ago ago

  Similar questions


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert