将旧版sql转换为标准sql - Big Query

时间:2017-11-20 10:16:36

标签: google-bigquery

在标准SQL中运行以下代码时,我在大查询中遇到以下错误:

SELECT 
    DATE(DATE_ADD(TIMESTAMP("2017-10-01"), pos - 1, "DAY")) AS selected_date
FROM
    (SELECT 
         ROW_NUMBER() OVER() AS pos, *
     FROM 
         (FLATTEN((SELECT SPLIT(RPAD('', 1 + DATEDIFF(TIMESTAMP(CURRENT_DATE()), TIMESTAMP("2017-10-01")), '.'),'') AS h
     FROM (SELECT NULL)),h
     )))

错误:

  

语法错误:预期的关键字JOIN但在[7:7]

得到“)”

任何人都可以将其转换为标准SQL吗?

1 个答案:

答案 0 :(得分:2)

   
#standardSQL
SELECT d AS selected_date
FROM UNNEST(GENERATE_DATE_ARRAY("2017-10-01", CURRENT_DATE())) d