Skip to contents

Creates an OperationControl that controls behavior on special values in some UpdateBy operations. This function is the only way to properly create an OperationControl object.

Usage

op_control(on_null = "skip", on_nan = "skip", big_value_context = "decimal128")

Arguments

on_null

Defines how a uby function handles null values it encounters. 'skip' is the default.

on_nan

Defines how a uby function handles NaN values it encounters. 'skip' is the default.

big_value_context

Defines how a uby function handles exceptionally large values it encounters. 'decimal128' is the default.

Value

OperationControl to be used in a uby function.

Details

An OperationControl defines the control parameters of some uby functions used in an update_by() call. The uby functions that can use an OperationControl to handle erroneous data are:

The arguments on_null and on_nan can take the following values:

  • 'poison': Allow bad data to poison the result, meaning that any calculation involving at least one NaN will yield NaN. This is only valid for use with NaN.

  • 'reset': Reset the state for the bucket to NULL when invalid data is encountered.

  • 'skip': Skip and do not process the invalid data without changing state.

  • 'throw': Throw an exception and abort processing when bad data is encountered.

The argument big_value_context can take the following values:

  • 'decimal128': IEEE 754R Decimal128 format. 34 digits and rounding is half-even.

  • 'decimal32': IEEE 754R Decimal32 format. 7 digits and rounding is half-even.

  • 'decimal64': IEEE 754R Decimal64 format. 16 digits and rounding is half-even.

  • 'unlimited': Unlimited precision arithmetic. Rounding is half-up.

This function is a generator function. That is, its output is another function called an OperationControl intended to be used in a call to one of the above uby functions. This detail is typically hidden from the user. However, it is important to understand this detail for debugging purposes, as the output of a call to op_control() can otherwise seem unexpected.

Examples

print("hello!")
#> [1] "hello!"