odps词频统计

1、搭建maxcompute studio

一、编写udtf

2、在项目下面选择script新建文件:new->maxcomput python->python udtf ,然后编写文本spilt:

from odps.udf import annotate
from odps.udf import BaseUDTF


@annotate('string -> string')
class my_first_udtf(BaseUDTF):
    def process(self, arg):
        props = arg.split(' ')
        for p in props:
            self.forward(p)

然后运行一下,本地调试,可以查看结果。

3、提交udtf,并注册函数:打开该python源码,在定义的类my_first_udtf中,右键-》deploy to  server,然后填写一下function  name即可上传,并且注册函数function name

4、sql调用函数 测试结果:

create table if not exists chenmo_word_split_tabel1(word string ) lifecycle 1;
insert overwrite table  chenmo_word_split_tabel1 select my_first_udtf(word) as word from chenmo_wc_in;

二、编写udaf进行聚合统计




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值