简体   繁体   English

Hive SQL 文件执行

[英]Hive SQL file execution

I am using Cloudera Quickview VM 5.10我正在使用 Cloudera Quickview VM 5.10

The following is my implementation which is not working.以下是我的实现,它不起作用。

  1. Created a new file (sample.sql) in "user/hive/warehouse" using Hue.使用 Hue 在“user/hive/warehouse”中创建了一个新文件 (sample.sql)。 The extension is sql.扩展名为 sql。
  2. In Edit mode, I wrote some SQL code (use testdb; select * from sometable;)在编辑模式下,我写了一些 SQL 代码(使用 testdb; select * from sometable;)
  3. Saved the changes.保存更改。 In the HDFS terminal entered the following command在HDFS终端输入如下命令
hive -f /user/hive/warehouse/sample.sql

It says the file not found.它说找不到文件。 If I changed the file location to "/user/cloudera/sample.sql" then also the same issue.如果我将文件位置更改为“/user/cloudera/sample.sql”,那么也是同样的问题。 If I change the file location to "/home/cloudera/sample.sql" then it is invoking Hive and working as expected.如果我将文件位置更改为“/home/cloudera/sample.sql”,那么它正在调用 Hive 并按预期工作。

Seems it is a permission issue.似乎是权限问题。 How to solve it?如何解决? Please help.请帮忙。

It is not clear which file are you trying to execute: in HDFS or local filesystem.目前尚不清楚您要执行哪个文件:在 HDFS 或本地文件系统中。

hive -f <filename> command runs local file, not in HDFS. hive -f <filename>命令运行本地文件,不在 HDFS 中。

Check the file is located on the machine on which you are running hive (use ls -l <path> )检查文件是否位于运行 hive 的机器上(使用ls -l <path>

If you want to run file located in HDFS , you need to load it to local machine first (using hdfs dfs -get ) or use this command:如果要运行位于 HDFS 中的文件,则需要先将其加载到本地计算机(使用hdfs dfs -get )或使用以下命令:

hive -f <(hdfs dfs -cat /path/in_HDFS/sample.sql)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM