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

  • 相关阅读:
    JqGrid在IE8中表头不能分组的解决办法
    Task 异步小技巧
    封装好的socket,拿去用
    反射 实现不同模型相同属性赋值 第二集(automapper)
    .net破解二(修改dll)
    .net破解一(反编译,反混淆-剥壳)
    c/s 自动升级(WebService)
    反射实现不同模型相同属性赋值
    row_number() over()分页查询
    SQL函数
  • 原文地址:https://www.cnblogs.com/TendToBigData/p/10501163.html
Copyright © 2011-2022 走看看