Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unexpected column type on filtered data #527

Open
3 tasks done
averissimo opened this issue Jan 18, 2024 · 0 comments
Open
3 tasks done

[Bug]: Unexpected column type on filtered data #527

averissimo opened this issue Jan 18, 2024 · 0 comments
Labels
bug Something isn't working core

Comments

@averissimo
Copy link
Contributor

averissimo commented Jan 18, 2024

What happened?

Problem: get_data method in teal.slice::FilteredData doesn't keep the same column type for possible values in filtered parameter

It was detected on insightsengineering/teal#1038 and it only happens when there is a join_keys parent-child relationship.

Impact: As far as I can tell this doesn't affect users or is a problem, unless manually inspecting the contents.

Edge case: This surfaces when there is a conversion of FilteredData to teal_data and the initial hash of a dataname does not match the contents of qenv envirnoment object

Reproducible code: (needs {teal.slice}, {teal.code} and {teal.data})

td <- teal.data::teal_data(join_keys = teal.data::join_keys(teal.data::join_key("d1", "d2", c("pk" = "id")))) |> 
  within(d1 <- data.frame(id = 1:5, pk = c(2, 3, 2, 1, 4), val = 1:5)) |> 
  within(d2 <- data.frame(id = 1:5, value = 1:5))

datasets <- teal.slice::init_filtered_data(
  x = sapply(c("d1", "d2"), function(dn) td[[dn]], simplify = FALSE),
  join_keys = teal.data::join_keys(td)
)


# str() -----------------------------------------------------------------------

# filtered = TRUE
datasets$get_data("d2", filtered = TRUE) |> 
  shiny::isolate() |> 
  str()
#> 'data.frame':    5 obs. of  2 variables:
#>  $ id   : num  1 2 2 3 4
#>  $ value: int  1 2 2 3 4

# filtered = FALSE
datasets$get_data("d2", filtered = FALSE) |> 
  shiny::isolate() |> 
  str()
#> 'data.frame':    5 obs. of  2 variables:
#>  $ id   : int  1 2 3 4 5
#>  $ value: int  1 2 3 4 5

# rlang::hash() ---------------------------------------------------------------

# filtered = TRUE
datasets$get_data("d2", filtered = TRUE) |> 
  shiny::isolate() |> 
  rlang::hash()
#> [1] "fed25eb8e9c06544ff433b8cbb15379f"

# filtered = FALSE
datasets$get_data("d2", filtered = FALSE) |> 
  shiny::isolate() |> 
  rlang::hash()
#> [1] "6e30be195b7d914a1311672c3ebf4e4f"

Created on 2024-01-18 with reprex v2.0.2

sessionInfo()

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

No branches or pull requests

1 participant