<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Add a dynamic variable to a Hive view in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Add-a-dynamic-variable-to-a-Hive-view/m-p/80961#M4680</link>
    <description>I don't think this is supported at the moment.</description>
    <pubDate>Wed, 10 Oct 2018 05:36:29 GMT</pubDate>
    <dc:creator>EricL</dc:creator>
    <dc:date>2018-10-10T05:36:29Z</dc:date>
    <item>
      <title>Add a dynamic variable to a Hive view</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Add-a-dynamic-variable-to-a-Hive-view/m-p/79843#M4679</link>
      <description>&lt;P&gt;I would like to create a Hive view that would would include a dynamic variable that would give different output depending on what was done using the set command&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create view default.view_mikeg_test as&lt;BR /&gt;select * from prod_integration.dim_company where company_code = ${hiveconf:company_code};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This produces an error and will only work if I set the variable company_code first (i.e. set company_code = '7777') and then that value gets imbedded into the view.&amp;nbsp; That's not what I want.&amp;nbsp; I have tried to use single and double quotes around&amp;nbsp;&lt;SPAN&gt;${hiveconf:company_code} as suggested in other forums.&amp;nbsp; There has to be a simple solution to this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 13:42:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Add-a-dynamic-variable-to-a-Hive-view/m-p/79843#M4679</guid>
      <dc:creator>mikeg</dc:creator>
      <dc:date>2022-09-16T13:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add a dynamic variable to a Hive view</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Add-a-dynamic-variable-to-a-Hive-view/m-p/80961#M4680</link>
      <description>I don't think this is supported at the moment.</description>
      <pubDate>Wed, 10 Oct 2018 05:36:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Add-a-dynamic-variable-to-a-Hive-view/m-p/80961#M4680</guid>
      <dc:creator>EricL</dc:creator>
      <dc:date>2018-10-10T05:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Add a dynamic variable to a Hive view</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Add-a-dynamic-variable-to-a-Hive-view/m-p/295255#M217644</link>
      <description>This is old thread, but I have found a workaround, so would like to share here.&lt;BR /&gt;&lt;BR /&gt;Assuming I have a table with with a few partitions:&lt;BR /&gt;&lt;BR /&gt;SHOW PARTITIONS partitioned_table;&lt;BR /&gt;+------------+--+&lt;BR /&gt;| partition |&lt;BR /&gt;+------------+--+&lt;BR /&gt;| p=1 |&lt;BR /&gt;| p=2 |&lt;BR /&gt;| p=3 |&lt;BR /&gt;| p=4 |&lt;BR /&gt;| p=5 |&lt;BR /&gt;+------------+--+&lt;BR /&gt;&lt;BR /&gt;1. create a macro:&lt;BR /&gt;CREATE TEMPORARY MACRO partition_value() '1';&lt;BR /&gt;&lt;BR /&gt;2. create view using the macro:&lt;BR /&gt;CREATE VIEW view_test AS SELECT * FROM partitioned_table WHERE p = partition_value();&lt;BR /&gt;&lt;BR /&gt;3. query the view:&lt;BR /&gt;SELECT * FROM view_test;&lt;BR /&gt;&lt;BR /&gt;4. if you want to update the value returned by the Macro, you need to DROP and CREATE it again:&lt;BR /&gt;&lt;BR /&gt;DROP TEMPORARY MACRO partition_value;&lt;BR /&gt;CREATE TEMPORARY MACRO partition_value() '4';&lt;BR /&gt;&lt;BR /&gt;5. If you exit the session, also need to create it again in the next login, as Macro will be destroyed after session ends.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 May 2020 07:23:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Add-a-dynamic-variable-to-a-Hive-view/m-p/295255#M217644</guid>
      <dc:creator>EricL</dc:creator>
      <dc:date>2020-05-01T07:23:45Z</dc:date>
    </item>
  </channel>
</rss>

