0 / 0
DataStage Change Apply stage

Change Apply stage

The Change Apply stage is a processing stage. It takes the change data set that contains the changes in the before and after data sets from the Change Capture stage and applies the encoded change operations to a before data set to compute an after data set.

The before input to Change Apply must have the same columns as the before input that was input to Change Capture, and an automatic conversion must exist between the types of corresponding columns. In addition, results are only guaranteed if the contents of the before input to Change Apply are identical (in value and record order in each partition) to the before input that was fed to Change Capture, and if the keys are unique.

Note: The change input to Change Apply must have been output from Change Capture without modification. Because preserve-partitioning is set on the change output of Change Capture, you will be warned at run time if the Change Apply stage does not have the same number of partitions as the Change Capture stage. Additionally, both inputs of Change Apply are designated as partitioned by using the Same partitioning method.

The Change Apply stage reads a record from the change data set and from the before data set, compares their key column values, and acts accordingly:

  • If the before keys come before the change keys in the specified sort order, the before record is copied to the output. The change record is retained for the next comparison.
  • If the before keys are equal to the change keys, the behavior depends on the code in the change_code column of the change record:
    • Insert: The change record is copied to the output; the stage retains the same before record for the next comparison. If key columns are not unique, and there is more than one consecutive insert with the same key, then Change Apply applies all the consecutive inserts before existing records. This record order might be different from the after data set given to Change Capture.
    • Delete: The value columns of the before and change records are compared. If the value columns are the same or if the Check Value Columns on Delete is specified as False, the change and before records are both discarded; no record is transferred to the output. If the value columns are not the same, the before record is copied to the output and the stage retains the same change record for the next comparison. If key columns are not unique, the value columns ensure that the correct record is deleted. If more than one record with the same keys has matching value columns, the first-encountered record is deleted. This deletion might cause different record ordering than in the after data set given to the Change Capture stage. A warning is issued and both change record and before record are discarded, that is, no output record results.
    • Edit: The change record is copied to the output; the before record is discarded. If key columns are not unique, then the first before record that is encountered with matching keys will be edited. This might be a different record from the one that was edited in the after data set given to the Change Capture stage. A warning is issued and the change record is copied to the output; but the stage retains the same before record for the next comparison.
    • Copy: The change record is discarded. The before record is copied to the output.
  • If the before keys come after the change keys, behavior also depends on the change_code column:
    • Insert. The change record is copied to the output and the stage retains the same before record for the next comparison. (The same as when the keys are equal.)
    • Delete. A warning is issued and the change record is discarded while the before record is retained for the next comparison.
    • Edit or Copy. A warning is issued and the change record is copied to the output while the before record is retained for the next comparison.
      Note: If the before input of Change Apply is identical to the before input of Change Capture and either the keys are unique or copy records are used, then the output of Change Apply is identical to the after input of Change Capture. However, if the before input of Change Apply is not the same (different record contents or ordering), or the keys are not unique and copy records are not used, this is not detected and the rules that are described above are applied anyway, producing a result that might or might not be useful.

The properties pane has three tabs:

Stage tab
This tab is always present and is used to specify general information about the stage.
Input tab
This tab is where you specify the details about the single input set from which you are selecting records.
Output tab
This tab is where you specify details about the processed data that is output from the stage.
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more