I am aware that it is possible to specify parameters for a hive query/script like so:
>hive -e "USE uk_pers_dev;set hive.cli.print.header=true;CREATE TABLE IF NOT EXISTS ${hiveconf:tablename} (mycol int);SELECT * FROM ${hiveconf:tablename};" -hiveconf tablename=mytable;
However what I would like to do is specify a default parameter value within my hive script that should be used in case no value is passed from the command-line. Is that possible?
OK I have a table called airports
name: string country: string area_code int
in HIVE I do
works for me.
JT
Could you use
SET myvar = "Hello World"
inside your hive script do
SET myvar = COALESCE(${hiveconf:myvar},"Default");
SELECT * FROM MyTable WHERE MyColumn = ${hiveconf:myvar};
OR
SELECT * FROM MyTable WHERE MyColumn = COALESCE(${hiveconf:myvar},"Default");
OK So take the logic away from Hive
In POSH or a cmd file
Maybe look at that as a wrapper.
Allan