Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

how to compare two different hive table fields using pig

how to compare two different hive table fields using pig

Expert Contributor

Hi,

I have two tables in hive, both table have a common field which i want to compare and based on that i want to put a value.

a = load 'telecom.employee' using org.apache.hive.hcatalog.pig.HCatLoader();
b = load 'telecom.dept' using org.apache.hive.hcatalog.pig.HCatLoader();
c = foreach a {dp = foreach b generate (a.dept == b.deptname ? b.deptid:0); generate a.id as empid, dp as deptid,a.dept as deptname;};

whil executing statemnt c it throws an error:

a = load 'telecom.employee' using org.apache.hive.hcatalog.pig.HCatLoader();

2019-03-26 13:47:19,133 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: Pig script failed to parse: <line 13, column 28> expression is not a project expression: (Name: ScalarExpression) Type: null Uid: null)

Is there another way to compare hive table fields ?


Thanks,

Heta

Don't have an account?
Coming from Hortonworks? Activate your account here