关于flink table api如何实现多维度去重

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

关于flink table api如何实现多维度去重

steven.yu@oppo.com
HI ALL,

        Table groupByWindowDistinctResult = orders

    .window(Tumble.over("5.minutes").on("rowtime").as("w"))

    .groupBy("a, w")

    .select("a, b.sum.distinct as d");

         ----------------------------------------------------------------------
         以上flink table代码是我在官网看到的,请问如果要对多个字段去重求和应该如何实现呢?

         如:select sum(distinct b,c) from orders group by a,w

非常感谢!

________________________________
[hidden email]
________________________________
OPPO

本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。

This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!
Reply | Threaded
Open this post in threaded view
|

Re: 关于flink table api如何实现多维度去重

Leonard Xu
Hi,

>         如:select sum(distinct b,c) from orders group by a,w
sum function 的入参只能是一个,没太明白你的需求,如果是简单的去重,group by 所有需要去重的字段就可以去重:
   .groupBy("a,b,c w")
   .select("a, b, c”);

如果是group by分组还需要对非分组字段去重做聚合,那直接:

 .groupBy("a, w")
  .select("a, b.sum.distinct, c.sum.distinct”);

Best,
Leonard Xu

>
> 非常感谢!
>
> ________________________________
> [hidden email]
> ________________________________
> OPPO
>
> 本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。
>
> This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!