Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Unique Identifier in BigQuery Table

Use case

I need a stable Unique Identifier in a BigQuery table which is inserted into by Google. Thus I can not insert a UUID or similiar along with each row entry (but this is exactly what I need). I am aware of BigQuery's GENERATE_UUID() however this would return a new UUID on each query, which is not desired.

My question

How can I get an unique identifier for each row in a BigQuery table which is stable across multiple queries?

like image 936
kentor Avatar asked Sep 17 '25 01:09

kentor


1 Answers

You can use combination of TO_JSON_STRING() with one of hash functions like FARM_FINGERPRINT

SELECT FARM_FINGERPRINT(TO_JSON_STRING(t)), *
FROM `project.dataset.table` t
like image 168
Mikhail Berlyant Avatar answered Sep 23 '25 12:09

Mikhail Berlyant