java - Hive:为什么 CTAS 不能读取文件而选择查询可以
问题描述
我已将文件放在/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
解决方案
推荐阅读
- python - Pandas - 合并两列
- r - 在 Shiny 应用程序中显示 ggplot2 图表
- tabbing - 不止一次使用 jQuery 和 CSS 的选项卡式内容不起作用
- java - 如何在 IntelliJ 中使用 Gradle 设置 Amazon Polly 开发工具包
- python - 在python中设置循环迭代器变量= 0
- vba - 当变量可以取字符串或数字的值(单/双)时,VBA 对变量进行标注
- c# - 从 web-api 返回文件导致错误“找不到文件”
- c# - C# 中的 OleDbConnection SQL Server 数据库
- ios - 如何在 MPSNNGraph 的输入端使用两个 MPSImage
- silverstripe - Silverstripe 上传字段的默认图片