Get the metadata for the validation step where an action was triggered. This can be called by user functions to get the metadata for the current action. This function can only be used within callables crafted for the Actions class.
Returns
dict | None
A dictionary containing the metadata for the current step. If called outside of an action (i.e., when no action is being executed), this function will return None.
Description Of The Metadata Fields
The metadata dictionary contains the following fields for a given validation step:
step: The step number.
column: The column name.
value: The value being compared (only available in certain validation steps).
type: The assertion type (e.g., "col_vals_gt", etc.).
time: The time the validation step was executed (in ISO format).
level: The severity level ("warning", "error", or "critical").
level_num: The severity level as a numeric value (30, 40, or 50).
autobrief: A localized and brief statement of the expectation for the step.
failure_text: Localized text that explains how the validation step failed.
Examples
When creating a custom action, you can access the metadata for the current step using the get_action_metadata() function. Here’s an example of a custom action that logs the metadata for the current step:
the metadata is a dictionary that is used to craft the log message
the action is passed as a bare function to the Actions object within the Validate object (placing it within Validate(actions=) ensures it’s set as an action for every validation step)
See Also
Have a look at Actions for more information on how to create custom
actions for validation steps that exceed a set threshold value.