zoukankan      html  css  js  c++  java
  • 懵逼,同事前几天问我一个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('	'.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

  • 相关阅读:
    [洛谷P3674]小清新人渣的本愿
    [洛谷P2698][USACO12MAR]花盆Flowerpot
    [洛谷P4329][COCI2006-2007#1] Bond
    [洛谷P3203][HNOI2010]弹飞绵羊
    [洛谷P1407][国家集训队]稳定婚姻
    [洛谷P3388]【模板】割点(割顶)
    TX2_安装view_team
    tx2的一些系统命令
    tensorflow-cnnn-mnist
    mnist数据集tensorflow实现
  • 原文地址:https://www.cnblogs.com/TendToBigData/p/10501163.html
Copyright © 2011-2022 走看看