[Logo]
Forums Register Login
How to update records in PIG
(1 like)
I want to update/delete some records in pig, I want to know how to achieve that in pig.

ID Name
1 A
2 B
3 C
4 D
5 E
I want to update value of ID = 3 and delete record with ID =5 so that my expected table will have records like :

ID NAME
1 A
2 B
3 Z
4 D
How to achieve the above result?
Assuming your data is in files on HDFS, my understanding is that you cannot really do arbitrary in-place updates like you would with SQL in a relational database. You would probably need to read the data and modify the relevant records before writing it all back to HDFS. If you're using Hive or HBase to store your data, then maybe there are other options available, but in-place updates are not really what Hadoop is intended for.
You can't update the Pig values.
The same issue was mention in Pig issue list- https://issues.apache.org/jira/browse/PIG-1693
Pig script language called Pig Latin, used for filtering of the data.
Although hortonworks comes with Project_Range Expression that can help resolve this issue.
Check the link here: http://hortonworks.com/blog/new-apache-pig-0-9-features-part-3-additional-features/

But you can change some specific values check this links:
http://stackoverflow.com/questions/18796778/filter-and-change-a-column-in-pig

To learn more about Pig check this Pig tutorials:
https://www.dezyre.com//hadoop-tutorial/pig-tutorial
Pig is not a database in which you can update/delete data. It basically reads data from HDFS/local file system and does operations on it. So you should not try updating/deleting that data.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 2110 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 18, 2017 11:35:22.