Skip to content

Commit

Permalink
chore (backend): resolve the warning:
Browse files Browse the repository at this point in the history
SAWarning: SELECT statement has a cartesian product between FROM element(s) 'evaluations' and FROM element 'human_evaluations'.  Apply join condition(s) between each element to resolve.
  • Loading branch information
aybruhm committed Sep 26, 2024
1 parent f70f385 commit b786335
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions agenta-backend/agenta_backend/services/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2644,15 +2644,15 @@ async def fetch_evaluations_by_resource(
.join(HumanEvaluationVariantDB)
.filter(
HumanEvaluationVariantDB.variant_id.in_(ids),
EvaluationDB.project_id == uuid.UUID(project_id),
HumanEvaluationDB.project_id == uuid.UUID(project_id),
)
.options(load_only(HumanEvaluationDB.id)) # type: ignore
)
res_evaluations = result_evaluations.scalars().all()
res_human_evaluations = result_human_evaluations.scalars().all()
return res_evaluations + res_human_evaluations

if resource_type == "testset":
elif resource_type == "testset":
result_evaluations = await session.execute(
select(EvaluationDB)
.filter(
Expand All @@ -2665,15 +2665,16 @@ async def fetch_evaluations_by_resource(
select(HumanEvaluationDB)
.filter(
HumanEvaluationDB.testset_id.in_(ids),
EvaluationDB.project_id == uuid.UUID(project_id),
HumanEvaluationDB.project_id
== uuid.UUID(project_id), # Fixed to match HumanEvaluationDB
)
.options(load_only(HumanEvaluationDB.id)) # type: ignore
)
res_evaluations = result_evaluations.scalars().all()
res_human_evaluations = result_human_evaluations.scalars().all()
return res_evaluations + res_human_evaluations

if resource_type == "evaluator_config":
elif resource_type == "evaluator_config":
query = (
select(EvaluationDB)
.join(EvaluationDB.evaluator_configs)
Expand Down

0 comments on commit b786335

Please sign in to comment.