首页 > 其他 > 详细

ArrayProcessUDTF

时间:2019-05-17 10:39:51      阅读:120      评论:0      收藏:0      [点我收藏+]
package com.suning.udf;


import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF;

public class ArrayProcessUDTF extends GenericUDTF {

    @Override
    public void process(Object[] args) throws HiveException {

        String input = args[0].toString();
        String[] test = input.split(",");
        for (int i = 0; i < test.length; i++) {
            try {
                String[] result = (test[i] + ":" + String.valueOf(i + 1)).split(":");
                forward(result);
            } catch (Exception e) {
                continue;
            }
        }
    }

    @Override
    public void close() throws HiveException {

    }
}    // select array_process(‘a,c,b‘)    
//返回元素和索引 a 1 c 2 b 3

 

ArrayProcessUDTF

原文:https://www.cnblogs.com/yin-fei/p/10879710.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!