我遇到了一个问题。我想从涉及4个不同表的查询中创建模型。 但是,出现以下错误:语法错误-未公开评论
标准SQL中的代码:
CREATE MODEL `project.test1`
Options
(model_type='logistic_reg', labels = ['days_between_dates']) AS
WITH all_dates AS (SELECT ID, ARRAY_AGG(STRUCT(date)))
, info AS (SELECT ID, info)
, first_date AS (SELECT ID, date)
, second_date AS(SELECT ID, date)
SELECT * , DATE_DIFF(first_date.date, second_date.date) AS days_between_dates
FROM all_dates
JOIN first_date USING (ID)
JOIN second_date USING (ID)
LEFT JOIN info USING (ID)
WHERE days_between_dates > 1
代码按预期工作,无需添加CREATE MODEL语句(代码的前三行)即可运行。
任何帮助将我指向正确方向的方法,我们将不胜感激。
谢谢
答案 0 :(得分:0)
问题已通过以下代码解决:
CREATE MODEL `project.test1`
Options
(model_type='logistic_reg', labels = ['days_between_dates']) AS
SELECT * , DATE_DIFF(first_date.date, second_date.date) AS days_between_dates
FROM (SELECT ID, ARRAY_AGG(STRUCT(date)))
JOIN (SELECT ID, date) first_date USING (ID)
JOIN (SELECT ID, date) second_date USING (ID)
LEFT JOIN (SELECT ID, info) USING (ID)
WHERE days_between_dates > 1
但是“数据类型ARRAY