impala-count()报错换用NDV()函数

使用impala查询引擎的时候,如果count(disticnt column)数据量过大会报错,报错内容

正在提取遇到以下错误的结果:

 (370) Query analysis error occurred during query execution: [HY000] : AnalysisException: all DISTINCT aggregate functions need to have the same set of parameters as count(DISTINCT a.udid_); deviating function: count(DISTINCT a.ip_)
Consider using NDV() instead of COUNT(DISTINCT) if estimated counts are acceptable. Enable the APPX_COUNT_DISTINCT query option to perform this rewrite automatically.
. Error 370. SQLSTATE HY000

简单来说就是count(distinct column)让你换成NDV(column),换了之后查询会快很多,
如果想正常使用count()需要设置参数,

官方文档:

set APPX_COUNT_DISTINCT=true;

NDV功能
一个聚合函数,返回一个类似于COUNT(DISTINCT col )结果的近似值,即“不同值的数量” 。 它比COUNT和DISTINCT的组合快得多,并且使用恒定的内存量,因此对于具有高基数的列而言,内存密集度较低。
 
句法:
 
 NDV([DISTINCT | ALL] expression ) 
使用说明:
这是COMPUTE STATS语句
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值