hiveudf-如何访问列名

rur96b6h  于 2021-05-31  发布在  Hadoop
关注(0)|答案(0)|浏览(149)

有人请让我知道如何访问简单配置单元自定义项的列名。

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;
import Utils

@Description(name = "Decrypt", value = "Encrypt the Given Column", extended = "SELECT Decrypt('Hello World!');")
public class Encrypt extends UDF {

    private Text result = new Text();

    public Text evaluate(Text str) {
        if (str == null) {
            return null;
        }

        //Access Column Name and pass to the function to get encryption key 
        String secretKey = Utils.getSecretKey(columnName) 
        String encryptedText = AES.encrypt(str.toString(), "randomkey");
        result.set(encryptedText);
        return result;
    }

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题