Skip to main content
Version: Python

DeltaControl

DeltaControl is a Python class that defines ways to handle null values during a delta UpdateByOperation. delta calculates the difference between the current row and the previous row.

Syntax

DeltaControl(value: Enum = None) -> DeltaControl

Parameters

ParameterTypeDescription
valueEnum

Defines how special cases should behave. Enum options are:

  • DeltaControl.NULL_DOMINATES: A valid value following a null value returns null.
  • DeltaControl.VALUE_DOMINATES: A valid value following a null value returns the valid value.
  • DeltaControl.ZERO_DOMINATES: A valid value following a null value returns zero.

Returns

An instance of a DeltaControl class that can be used in an update_by delta operation.

Examples

The following example creates a table with three rows of int columns. Next, it creates three DeltaControl objects by calling its constructor. Finally, it uses update_by and invokes the delta UpdateByOperation to demonstrate how the three Enum values for DeltaControl affect the output.

from deephaven import new_table
from deephaven.updateby import delta, DeltaControl
from deephaven.column import int_col
from deephaven.constants import NULL_INT

null_dominates = DeltaControl(DeltaControl.NULL_DOMINATES)
value_dominates = DeltaControl(DeltaControl.VALUE_DOMINATES)
zero_dominates = DeltaControl(DeltaControl.ZERO_DOMINATES)

source = new_table(
[
int_col("X", [1, NULL_INT, 3, NULL_INT, 5, NULL_INT, NULL_INT, 8, 9]),
int_col("Y", [0, 5, 3, NULL_INT, NULL_INT, 3, 0, NULL_INT, 9]),
int_col("Z", [5, 6, 3, 4, 2, NULL_INT, 5, 0, 3]),
]
)

result = source.update_by(
[
delta(["X_null = X", "Y_null = Y", "Z_null = Z"], null_dominates),
delta(["X_value = X", "Y_value = Y", "Z_value = Z"], value_dominates),
delta(["X_zero = X", "Y_zero = Y", "Z_zero = Z"], zero_dominates),
]
)