我一直试图解决这个错误几个小时而没有任何运气,这是一个我已经运行数周而没有任何问题的查询,但突然间我看到了这个错误:
错误:ON子句必须为AND = =比较一个字段名称 每个表,所有字段名称都以表名为前缀。
查询的格式如下:
SELECT S.av AS av, S.dm AS dm, t, gn
FROM [dataset.cTable]
JOIN EACH (SELECT id, av, dm FROM [dataset.sTable]) AS S ON S.id = sid
AND (t == 'type1' OR t == 'type2') GROUP EACH BY av, dm, t, gn;
非常感谢任何帮助。
答案 0 :(得分:2)
(t == 'type1' OR t == 'type2')
子句不是连接条件,它是where条件。如果您将查询更改为:
SELECT S.av AS av, S.dm AS dm, C.t, C.gn
FROM [dataset.cTable] C
JOIN EACH (SELECT id, av, dm FROM [dataset.sTable]) AS S ON S.id = sid
WHERE (C.t == 'type1' OR C.t == 'type2') GROUP EACH BY S.av, S.dm, C.t, C.gn;
它应该有用。
答案 1 :(得分:0)
据推测,添加别名可以解决问题。我也不认为子查询是必要的:
SELECT S.av AS av, S.dm AS dm, c.t, c.gn
FROM [dataset.cTable] as c JOIN EACH
[dataset.sTable] AS S
ON S.id = c.sid
WHERE c.t in ('type1', 'type2')
GROUP EACH BY av, dm, t, gn;
each
可能没有必要,但我对Google BigQuery并不太熟悉。