在直线中添加本地文件(Hive)

时间:2017-02-27 22:08:57

标签: apache-hive beeline

我试图通过Beeline客户端添加本地文件,但是我一直遇到一个问题,它告诉我文件不存在。

[test@test-001 tmp]$ touch /tmp/m.py
[test@test-001 tmp]$ stat /tmp/m.py 
  File: ‘/tmp/m.py’
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d  Inode: 34091464    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1036/ test)   Gid: ( 1037/ test)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2017-02-27 22:04:06.527970709 +0000
Modify: 2017-02-27 22:04:06.527970709 +0000
Change: 2017-02-27 22:04:06.527970709 +0000
 Birth: -
[test@test-001 tmp]$ beeline -u jdbc:hive2://hs2-test:10000/default -n r-zubis
Connecting to jdbc:hive2://hs2-test:10000/default
Connected to: Apache Hive (version 1.2.1.2.3.0.0-2557)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1 by Apache Hive
0: jdbc:hive2://hs2-test:10000/def> ADD FILE '/tmp/m.py';
Error: Error while processing statement: '/tmp/m.py' does not exist (state=,code=1)
0: jdbc:hive2://hs2-test:10000/def> 

问题是什么?

2 个答案:

答案 0 :(得分:2)

您只能在运行HiveServer2的框中添加文件。 (我需要删除引号)我是通过Cloudera的博客评论找到的。不知道为什么这不在Beeline文档中。

答案 1 :(得分:2)

如果像我一样,你被困在HiveServer2远程运行的位置,beeline会让你从HDFS加载文件,

hdfs fs -put /tmp/m.py

然后

beeline> add file hdfs:/user/homedir/m.py;