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

Fix matching on multiple properties and profiles #101

Merged
merged 2 commits into from
Sep 12, 2023

Conversation

matthuska
Copy link
Contributor

Previously there would always be no matches returned when you query for > 1 property. I suspect the same would be the case if you searched for > 1 profile as well, or mixtures of the two. This fix was tested with multiple properties and profiles, as well as negation.

I don't love the if count == 0 stuff, if you want to rewrite that in a more elegant way then feel free.

@matthuska
Copy link
Contributor Author

I found problems with this solution when querying using wildcards (e.g. match --LINEAGE "B.1%"). Will reopen this when I find a solution.

@matthuska matthuska closed this Sep 6, 2023
@matthuska matthuska reopened this Sep 6, 2023
@@ -2442,15 +2441,18 @@ def create_profile_cases(
if match:
case, val = processing_funcs[mutation_type](match)
cases.append(
f"CASE WHEN {' AND '.join(case)} THEN 1 ELSE 0 END AS mutation_{ids[mutation]}"
f"SUM(CASE WHEN {' AND '.join(case)} THEN 1 ELSE 0 END) AS mutation_{ids[mutation]}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why SUM? I think this is nor necessary. If the conditions are met we assign 1 else we assign 0. Makes the comparsion easier

@@ -2551,7 +2553,7 @@ def create_sample_selection_sql(

if conditions:
conditions = " AND ".join(conditions)
sql += f" WHERE {conditions}"
sql += f" GROUP BY s.id HAVING {conditions}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is GROUP BY really necessary since it would be very bad for performance.

@matthuska matthuska merged commit 14e6387 into dev/covsonar2-alpha Sep 12, 2023
1 check passed
@matthuska matthuska deleted the fix/match-multi-prop branch September 12, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants