I have hive script custsales.hql now I want to run it from hive cli as
hive (pract5)> run /user/training/hdfs_location/custsales.hql
but it does not execute. Please guide. I know we can run it from command line with
$ hive -f /home/training/local_location/custsales.hql
but this is not my requirement.
Use source path/to/script command.
Related
I'm trying to create a cronjob in my VM server that run a shell script that upload the apache log to a bigquery table and the script have this assertments:
#!/bin/bash
bq load --project_id=myproject --field_delimiter=" " mylogs.mylogsfont /var/log/apache2/access.log /var/log/apache2/schema_access.txt
rm /var/log/apache2/access.log
/etc/init.dapache2 restart
but the bq load command do not run.
Is there a way to run this command in a shell script?
I've looked thru the web and I found the boto files and gcsfuse but both talks about jobs with the storage and have no metntions to bigquery jobs
I am trying to execute a beeline hql file with the following contents.
INSERT OVERWRITE DIRECTORY "${hadoop_temp_output_dir}${file_pattern}${business_date}" select data from database.${table}
I am executing the script using the following command:
beeline -u "jdbc:hive2://svr.us.XXXX.net:10000/;principal=hive/svr.us.XXXX.net#NAEAST.COM" --hivevar hadoop_temp_output_dir=/tenants/demo/hive/database/ --hivevar file_pattern=sales --hivevar business_date=20180709 -f beeline_test.hql
I see the variables are not getting substituted while they are getting executed in the hive environment. What is the mistake I made here.
Also, how to setup init.hql(for all configurations) and execute this hql file
EDIT:I got the answer: I just used double quotes for the variables and corrected few typos
I am new to Hive and wanted to know how to execute hive commoands directly from .hql file.
As mentioned by #rajshukla4696, both hive -f filename.hql or beeline -f filename will work.
You can also execute queries from the command line via "-e":
hive -e "select * from my_table"
There are plenty of useful command line arguments for Hive that can be found here: Hive Command line Options
hive -f filepath;
example-hive -f /home/Nitin/Desktop/Hive/script1.hql;
Use hive -f filename.hql;
Remember to terminate your command with ;
I am trying to pass command line arguments through the below ,but its not working . Can anybody help me with what I am doing wrong here!
hive -f test2.hql -hiveconf partition=20170117 -hiveconf -hiveconf datepartition=20170120
Pass your arguments before the query file,
hive --hiveconf partition='20170117' --hiveconf datepartition='20170120' -f test2.hql
And use them in your queries in test2.hql like this,
${hiveconf:partition}
Example:
select * from tablename where partition=${hiveconf:partition} and date=${hiveconf:datepartition}
Some alternatives:
1) if using hive command line, you can just elaborate the whole sql command and execute it like:
hive -e <command>
and explicit the parameters as literals.
2) if using beeline (preferred to hive), just append this to the command line:
--hivevar myparam='myvalue'
How can i run multiple sql files from one main sql files in postgres.
For example in oracle
Inside Main.sql i can specify n number of #Child.sql , and then i can run Main.sql to run all child.sql 's .
How can i do this in the postgres.
Thanks!
Pratik
\i is the psql equivalent of the Oracle SQL*Plus # command.
If you're using psql to run the Main.sql script, you can put:
\i path/to/child.sql
... in Main.sql. The difference between this and the EXECUTE SCRIPT command pointed out by Tzury is that there the path in FILENAME would refer to a path on the server's file system, while the \i command refers to a path on the machine running psql.