BigQuery 现在支持 函数调用 GENERATE_UUID
.这将返回一个 STRING
,其中包含 8-4-4-4-12 形式的连字符分隔的五组中的 32 个十六进制数字.
BigQuery now supports a function called GENERATE_UUID
. This returns a STRING
with 32 hexadecimal digits in five groups separated by hyphens in the form 8-4-4-4-12.
原创内容:
权衡的一些讨论:
- UUID 与其他系统中的表示兼容,例如,如果您导出到 CSV,然后想要与其他地方的导出合并.
- UUID 与 BigQuery 的可能是 UUID 实现兼容.您将能够使用函数生成相同形式的 UUID(在实现该功能时).
- 如果您稍后决定将 UUID 表示为
BYTES
,则可以使用 UDF 进行转换.
- 缺点:根据运算符,比较可能不如
BYTES
快,因为字符串比较必须考虑 UTF-8 编码.(听起来这对您来说不是问题).
- 缺点:存储成本较高.(听起来这对您来说不是问题).
- UUIDs are compatible with the representation in other systems, such as if you export to CSV and then want to merge with exports from elsewhere.
- UUIDs are compatible with BigQuery's probably UUID implementation. You will be able to generate UUIDs of this same form using a function (when the feature is implemented).
- If you decide to represent the UUIDs as
BYTES
later, you can potentially convert using a UDF.
- Downside: Comparisons may not be as fast as with
BYTES
depending on the operator, since string comparisons have to take UTF-8 encoding into account. (It sounds like this isn't an issue for you).
- Downside: Storage costs are higher. (It sounds like this isn't an issue for you).
- UUID 的存储更加紧凑;存储更便宜,比较更快.
- 如果您决定稍后将 UUID 表示为
STRING
,则可以使用 UDF 潜在地转换它们.
- 缺点:UUID 导出后与其他系统不兼容,也可能与 BigQuery 的实现不兼容.
- UUIDs are stored more compactly; storage is cheaper and comparisons are faster.
- If you decide to represent the UUIDs as
STRING
s later, you can potentially convert them using a UDF.
- Downside: UUIDs are not compatible with other systems after export, and will likely not be compatible with BigQuery's implementation either.