title: command line arguments in hive ( .hql) files from a bash script
body: <p>I am having a main bash script running several other bash scripts and hql files.  The hql files have hive queries.  The hive queries have a where clause and it is on the date field. I am trying to automate a process and I need the where clause to change based on todays date ( which is obtained from the main bash script).</p>
  
  <p>For example the .hql file looks like this:
  This is <code>selectrows.hql</code></p>
  
  <pre><code>DROP TABLE IF EXISTS tv.events_tmp;
  CREATE TABLE tv.events_tmp
  (   origintime STRING,
   deviceid STRING,
   clienttype STRING,
   loaddate STRING)
   ROW FORMAT DELIMITED FIELDS TERMINATED BY '\u0001'
   LINES TERMINATED BY '\n'
   STORED AS TEXTFILE LOCATION 'hdfs://nameservice1/data/full/events_tmp';
  
  INSERT INTO TABLE tv.events_tmp SELECT origintime, deviceid, clienttype, loaddate FROM tv.events_tmp WHERE origintime &gt;= '2015-11-02 00:00:00' AND origintime &lt; '2015-11-03 00:00:00';
  </code></pre>
  
  <p>Since today is 2015-11-11, i want to be able to pass the <code>date - 9 days</code> and <code>date-8 days</code> to the .hql script from the bash script.  Is there a way to pass these two variable from the bash script to the .hql file.</p>
  
  <p>So the main bash script looks like this:</p>
  
  <pre><code>#!/bin/bash
  # today's date
  prodate=`date +%Y-%m-%d`
  echo $prodate
  dateneeded=`date -d "$prodate - 8 days" +%Y-%m-%d`
  echo $dateneeded
  
  # CREATE temp table
  beeline -u 'jdbc:hive2://datanode:10000/;principal=hive/datanode@HADOOP.INT.BELL.CA' -d org.apache.hive.jdbc.HiveDriver -f /home/automation/tv/selectrows.hql
  echo "created table"
  </code></pre>
  
  <p>thanks in advance.</p>