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

add distinct to remove duplicate results #706

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

raylrui
Copy link
Contributor

@raylrui raylrui commented Nov 18, 2024

Fix

Duplicate workflows when using workflow search: umccr/orca-ui#82

Analysis

The duplicate results occur because of the OR conditions in the search query combined with the related table joins. And The duplicate results occur selectively because of how JOIN operations work with OR conditions in the search query.
No Duplicates Case:

-- When searching only direct fields (workflow_run_name or comment)
-- Example search: "test" matching workflow_run_name
SELECT * FROM workflow_run 
WHERE workflow_run_name ILIKE '%test%'
-- No JOINs needed = No duplicates

Duplicates Case:

-- When searching related fields (libraries or workflow)
-- Example search: "oncoanalyser_wgs" matching multiple libraries
SELECT workflow_run.* 
FROM workflow_run 
JOIN libraries ON workflow_run.id = libraries.workflow_run_id
WHERE libraries.library_id ILIKE '%oncoanalyser_wgs%'
-- One workflow_run might have multiple matching libraries = Duplicates

🥲 So, to be simple, in our case, if there are multiple libraries related to that workflow_run, there will be duplicate case of search results.

@raylrui
Copy link
Contributor Author

raylrui commented Nov 20, 2024

merging...

@raylrui raylrui merged commit 6c88075 into main Nov 20, 2024
6 checks passed
@raylrui raylrui deleted the fix/duplicate-workflows-when-using-workflow-search branch November 20, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant