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] Error with outerJoin in Getting Cohort Dispatch #77

Open
TheCedarPrince opened this issue Feb 27, 2024 · 2 comments
Open

[BUG] Error with outerJoin in Getting Cohort Dispatch #77

TheCedarPrince opened this issue Feb 27, 2024 · 2 comments
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers good for beginners help wanted Extra attention is needed

Comments

@TheCedarPrince
Copy link
Member

I had seen this bug a few times and thought maybe I was just "using it wrong", but it just dawned on me that there is actually an error here as the outerjoin should also join on the :subject_id variable or else there will result duplicate column name errors.

"""
function GetCohortSubjectStartDate(df:DataFrame, conn; tab = cohort)

Given a `DataFrame` with a `:cohort_definition_id` column and `:subject_id` column, return the `DataFrame` with an associated `:cohort_start_date` corresponding to a cohort's subject ID in the `DataFrame`

Multiple dispatch that accepts all other arguments like in `GetCohortSubjectStartDate(ids, conn; tab = cohort)`
"""
function GetCohortSubjectStartDate(
    df::DataFrame, 
    conn; 
    tab = cohort
)

    return outerjoin(GetCohortSubjectStartDate(df[:,"cohort_definition_id"], df[:,"subject_id"], conn; tab=tab), df, on = :cohort_definition_id)

end

@Jay-sanjay, I am not sure how we missed this with the tests... Did we not have a test that accounted for a dataframe with both cohort_definition_id and subject_id? I guess I am just surprised we missed this; ah well!

@TheCedarPrince TheCedarPrince added bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed good for beginners labels Feb 27, 2024
@Jay-sanjay
Copy link
Member

Jay-sanjay commented Feb 27, 2024

Hi, @TheCedarPrince I guess that's strange, because I think this should have done that part , right ?

test_df1 = DataFrame(cohort_definition_id = test_cohort_definition_ids, subject_id = test_subject_ids, cohort_start_date = res.cohort_start_date[1:8])

@TheCedarPrince
Copy link
Member Author

Weird!!! Are you able to see the error too @Jay-sanjay ? Let me see if I can get a code example shortly so you can see what I am seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers good for beginners help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants