📐

BigQueryで10進数と16進数の相互変換

2021/03/15に公開

10進数から16進数

SELECT
  65535 AS a,
  FORMAT('%x', 65535) AS b
a b
65535 ffff

参考

https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions?hl=ja#format_string

16進数から10進数

SELECT
  'ffff' AS a,
  CAST(CONCAT('0x', 'ffff') AS INT64) AS b
a b
ffff 65535

参考

https://cloud.google.com/bigquery/docs/reference/standard-sql/conversion_rules?hl=ja#casting

Discussion