我已将文件放在/hadoop/yarn/local/usercache/root/test_abspath
并想使用我的 UDF 读取第一行。当我使用它运行它时,select test('ABCD','ABCD');
我可以读取该文件,但是当我尝试使用它时Create table as test_tb select test(name,'ABCD') from another_table
它失败了。在第二种情况下f1.exist() was true
,但f1.canRead() was false
我尝试通过 chmod 777 更改读写权限,但没有成功。
读取文件的Java代码如下:
public class config {
public static final String confFilePath = "/hadoop/yarn/local/usercache/root/test_file
public static void init(){
BufferedReader br;
try {
File f1 = new File(confFilePath);
if (f1.exists())
{ if (f1.canRead()){
br = new BufferedReader( new FileReader( confFilePath ));
String line;
line = br.readLine();
str = line;
logger.info("inside init");
}
else{
str = "can't read";
}
}
如果select test('ABCD','ACBD')
它成功读取 test_file 的第一行,Create table as test_tb select test(name,'ABCD') from another_table
则返回can't read
字符串。
编辑:如果这是关于添加 serde.jar 那么请重定向我以正确下载 jar。HDP 沙盒版本 2.6.5