我想使用“LOAD DATA LOCAL INPATH..”在本地机器上导入文件
但是,我不能导入
$ beeline -u jdbc:hive2://example:10000 -e "LOAD DATA LOCAL INPATH 'tmp/file_20161024.dat' OVERWRITE INTO TABLE some_table PARTITION(dt=20161024);"
Connecting to jdbc:hive2://example:10000
Connected to: Apache Hive (version 2.1.0)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Error: Error while compiling statement: FAILED: SemanticException Line 1:23 Invalid path ''tmp/file_20161024.dat'': No files matching path file:/opt/hive/bin/tmp/file_20161024.dat (state=42000,code=40000)
Closing: 0: jdbc:hive2://example:10000
可能是因为文件在本地机器上,我认为它没有被导入。
如何使用本地文件作为导入文件
我使用直线(1.2.1)。
VirtualMachine上有Hiveserver(例子)
谢谢!
更新
我尝试了以下方法。
beeline -u jdbc:hive2://example:10000 -e "LOAD DATA LOCAL INPATH '/Users/asari/workspace/tmp/file_20161024.dat' OVERWRITE INTO TABLE some_table PARTITION(dt=20161024);"
Connecting to jdbc:hive2://example:10000
Connected to: Apache Hive (version 2.1.0)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Error: Error while compiling statement: FAILED: SemanticException Line 1:23 Invalid path ''/Users/asari/workspace/tmp/file_20161024.dat'': No files matching path file:/Users/asari/workspace/tmp/file_20161024.dat (state=42000,code=40000)
Closing: 0: jdbc:hive2://example:10000
最佳答案
只是猜测,但根据您的描述,我会说您指向了错误的位置。
推测您的文件位于“普通”本地目录中。在这种情况下,您可能需要像在以下两个示例之一中那样引用它:
/tmp/file_20161024.dat
/home/asari/tmp/file_20161024.dat
注意开头的/
如果您的文件实际上位于您现在尝试的位置
/opt/hive/bin/tmp/file_20161024.dat
然后请检查该文件是否有任何行,以及访问该文件的权限是什么。 (如果您不确定您需要哪些权限,请将权限设置为完全打开并查看这是否有帮助,但请务必将其设置回去!)
关于hadoop - "LOAD DATA LOCAL INPATH"如何到远程hiveserver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40278144/