Apache Pig Tutorial on Apache Pig Describe Operator

the describe operator is used to view the schema of a relation.

syntax

the syntax of the describe operator is as follows −

grunt> describe relation_name

example

assume we have a file student_data.txt in hdfs with the following content.

001,rajiv,reddy,9848022337,hyderabad
002,siddarth,battacharya,9848022338,kolkata
003,rajesh,khanna,9848022339,delhi
004,preethi,agarwal,9848022330,pune
005,trupthi,mohanthy,9848022336,bhuwaneshwar
006,archana,mishra,9848022335,chennai.

and we have read it into a relation student using the load operator as shown below.

grunt> student = load 'hdfs://localhost:9000/pig_data/student_data.txt' using pigstorage(',')
   as ( id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray );

now, let us describe the relation named student and verify the schema as shown below.

grunt> describe student;

output

once you execute the above pig latin statement, it will produce the following output.

grunt> student: { id: int,firstname: chararray,lastname: chararray,phone: chararray,city: chararray }