在 Google BigQuery 中创建一列 UUID [英] Create a column of UUIDs in Google BigQuery

查看:23
本文介绍了在 Google BigQuery 中创建一列 UUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google BigQuery 不支持 UUID 作为数据类型.那么,哪个选项更好地存储它:

Google BigQuery doesn't support UUID as data type. So, which option is better to store it:

  • STRING:8-4-4-4-12 格式的字符串
  • BYTES:16 个字节(128 位)的数组
  • STRING: String with the format 8-4-4-4-12
  • BYTES: Array of 16 bytes (128 bits)

推荐答案

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 STRINGs 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.

这篇关于在 Google BigQuery 中创建一列 UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆