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

  • 相关阅读:
    npropress进度条插件的使用
    让img图片像背景一样显示
    vue-cli3配置多页面入口
    7中漂亮的纯css字体
    速查手册
    推荐系统架构
    leetcode 172. 阶乘后的零
    C++ string和int互相转换
    特征分解
    线性代数基础
  • 原文地址:https://www.cnblogs.com/TendToBigData/p/10501163.html
Copyright © 2011-2022 走看看