简体   繁体   中英

Hive SQL file execution

I am using 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. The extension is sql.
  2. In Edit mode, I wrote some SQL code (use testdb; select * from sometable;)
  3. Saved the changes. In the HDFS terminal entered the following command
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. If I change the file location to "/home/cloudera/sample.sql" then it is invoking Hive and working as expected.

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.

hive -f <filename> command runs local file, not in HDFS.

Check the file is located on the machine on which you are running hive (use 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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