Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to update records in PIG  RSS feed

 
perhir hi
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
chris webster
Bartender
Posts: 2407
36
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
abhi k tripathi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
ruchika sharma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!