Skip to contents

The yaml_agent_show_exprs() function follows the specifications of a pointblank YAML file to generate and show the pointblank expressions for generating the described validation plan. The expressions are shown in the console, providing an opportunity to copy the statements and extend as needed. A pointblank YAML file can itself be generated by using the yaml_write() function with a pre-existing agent, or, it can be carefully written by hand.

Usage

yaml_agent_show_exprs(filename, path = NULL)

Arguments

filename

The name of the YAML file that contains fields related to an agent.

path

An optional path to the YAML file (combined with filename).

Examples

Let's create a validation plan for the data quality analysis of the small_table dataset. We need an agent and its table-prep formula enables retrieval of the target table.

agent <- 
  create_agent(
    tbl = ~ small_table,
    tbl_name = "small_table",
    label = "A simple example with the `small_table`.",
    actions = action_levels(
      warn_at = 0.10,
      stop_at = 0.25,
      notify_at = 0.35
    )
  ) %>%
  col_exists(columns = vars(date, date_time)) %>%
  col_vals_regex(
    columns = vars(b),
    regex = "[0-9]-[a-z]{3}-[0-9]{3}"
  ) %>%
  rows_distinct() %>%
  col_vals_gt(columns = vars(d), value = 100) %>%
  col_vals_lte(columns = vars(c), value = 5)

The agent can be written to a pointblank YAML file with yaml_write().

yaml_write(
  agent = agent,
  filename = "agent-small_table.yml"
)

At a later time, the YAML file can be read into a new agent with the yaml_read_agent() function.

agent <- yaml_read_agent(filename = "agent-small_table.yml")

agent

To get a sense of which expressions are being used to generate the new agent, we can use yaml_agent_show_exprs().

yaml_agent_show_exprs(filename = "agent-small_table.yml")

create_agent(
  tbl = ~small_table,
  actions = action_levels(
    warn_at = 0.1,
    stop_at = 0.25,
    notify_at = 0.35
  ),
  tbl_name = "small_table",
  label = "A simple example with the `small_table`."
) %>%
  col_exists(
    columns = vars(date, date_time)
  ) %>%
  col_vals_regex(
    columns = vars(b),
    regex = "[0-9]-[a-z]{3}-[0-9]{3}"
  ) %>%
  rows_distinct() %>%
  col_vals_gt(
    columns = vars(d),
    value = 100
  ) %>%
  col_vals_lte(
    columns = vars(c),
    value = 5
  ) 

Function ID

11-6