<?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: Create empty table if no data in source table in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219821#M66783</link>
    <description>&lt;P&gt;@Simon, I tried the same scenario in Spark-shell with Hive.. I am able to create orc table from another external table.. Attaching snap. &lt;A href="https://community.cloudera.com/legacyfs/online/attachments/31387-createasselect.png"&gt;createasselect.png&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Can you pls provide logs or error displayed while "create as select" ?&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2017 14:18:48 GMT</pubDate>
    <dc:creator>nramanaiah</dc:creator>
    <dc:date>2017-08-18T14:18:48Z</dc:date>
    <item>
      <title>Create empty table if no data in source table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219816#M66778</link>
      <description>&lt;PRE&gt;Hi i am doing some ETL with hiveQl
I am creating new tables based on external hive tables, but then the external hive table is empty no empty table is created. How do i create a empty table if there is no records in the external table om selecting from.
I am running the code from NIFI hiveql processor in nifi 2.x not supporting multiple hql statement. A oneliner would be beautiful


Her is a example 
DROP TABLE IF EXISTS myname_t1;

CREATE TABLE myname_t1 STORED AS ORC  LOCATION '/archive/data/myname/T1'AS

 select*,INPUT__FILE__NAME ETL_FILENAME from myname;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 15:50:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219816#M66778</guid>
      <dc:creator>simon_jespersen</dc:creator>
      <dc:date>2017-08-17T15:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create empty table if no data in source table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219817#M66779</link>
      <description>&lt;P&gt;Hi I´m not sure if I understand this exactly but I´m going to try to answer it.&lt;BR /&gt;&lt;BR /&gt;If you want to create an empty table from an empty external table the only thing you have to do is:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create external table&lt;UL&gt;&lt;LI&gt;create external table rangerhdfslog(j string) stored as textfile location '/ranger/audit/hdfs';&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Create table from external table&lt;UL&gt;&lt;LI&gt;create table rangerhdfslog2 as select * from rangerhdfslog;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So, that should work with any major issue.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 20:43:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219817#M66779</guid>
      <dc:creator>palgaba</dc:creator>
      <dc:date>2017-08-17T20:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create empty table if no data in source table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219818#M66780</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/31189/palgaba.html" nodeid="31189"&gt;@palgaba&lt;/A&gt; You mean with&lt;STRONG&gt;out &lt;/STRONG&gt;major issue?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 21:19:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219818#M66780</guid>
      <dc:creator>balavignesh_nag</dc:creator>
      <dc:date>2017-08-17T21:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create empty table if no data in source table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219819#M66781</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/12437/balavigneshnagamuthuvenkatesan.html" nodeid="12437"&gt;@Bala Vignesh N V&lt;/A&gt; is correct.  &lt;/P&gt;&lt;PRE&gt;create table &amp;lt;new table&amp;gt; as&lt;BR /&gt;select * from &amp;lt;external_table&amp;gt;;&lt;/PRE&gt;&lt;P&gt;Will create a new empty table with the same as the external columns. The external table has to be created prior to executing the CTAS.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 22:04:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219819#M66781</guid>
      <dc:creator>SQLShaw</dc:creator>
      <dc:date>2017-08-17T22:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create empty table if no data in source table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219820#M66782</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/12437/balavigneshnagamuthuvenkatesan.html" nodeid="12437"&gt;@Bala Vignesh N V&lt;BR /&gt;&lt;/A&gt;, yes sorry that is what I meant.</description>
      <pubDate>Thu, 17 Aug 2017 22:35:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219820#M66782</guid>
      <dc:creator>palgaba</dc:creator>
      <dc:date>2017-08-17T22:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create empty table if no data in source table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219821#M66783</link>
      <description>&lt;P&gt;@Simon, I tried the same scenario in Spark-shell with Hive.. I am able to create orc table from another external table.. Attaching snap. &lt;A href="https://community.cloudera.com/legacyfs/online/attachments/31387-createasselect.png"&gt;createasselect.png&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Can you pls provide logs or error displayed while "create as select" ?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 14:18:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219821#M66783</guid>
      <dc:creator>nramanaiah</dc:creator>
      <dc:date>2017-08-18T14:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create empty table if no data in source table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219822#M66784</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/37152/nramanaiah.html" nodeid="37152"&gt;@nramanaiah&lt;/A&gt;Hi, yes i found out the same,it seems to be happening when running hive through JDBC and ODBC. My problem is that i am running this in NIFI PutHiveQL processor &lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 15:19:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Create-empty-table-if-no-data-in-source-table/m-p/219822#M66784</guid>
      <dc:creator>simon_jespersen</dc:creator>
      <dc:date>2017-08-18T15:19:17Z</dc:date>
    </item>
  </channel>
</rss>

