You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by 小旋锋 <wh...@qq.com> on 2020/02/26 10:21:04 UTC

Flink sql count 多个属性的问题

大家好:
&nbsp; &nbsp; &nbsp; &nbsp; 我在flink官方文档上看到内置聚合函数count的函数头是这样的
&nbsp; &nbsp; &nbsp; &nbsp; count([all] Expression | distinct Expression1 [, Expression2])
&nbsp; &nbsp; &nbsp; &nbsp; 所以它应该可以对多个属性进行distinct去重,而且我在源码的单元测试里也看到有几个用例 select count(distinct a, b) from mytable,并且是可以运行通过的
&nbsp; &nbsp; &nbsp; &nbsp; 但是我自己写sql却运行不起来,报异常&nbsp; codegenexpression. No matching accumulate methods for Aggregation function. ......CountAggFunction with Parameters (Java.lang.String, java.lang.Long)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Flink1.8和1.9都无法运行,请问这是什么情况呢?

Re: Flink sql count 多个属性的问题

Posted by Jark Wu <im...@gmail.com>.
Hi,

能贴一下你的完整 SQL 吗?

On Wed, 26 Feb 2020 at 18:21, 小旋锋 <wh...@qq.com> wrote:

> 大家好:
> &nbsp; &nbsp; &nbsp; &nbsp; 我在flink官方文档上看到内置聚合函数count的函数头是这样的
> &nbsp; &nbsp; &nbsp; &nbsp; count([all] Expression | distinct Expression1
> [, Expression2])
> &nbsp; &nbsp; &nbsp; &nbsp; 所以它应该可以对多个属性进行distinct去重,而且我在源码的单元测试里也看到有几个用例
> select count(distinct a, b) from mytable,并且是可以运行通过的
> &nbsp; &nbsp; &nbsp; &nbsp; 但是我自己写sql却运行不起来,报异常&nbsp; codegenexpression.
> No matching accumulate methods for Aggregation function.
> ......CountAggFunction with Parameters (Java.lang.String, java.lang.Long)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Flink1.8和1.9都无法运行,请问这是什么情况呢?

Re: Flink sql count 多个属性的问题

Posted by godfrey he <go...@gmail.com>.
hi, 你看到的 select count(distinct a, b) from mytable 单元测试能通过,应该是只测试 logical
plan,当前在生成 physical plan的时候,显示的禁用了多个字段

Bests,
Godfrey

apache22 <ap...@163.com> 于2020年2月26日周三 下午6:56写道:

> 我的经验:
> count(distinct 只支持单字段)   ,  distinct  a,b 是可以的
> 有一个解决方式:count(distinct  concat(a,b))
>
>
> | |
> apache22
> |
> |
> apache22@163.com
> |
> 签名由网易邮箱大师定制
> 在2020年2月26日 18:21,小旋锋<wh...@qq.com> 写道:
> 大家好:
> &nbsp; &nbsp; &nbsp; &nbsp; 我在flink官方文档上看到内置聚合函数count的函数头是这样的
> &nbsp; &nbsp; &nbsp; &nbsp; count([all] Expression | distinct Expression1
> [, Expression2])
> &nbsp; &nbsp; &nbsp; &nbsp; 所以它应该可以对多个属性进行distinct去重,而且我在源码的单元测试里也看到有几个用例
> select count(distinct a, b) from mytable,并且是可以运行通过的
> &nbsp; &nbsp; &nbsp; &nbsp; 但是我自己写sql却运行不起来,报异常&nbsp; codegenexpression.
> No matching accumulate methods for Aggregation function.
> ......CountAggFunction with Parameters (Java.lang.String, java.lang.Long)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Flink1.8和1.9都无法运行,请问这是什么情况呢?

回复:Flink sql count 多个属性的问题

Posted by apache22 <ap...@163.com>.
我的经验:  
count(distinct 只支持单字段)   ,  distinct  a,b 是可以的
有一个解决方式:count(distinct  concat(a,b))


| |
apache22
|
|
apache22@163.com
|
签名由网易邮箱大师定制
在2020年2月26日 18:21,小旋锋<wh...@qq.com> 写道:
大家好:
&nbsp; &nbsp; &nbsp; &nbsp; 我在flink官方文档上看到内置聚合函数count的函数头是这样的
&nbsp; &nbsp; &nbsp; &nbsp; count([all] Expression | distinct Expression1 [, Expression2])
&nbsp; &nbsp; &nbsp; &nbsp; 所以它应该可以对多个属性进行distinct去重,而且我在源码的单元测试里也看到有几个用例 select count(distinct a, b) from mytable,并且是可以运行通过的
&nbsp; &nbsp; &nbsp; &nbsp; 但是我自己写sql却运行不起来,报异常&nbsp; codegenexpression. No matching accumulate methods for Aggregation function. ......CountAggFunction with Parameters (Java.lang.String, java.lang.Long)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Flink1.8和1.9都无法运行,请问这是什么情况呢?