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

join_key can set default parent #215

Merged
merged 34 commits into from
Dec 22, 2023
Merged

join_key can set default parent #215

merged 34 commits into from
Dec 22, 2023

Conversation

averissimo
Copy link
Contributor

@averissimo averissimo commented Dec 11, 2023

Pull Request

Fixes #203

Changes description / TODO while wip

  • Add parameter on join_key() and [<-.join_keys that determines which dataset is parent
  • Protects against cyclical parents when creating or merging join_keys
  • Tests
    • Corrects existing tests to include new logic
    • Re-write / add tests to account for usage
  • Update documentation
    • Man pages
    • Update join_key vignette

🗨️ Discussion

  • Q: should jk[[i]][[j]] <- key define a parent relationship?
    • consider that jk[[i]] <- list(j = key, m = key2) would have to set parents for j and m
      • might also have to add parent parameter.
    • My intuition is that [[ should be left undirected

@averissimo averissimo force-pushed the 203_default_parents@main branch from 476fa06 to 497435d Compare December 11, 2023 11:45
R/join_keys-c.R Outdated Show resolved Hide resolved
R/join_key.R Outdated Show resolved Hide resolved
@averissimo averissimo marked this pull request as ready for review December 12, 2023 14:03
Copy link
Contributor

github-actions bot commented Dec 12, 2023

badge

Code Coverage Summary

Filename                         Stmts    Miss  Cover    Missing
-----------------------------  -------  ------  -------  -------------------
R/cdisc_data.R                       1       1  0.00%    37
R/default_cdisc_join_keys.R         11      11  0.00%    17-35
R/deprecated.R                      69      69  0.00%    16-350
R/dummy_function.R                   5       5  0.00%    16-23
R/formatters_var_labels.R           47      47  0.00%    28-149
R/join_key.R                        38       0  100.00%
R/join_keys-c.R                     12       0  100.00%
R/join_keys-extract.R              128       0  100.00%
R/join_keys-names.R                 15       0  100.00%
R/join_keys-parents.R               30       0  100.00%
R/join_keys-print.R                 45       0  100.00%
R/join_keys-utils.R                 73       3  95.89%   33-36
R/join_keys.R                       21       0  100.00%
R/teal_data-class.R                 25       1  96.00%   70
R/teal_data-datanames.R             10       0  100.00%
R/teal_data-get_code.R              15       1  93.33%   55
R/teal_data-show.R                   4       4  0.00%    13-18
R/teal_data.R                       22       9  59.09%   32, 41-47, 50
R/testhat-helpers.R                 26       0  100.00%
R/topological_sort.R                32       0  100.00%
R/utils-get_code_dependency.R      104       1  99.04%   43
R/utils.R                           14       0  100.00%
R/verify.R                          42      11  73.81%   68, 98-102, 105-109
R/zzz.R                             10      10  0.00%    4-16
TOTAL                              799     173  78.35%

Diff against main

Filename                 Stmts    Miss  Cover
---------------------  -------  ------  --------
R/join_key.R                +7       0  +100.00%
R/join_keys-c.R            -14       0  +100.00%
R/join_keys-extract.R       +6       0  +100.00%
R/join_keys-parents.R       +2      -1  +3.57%
R/join_keys-print.R         -1       0  +100.00%
R/join_keys-utils.R        -14      +1  -1.81%
TOTAL                      -14       0  -0.37%

Results for commit: 86529be

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Dec 12, 2023

Unit Tests Summary

    1 files    14 suites   1s ⏱️
168 tests 166 ✔️ 2 💤 0
247 runs  245 ✔️ 2 💤 0

Results for commit 86529be.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 12, 2023

Unit Test Performance Difference

Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
join_keys-c 💀 $0.01$ $-0.01$ c.join_key_set_throws_on_conflicting_join_keys_set_objects
join_keys-c 👶 $+0.01$ c.join_keys_throws_error_when_merge_produces_acyclical_graph
join_keys-c 💀 $0.02$ $-0.02$ c.join_keys_throws_on_conflicting_join_keys_set_objects
join_keys-extract 💀 $0.01$ $-0.01$ _.join_keys_adds_symmetrical_change_to_the_foreign_dataset
join_keys-extract 👶 $+0.00$ _.join_keys_adds_symmetrical_change_without_parents_to_the_foreign_dataset
join_keys-extract 💀 $0.01$ $-0.01$ _.join_keys_removes_keys_with_NULL_and_applies_summetrical_changes
join_keys-extract 👶 $+0.01$ _.join_keys_removes_keys_with_NULL_and_applies_symmetrical_changes
join_keys-extract 👶 $+0.01$ join_keys_i_j_removes_keys_with_NULL
join_keys-parents 👶 $+0.00$ parents_will_return_empty_list_when_attribute_does_not_exist
join_keys 👶 $+0.01$ join_keys_accepts_duplicated_join_key_undirected_
join_keys 👶 $+0.01$ join_keys_cannot_create_acyclical_graph
join_keys 💀 $0.03$ $-0.03$ join_keys_fails_when_provided_foreign_key_pairs_have_incompatible_values

Results for commit 3270664

♻️ This comment has been updated with latest results.

R/join_key.R Outdated Show resolved Hide resolved
Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent argument is confusing. Default values differ between two functions and the possibility of having a parent as dataset_1 or dataset_2 is too "freely". I would prefer to limit dataset_1 to be a parent only. So that

join_key("parent", "child", c(id_in_parent = id_in_child), directed = TRUE) # default

join_key("A", "B", c(id_in_A = id_in_B), directed = FALSE)

R/join_key.R Outdated Show resolved Hide resolved
R/join_key.R Outdated Show resolved Hide resolved
R/join_keys-extract.R Outdated Show resolved Hide resolved
R/join_keys-extract.R Outdated Show resolved Hide resolved
R/join_key.R Outdated Show resolved Hide resolved
R/join_keys-utils.R Outdated Show resolved Hide resolved
R/join_key.R Outdated Show resolved Hide resolved
R/join_keys-parents.R Outdated Show resolved Hide resolved
averissimo and others added 2 commits December 20, 2023 12:15
Co-authored-by: kartikeya kirar <[email protected]>
Co-authored-by: Dawid Kałędkowski <[email protected]>
Signed-off-by: André Veríssimo <[email protected]>
R/join_key.R Show resolved Hide resolved
R/join_key.R Outdated Show resolved Hide resolved
R/join_key.R Show resolved Hide resolved
R/join_keys-parents.R Outdated Show resolved Hide resolved
R/join_keys-parents.R Outdated Show resolved Hide resolved
vignettes/join-keys.Rmd Outdated Show resolved Hide resolved
R/join_keys.R Outdated Show resolved Hide resolved
@gogonzo gogonzo dismissed their stale review December 20, 2023 22:11

Comments addressed

@kartikeyakirar kartikeyakirar self-assigned this Dec 22, 2023
@kartikeyakirar
Copy link
Contributor

@averissimo PR looks great. I have re-reviewed it and tested it with c(...) and join_keys(...). Additionally, I found three unused variables (by running the linter), which I have removed here 7947878

Copy link
Contributor

@kartikeyakirar kartikeyakirar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@averissimo averissimo merged commit 85e6a6e into main Dec 22, 2023
23 checks passed
@averissimo averissimo deleted the 203_default_parents@main branch December 22, 2023 10:15
averissimo added a commit to insightsengineering/teal that referenced this pull request Dec 22, 2023
…efault (#1020)

# Pull Request

<!--- Replace `#nnn` with your issue link for reference. -->

Fixes insightsengineering/teal.slice#502

Part of insightsengineering/teal.slice#503 and
insightsengineering/teal.data#215

### Changes 

- Corrects test to reflect behavior resulting from `teal.data` default
parent setting when creating new `join_key`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Set default parent
4 participants