“计数不同”使用BigQuery新的标准SQL语法确切吗? [英] Is "count distinct" exact with BigQuery new standard SQL syntax?

查看:102
本文介绍了“计数不同”使用BigQuery新的标准SQL语法确切吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用旧版BigQuery语法,如果我们想为字段使用精确数量的不同值,则必须使用 exact_count_distinct 函数。



使用标准SQL 2011语法,我想知道如果我不选择'Use Legacy SQL'选项,那么 count(distinct myfield )将始终返回不同值的确切数目。

解决方案

COUNT(DISTINCT input)给出了标准SQL中的精确计数。



一个重要的区别是 COUNT(DISTINCT input) EXACT_COUNT_DISTINCT(input) code>在传统的BigQuery SQL中,所以通常情况下,性能会更好,并且您不太可能遇到资源超出错误。



您可以阅读其他差异传统和标准SQL之间在迁移指南中。


With the legacy BigQuery syntax, we have to use the exact_count_distinct function if we want to have the exact number of distinct values for a field.

With the Standard SQL 2011 syntax, I wonder if "count(distinct myfield)" will always return the exact number of distinct values if I don't select the 'Use Legacy SQL' option.

解决方案

COUNT(DISTINCT input) gives an exact count in standard SQL.

One important distinction is that COUNT(DISTINCT input) is more scalable than EXACT_COUNT_DISTINCT(input) in legacy BigQuery SQL, so in general the performance will be better and you are less likely to encounter resource exceeded errors.

You can read about other differences between legacy and standard SQL in the migration guide.

这篇关于“计数不同”使用BigQuery新的标准SQL语法确切吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆