I am running a query via command line and am getting this error.
CMD: hive -e query1.hql
FAILED: ParseException line 1:0 cannot recognize input near 'query1' '.' 'hql'
CREATE TABLE dcarlo.new_table AS
SELECT ma.name, ma.address, ma.state
FROM main_db AS ma
WHERE ma.dt>=20180301 AND ma.dt<=20180331;
Use -f
instead of -e
for running scripts from file.
hive -f query1.hql
usage: hive
-d,--define key=value Variable substitution to apply to Hive commands. e.g. -d A=B or --define A=B
-e "quoted-query-string" SQL from command line
-f filename SQL from files
-H,--help Print help information
-h hostname Connecting to Hive Server on remote host --hiveconf property=value Use value for given property --hivevar key=value Variable substitution to apply to hive commands. e.g. --hivevar A=B
-i filename Initialization SQL file
-p port Connecting to Hive Server on port number
-S,--silent Silent mode in interactive shell
-v,--verbose Verbose mode (echo executed SQL to the console)