How to write 'foreach' statement for bag datatype in pig scripts?
Answer / Raju Shah
'FOREACH' statement can be used with the bag data type to process each element individually.nSyntax: FOREACH bag_name GENERATED_FOR ALL x GENERATED BY bag_name.x;nInside the 'GENERATED BY' clause, replace 'bag_name.x' with the name of the field inside the bag.
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain tokenize?
What are different modes of execution in Apache Pig?
What are the Data types in Pig?
What is Pig Storage?
Are pig scripts support distributed file systems?
What do you understand by an inner bag and outer bag in Pig?
What co-group does in Pig?
What are the different math functions available in Pig?
What is the use of foreach operation in Pig scripts?
Why should we use ‘distinct’ keyword in Pig scripts?
Define the Use of Pig?
What is Flatten and what it do in PIG?
Apache Hadoop (394)
MapReduce (354)
Apache Hive (345)
Apache Pig (225)
Apache Spark (991)
Apache HBase (164)
Apache Flume (95)
Apache Impala (72)
Apache Cassandra (392)
Apache Mahout (35)
Apache Sqoop (82)
Apache ZooKeeper (65)
Apache Ambari (93)
Apache HCatalog (34)
Apache HDFS Hadoop Distributed File System (214)
Apache Kafka (189)
Apache Avro (26)
Apache Presto (15)
Apache Tajo (26)
Hadoop General (407)