in components/doc-registry/src/document_registry_service.py [0:0]
def look_up_document(registry_table: str, crc32s: list[str]):
"""Given a list of crc32 values and return all the matching entries from the document registry table"""
unique_crc32s = list(set(crc32s))
select_crc32_rows = [f"SELECT '{crc32}' AS crc32" for crc32 in unique_crc32s]
crc32_table = " UNION ALL ".join(select_crc32_rows)
crc32_table_alias = "crc32_table"
query = " ".join(
[
f"WITH {crc32_table_alias} AS ({crc32_table})",
f"SELECT id, fileName, gcsUri, a.crc32 FROM `{registry_table}` AS a",
f"INNER JOIN {crc32_table_alias} AS b",
"ON a.crc32 = b.crc32",
]
)
return GoogleCloudClients.get_bq_client().query(query)