在hue中,使用impala查询时, distinct host 查出结果为 2089, 而使用count(distinct host) 查出结果为2034;
通过查看DISTINCT Operator, 看到 “开启自动将COUNT(DISTINCT)重写为NDV(),通过加上查询参数APPX_COUNT_DISTINCT
”
在hue里,使用NDV(host) 查出结果为2034, 可知HUE连接impala时自动加上了APPX_COUNT_DISTINCT
, 使count(distinct host) 转为NDV(host) , 而NDV是快速得到近似值;
而直接在impala shell里执行,得到的结果是正确的;
在hue和impala-shell里通过 set
查看查询参数:
> set;
APPX_COUNT_DISTINCT: [0]
这个参数并没有开启;
第二天在Hue查询,结果又是正常的了;进一步查找原因
使用在hue里explain
查看查询任务
> explain select count(distinct host) from default.tmp_kn2_monitor_host_runhigh_hour_4_2019102310
WARNING: The following tables are missing relevant table and/or column statistics
可能跟表统计有关;也可能跟节点信息不同步有关;