pointblank icon indicating copy to clipboard operation
pointblank copied to clipboard

`get_agent_x_list()$columns` is empty for `col_vals_expr()`

Open mayeulk opened this issue 2 years ago • 1 comments

I notice that, for col_vals_expr(), the columns slot of the object returned by get_agent_x_list() is NA. This is linked to https://github.com/rich-iannone/pointblank/issues/475, but as a slightly broader issue (such as "For failed rows, access columns used in validation, and only those").

In my code in issue https://github.com/rich-iannone/pointblank/issues/475, instead of columns_to_display <- unique c((id_columns, get_agent_x_list(agent, i = c_step)$columns )) I use the following workaround, with a hack involving all.vars(as.formula()):

c_agent_step <- get_agent_x_list(agent, i = c_rule)
if (c_agent_step$type == "col_vals_expr") {
   columns_to_display <- unique (c(id_columns,
                                   # get the variables from the expr-ession used in col_vals_expr()
                                   all.vars(as.formula( paste0("~", c_agent_step$values)))) )
 } else {
   columns_to_display <- unique (c(id_columns, c_agent_step$columns) )
 }

My use case here is a validation step involving:

  col_vals_expr(
    expr = expr( paste0("some_string", column1) == column2))

I would suggest adding something to fill in the columns slot in such cases (and maybe for specially(), too).

mayeulk avatar May 03 '23 15:05 mayeulk

Thank you for raising this issue and digging into the details. This definitely should be fixed!

rich-iannone avatar Jul 21 '23 18:07 rich-iannone

Fixed in dev!

agent <- data.frame(x = 1, y = 2, z = 3) %>% 
  create_agent() %>% 
  col_vals_expr(expr(x + y == z)) %>% 
  interrogate()
  
get_agent_report(agent)

image

get_agent_report(agent, display_table = FALSE)$columns
#> [1] "x, y, z"

yjunechoe avatar Jun 09 '24 10:06 yjunechoe