UDAF 聚合函数

UDAF(Built-in Aggregate Functions)

  • UDF:User-Defined Functions
  • A:Aggregate


collect_set(col)collect_list(col)

  • 将某个列的多行记录合并成一个 array 返回

  • 前者去重,后者不去重

  • drop table if exists test.test;
    create table IF NOT EXISTS test.test(
        name string
    );
    insert into test.test values
    ('刘一'),
    ('刘一'),
    ('陈二'),
    ('张三'),
    ('李四'),
    ('王五'),
    ('刘一');
    select collect_set(name), collect_list(name) from test.test;
    
  • 074