Google BigQuery returns 同一查询的不同结果

Google BigQuery returns different results for the same query

我有以下查询:

SELECT FIRST(userId) userId, phone
FROM [Streaming_Union.client_card] c
    JOIN [FunnelReport.0050_client_cards_to_users] u 
    ON c.client_card_id = u.client_card_id GROUP BY phone
HAVING userId = "c.297500" 

在 BigQuery UI 的选项中,我禁用了查询缓存。然后我点击"Run Query",等待结果,然后再次点击,等待再点击等等。从一次到另一次,我随机得到三种不同结果之一:

第一个:

 Row    userId  phone
 1    c.297500  (XXX) XXX-XXXX   
 2    c.297500  (YYY) YYY-YYYY   
 3    c.297500  (ZZZ) ZZZ-ZZZZ  

第二个:

 Row    userId  phone
 1    c.297500  (XXX) XXX-XXXX   
 2    c.297500  (YYY) YYY-YYYY   

第三名:

Row userId  phone
Query returned zero records.

我确信JOIN 两边的表在这次测试中没有改变。当我使用 JOIN EACH 而不是 JOIN 时,我遇到了同样的问题。

我想知道是否有人可以提供帮助。是 Big Query 错误还是记录在案的行为?

非常感谢!

尝试以下操作以确认您看到的 "behaviour":

SELECT FIRST(first) AS first, second
FROM [publicdata:samples.trigrams]
GROUP BY second
HAVING first = 'merry'

如果禁用缓存 - 每次 运行 它都会 returns 不同的结果。
我认为这是因为 FIRST() 函数的性质。

您需要重写您的查询以保证对于每个 phone 您始终获得相同的第一个用户,因此最终结果是确定性的。像下面用 MAX() 代替 FIRST()

的查询
SELECT MAX(first) AS first, second
FROM [publicdata:samples.trigrams]
GROUP BY second
HAVING first = 'merry'