BigQuery 解析日期不适用于 %Y%W 格式

BigQuery parse date not working on %Y%W format

一切尽在截图中: 我有一个格式为 %Y%W 的日期字符串列。我想获取对应周星期日的日期(eg. 202201 returning 2022-01-09

PARSE_DATE 函数无法正确解析数据,它只是 return 正确的年份但不解析周数

the doc开始:

The format string fully supports most format elements except for %a, %A, %g, %G, %j, %u, %U, %V, %w, and %W

那么如何解决问题呢?

数据样本:

week_year
202204
202208
202203
202205
202202
202207
202206

this question 相关但未提供问题的答案

丑陋但可行的解决方案(灵感来自 this):

DATE_SUB( DATE_ADD(DATE_TRUNC(PARSE_DATE('%Y%m%d',
          CONCAT(SUBSTR(week_year, 1, 4), '0601')), isoyear ), INTERVAL CAST(SUBSTR(week_year, -2) AS int64) WEEK), INTERVAL 1 day),