title: Get column names from Hive to CSV using Airflow hook using python
body: <p>I am using Airflow hiveserver2 hook to get results from Hive table and load into CSV. The hook <code>to_csv</code> function has a parameter '<code>output_headers</code>'. If set to true, it gets column names in the form of <code>tablename.columnname</code> along with data and writes to a CSV file. In the CSV header I just need the column names and need to get rid of the tablename from <code>tablename.columnname</code>. Can I override the parameter somehow to just get column names? Is there any other way to just retrieve column names using <code>HiveServer2Hook</code>?</p>
  
  <p>I have connected to Hive using HiveServer2Hook. I have also executed the hooks <code>to_csv</code> function. I just need to change the format of the column names returned using the function. Here is the link to the hook. You can find the <code>to_csv</code>, <code>get_records</code> and <code>get_results</code> function under <code>HiveServer2Hook</code>.</p>
  
  <pre><code>https://airflow.apache.org/_modules/airflow/hooks/hive_hooks.html
  </code></pre>
  
  <p>I also tried running 'describe tablename' and 'show columns from tablename' for HQL but the hive hook's <code>get_records</code> and <code>get_results</code> function breaks on header issue as the result returned by 'describe' and 'show columns' is not in the expected format.</p>
  
  <p>tried the following:</p>
  
  <pre><code>1) describe tablename;
  2) show columns from tablename;
  </code></pre>
  
  <p>The airflow hook has functions <code>get_records</code> and <code>get_results</code>. Both break on following line when I use above HQL statements.</p>
  
  <pre><code> header = next(results_iter)
  </code></pre>
  
  <p>Is there any other way to get column names, write to <code>CSV</code> and pull data using <code>HiveServer2Hook</code> and <code>Python</code>?</p>