Skip to main content

Expressions and CASE statements

Custom Expression Builder provides built-in Pig functions and UDFs (User-Defined Functions) that transform and join data with powerful and flexible operations. Note that when using a CASE statement, only expressions with non-conditional variables will validate. Due to a limitation in Pig, CASE statements built with conditional operators such as NULL, IS NULL, greater than or equal to (>=) etc., the transformation must be staged in two distinct expressions: The first establishes a condition with a boolean determination (true/false), the second expression determines the run-time field value depending on the whether the condition is true.

The following example demonstrates this sequence. The first transform determines if the field MIN_SALARY is greater than or equal to 4000. The second transform changes the output so that MIN_SALARY values greater than or equal to 4000 will display runtime output Tier A and values less than 4000 will display Tier B.

Note that this two-step operation requires the use of two sequential controls in the dataflow.

First custom expression:

MIN_SALARY >= 4000
 

Second custom expression:

(CASE MIN_SALARY WHEN true THEN 'Tier A' ELSE 'Tier B' END)'
 
Source entity : Sample data, pre-transform

Pre-transform salary field values are integers

Target entity: Sample data, post-transform

Post-transform salary field values display as Tier A or Tier B

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!