[Solved-2 Solutions] Is there any Conditional IF like operator in Apache PIG ?
What is Conditional IF
- Conditional Sentences are also known as Conditional Clauses or If Clauses. They are used to express that the action in the main clause (without if) can only take place if a certain condition (in the clause with if) is fulfilled.
If you want to execute some set of statements in pig script if one of the condition is satisfied. You have set one variable and checking for some value of that variable.
Can you do this in PIG Script ?
- Yes, Pig has if-then-else construction,.
- Pig's if-then-else is an arithmetic operator invoked with the shorthand "condition ? true_value : false value” as part of an expression such as:
- Pig is data flow language not control flow. Only construct which comes close is PIG split but it is very limited.
- We can use oozie and its decision construct with two pig scripts.
- Oozie is a workflow scheduler system to manage Apache Hadoop jobs.
- Oozie Workflow jobs are Directed Acyclical Graphs (DAGs) of actions.
- To execute control flow around entire Pig statements we need something like oozie