懵逼,同事前几天问我一个udf 问题 ,还是 Python 格式的

 

以前所有的Hive 函数都是 Java  或是 Scala 语言写的 ,Python 没有弄个 ,看到Python 格式的 code  懵逼了 ,非常懵逼

 

今天在看 Python 正则表达式偶遇 Python udf 的一个 case  ,不过 Python 484  not support  udaf or udtf  ??  I have know idea now .fuck

 

Here is the case   :

there is one   table named  mytable  and one column named your_name  (last_name first_name )

and we want to split this column into two from one 

Init:

mytable :

your_name

huchihaihe   fuck   

 

Finally :

mytable :

your_lastname   your_firstname

huchihaihe          fuck   

#!/usr/bin/python3

import sys

for line in sys.stdin:
    line=line.strip()
    lname ,fname=line.split(' ') # space 
    l_name=lname.lower()
    print('\t'.join([str(l_name),fname]))

#this it

the code represented the udf function  to split a data into 2

Oky I admitted I fucked for the above print function  why  you need this  ,sorry  I  do not know  ,but it needed 

Okay  let's skip the question  and see what we can do using the script

 

select your_name ,transform(your_name) using 'the above script path and name.py' as (l_name,fname) from mytable

 

Here we will get the result we wantted  funny  heng

I totally fucked

 

转载于:https://www.cnblogs.com/TendToBigData/p/10501163.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值