Skip to content

Commit e498931

Browse files
committed
Consolidate metadata join statements for embeddings
1 parent eab335c commit e498931

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

.DS_Store

8 KB
Binary file not shown.

timdex_dataset_api/embeddings.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,6 @@ def _build_query(
411411
embeddings_table = self.get_sa_table(table)
412412
metadata_table = self.timdex_dataset.metadata.get_sa_table("records")
413413

414-
# create SQL statement with join to metadata.records
415-
join_condition = and_(
416-
embeddings_table.c.timdex_record_id == metadata_table.c.timdex_record_id,
417-
embeddings_table.c.run_id == metadata_table.c.run_id,
418-
embeddings_table.c.run_record_offset == metadata_table.c.run_record_offset,
419-
)
420-
421414
# select specific columns or default to all from embeddings + metadata
422415
if columns:
423416
embeddings_cols = []
@@ -441,7 +434,12 @@ def _build_query(
441434
]
442435
stmt = select(*embeddings_cols, *metadata_cols)
443436

444-
# build join
437+
# create SQL statement with join to metadata.records
438+
join_condition = and_(
439+
embeddings_table.c.timdex_record_id == metadata_table.c.timdex_record_id,
440+
embeddings_table.c.run_id == metadata_table.c.run_id,
441+
embeddings_table.c.run_record_offset == metadata_table.c.run_record_offset,
442+
)
445443
stmt = stmt.select_from(embeddings_table.join(metadata_table, join_condition))
446444

447445
# split filters between embeddings and metadata tables

0 commit comments

Comments
 (0)