Support Questions

Find answers, ask questions, and share your expertise

Is it possible to delete a relation in pig?

avatar
Expert Contributor

I created a relation like

A = Load from 'soemtable' using org.apache.hive.hcatalog.pig.HCatLoader();

A_Filtered = FILTER A BY Col1 == 1 ;

Now I changed the underlying table structure in Hive and so get the proper data type reflected in relation "A" I ran the same command again to create A. I changed the column type of Col1 from Int to String.

A = Load from 'soemtable' using org.apache.hive.hcatalog.pig.HCatLoader();

Now when I created this relation, I understand that A_Filtered becomes invalid. So I got below error when I tried to create A again. But I am unable to even create the same A_Filtered relation again or any relation at all with new definition, I am getting this error at all time that the relation A_Filtered has different data types in equal operator.

How to fix this? Can I delete the relation so that it does not occur? This will be cleared once I exit grunt shell and login again. But I wanted to know how to fix this without exiting the shell, is it possible?

2016-05-13 12:32:02,354 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - fs.default.name is deprecated. Instead, use fs.defaultFS
2016-05-13 12:32:02,403 [main] WARN  org.apache.hadoop.hive.conf.HiveConf - HiveConf of name hive.metastore.pre-event.listeners does not exist
2016-05-13 12:32:02,403 [main] WARN  org.apache.hadoop.hive.conf.HiveConf - HiveConf of name hive.semantic.analyzer.factory.impl does not exist
2016-05-13 12:32:02,425 [main] INFO  hive.metastore - Connected to metastore.
2016-05-13 12:32:02,519 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - fs.default.name is deprecated. Instead, use fs.defaultFS
2016-05-13 12:32:02,553 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - fs.default.name is deprecated. Instead, use fs.defaultFS
2016-05-13 12:32:02,603 [main] WARN  org.apache.hadoop.hive.conf.HiveConf - HiveConf of name hive.metastore.pre-event.listeners does not exist
2016-05-13 12:32:02,604 [main] WARN  org.apache.hadoop.hive.conf.HiveConf - HiveConf of name hive.semantic.analyzer.factory.impl does not exist
2016-05-13 12:32:02,666 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1039:
<line 2, column 56> In alias A_Filtered, incompatible types in Equal Operator left hand side:chararray right hand side:int
1 ACCEPTED SOLUTION

avatar
Guru

Once you changed it, try using

A_Filtered = FILTER A BY Col1 == '1';

From the error, it shows that right hand side is a number and not a string. Use '' to search for a string and this will work.

View solution in original post

1 REPLY 1

avatar
Guru

Once you changed it, try using

A_Filtered = FILTER A BY Col1 == '1';

From the error, it shows that right hand side is a number and not a string. Use '' to search for a string and this will work.