Pig: Using Hcat Example

 

HCatLoader

//use default database
A = LOAD 'tablename' USING org.apache.hcatalog.pig.HCatLoader();

  

 

//specify database 'exampledb' and you could create the database and table using
//Hsql statements in Pig script after 0.10.
A = LOAD 'exampledb.tablename' USING org.apache.hcatalog.pig.HCatLoader();

because hive metastore is the same with Hcatalog, so the obove commands could be written as follows:

A = LOAD 'exampledb.tablename' USING org.apache.hive.hcatalog.pig.HCatLoader();

 

 

HCatStorer

//use default database
STORE processed_data INTO 'tablename' USING org.apache.hcatalog.pig.HCatStorer();

//or using hive metastore class
STORE processed_data INTO 'tablename' USING org.apache.hive.hcatalog.pig.HCatStorer();

 

//To add one new partition to a partitioned table, specify the partition value 
//in the store function.
store z into 'web_data' using org.apache.hcatalog.pig.HCatStorer('datestamp=20110924');

 

 

When using pig with hcatalog, you should care about the type system.

 
Pig: Using Hcat Example
 

 

 

 

 

References

https://cwiki.apache.org/confluence/display/Hive/HCatalog+LoadStore

你可能感兴趣的:(example)