<?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>topic Re: How to delete hive tables using datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367028#M275240</link>
    <description>&lt;P&gt;In my sample code the Hive table mycars is deleted in Hive metadata as well as in the HDFS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show the output of the "describe formatted tableName" after you created the Hive table using the DATA Step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the output of the two HDFS LS= should show, that the actual data in HDFS gets deleted.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2017 16:13:04 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2017-06-14T16:13:04Z</dc:date>
    <item>
      <title>How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366903#M275235</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we drop a managed table , Hive deletes the data in the table is my understanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By default, SAS data step option DBCREATE_EXTERNAL is set to NO which means SAS data step using hive libraries like below creates a “managed table”.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://i.stack.imgur.com/uH2HE.png" target="_blank" rel="nofollow noreferrer"&gt;&lt;IMG alt="enter image description here" src="https://i.stack.imgur.com/uH2HE.png" border="0" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using proc sql - drop table / proc delete / proc dataset - delete, the hive metadata is deleted i.e. table structure is dropped from the schema but the underlying HDFS file is not. While running the same data step again (after deletion), i,e. creating the same table in the schema - the number of records ingested is incorrect.&lt;/P&gt;&lt;P&gt;&amp;nbsp; Steps&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a hive table using SAS data step and note the no of rows.&lt;/LI&gt;&lt;LI&gt;Drop the table using proc sql delete / proc dataset delete.&lt;/LI&gt;&lt;LI&gt;Run the create table step again.&lt;/LI&gt;&lt;LI&gt;Count the number of rows.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Source : &lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n12r2tbfrrrsgdn1fa4ufw8vb79f.htm" target="_blank" rel="nofollow noreferrer"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n12r2tbfrrrsgdn1fa4ufw8vb79f.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 11:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366903#M275235</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-14T11:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366950#M275236</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no knowledge about hive.&lt;/P&gt;&lt;P&gt;Nevertheless I would try different ways of deleting that table and see if it resolves the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;drop&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; hive_lib.ext_test_default;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;or &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;datasets&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;lib&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;=hive_lib &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;nolist&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;delete&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ext_test_default;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;quit&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;or: looks like you only need to empty your table and not deleting it entirely&amp;nbsp;right?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; hive_lib.ext_test_default;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;if&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; hive_lib.ext_test_default;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;delete&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 13:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366950#M275236</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-06-14T13:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366976#M275237</link>
      <description>&lt;P&gt;As mentioned in the steps above, proc delete / proc dataset - delete / proc sql drop table - none of them are deleting the underlying hdfs file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 14:22:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366976#M275237</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-14T14:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366977#M275238</link>
      <description>&lt;P&gt;By default, tables created in Hive are managed tables. so if you delete a table from SAS using the methods you mentioned also the actual data in the HDFS is deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a code sample that will create a Hive table, show the metadata information from Hive, list the contents of the HDFS directory, delete, show HDFS directory info. You need to set the appropriate macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME ahd HADOOP PORT=&amp;amp;hd_port SERVER="&amp;amp;hd_server" SCHEMA=&amp;amp;hd_schema;

proc delete data=ahd.mycars;
run;

data ahd.mycars;
  set sashelp.cars;
run;

proc sql;
  connect to hadoop (
    PORT=&amp;amp;hd_port SERVER="&amp;amp;hd_server" SCHEMA=&amp;amp;hd_schema
  );

  select * from connection to hadoop (
    describe formatted mycars
  );
  disconnect from hadoop;
quit;

options set=SAS_HADOOP_RESTFUL 1;
proc hadoop;
  hdfs ls="&amp;amp;hive_db_location/mycars" ;
run;
options set=SAS_HADOOP_RESTFUL 0;

proc delete data=ahd.mycars;
run;

options set=SAS_HADOOP_RESTFUL 1;
proc hadoop;
  hdfs ls="&amp;amp;hive_db_location" ;
run;
options set=SAS_HADOOP_RESTFUL 0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jun 2017 14:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/366977#M275238</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-14T14:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367018#M275239</link>
      <description>&lt;P&gt;Can you please replace the describe formatted to select count(*) from the table and note the result from your second run ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you are using the sashelp.cars dataset - the total should always be 428 but from the second run you will see the count getting increased.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a nutshell, it will be appending the entire saslhelp.cars from the second run since the underlying HDFS file is not deleted.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 15:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367018#M275239</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-14T15:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367028#M275240</link>
      <description>&lt;P&gt;In my sample code the Hive table mycars is deleted in Hive metadata as well as in the HDFS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show the output of the "describe formatted tableName" after you created the Hive table using the DATA Step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the output of the two HDFS LS= should show, that the actual data in HDFS gets deleted.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 16:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367028#M275240</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-14T16:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367218#M275241</link>
      <description>&lt;P&gt;The &lt;A href="https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html#File_Deletes_and_Undeletes" rel="noreferrer" target="_blank"&gt;Official documentation&lt;/A&gt; of Hadoop reads :&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The deletion of a file causes the blocks associated with the file to be freed. Note that &lt;STRONG&gt;there could be an appreciable time delay&lt;/STRONG&gt; between the time a file is deleted by a user and the time of the corresponding increase in free space in HDFS.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 04:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367218#M275241</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-06-15T04:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367284#M275243</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hivlib.ext_test_default_ak;
	set sashelp.cars;
run;

proc sql;
	connect to hadoop(server="&amp;amp;hive_server" 
		port=&amp;amp;hive_port 
		schema="&amp;amp;hive_schema" 
		properties="hive.warehouse.data.skiptrash=true;" 
		hdfs_tempdir="&amp;amp;hdfs_tmpdir" 
		uri="jdbc:hive2://&amp;amp;hive_server:&amp;amp;hive_port/&amp;amp;hive_schema;transportMode=http;httpPath=cliservice;principal=&amp;amp;principal?hive.fetch.task.conversion=minimal;hive.fetch.task.conversion.threshold=1;hive.exec.scratchdir=&amp;amp;hdfs_tmpdir;");
		select * from connection to hadoop (
		select count(*) from ext_test_default_ak
		);
/*		select * from connection to hadoop (*/
/*		dfs -ls="&amp;amp;hive_db_location/ext_test_default_ak"*/
/*		);*/
		select * from connection to hadoop (
		describe formatted ext_test_default_ak
		);
	disconnect from hadoop;
quit;

proc datasets lib=hivlib nodetails nolist;
	delete ext_test_default_ak;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not able to run dfs commands due to permissions but using unix hdfs commands I can see the hdfs file for the table and it is not gettting deleted. Table is dropped fine from the hive metadata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hdfs dfs -ls -h hdfs://location/ext*&lt;BR /&gt;Found 3 items&lt;BR /&gt;-rw-r--r--&amp;nbsp;&amp;nbsp;&amp;nbsp; 39.3 K 2017-06-15 10:05 ext_test_default_ak/sasdata-2017-06-15-10-05-07-268-e-00007.dlv&lt;BR /&gt;-rw-r--r--&amp;nbsp;&amp;nbsp;&amp;nbsp; 39.3 K 2017-06-15 10:12 ext_test_default_ak/sasdata-2017-06-15-10-12-56-846-e-00008.dlv&lt;BR /&gt;-rw-r--r--&amp;nbsp;&amp;nbsp;&amp;nbsp; 39.3 K 2017-06-15 10:24 ext_test_default_ak/sasdata-2017-06-15-10-24-08-882-e-00009.dlv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check the two attachments. First run has 428 observations and even after deletion, the second run (after 5 mins) has 856 observations.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13954i4B3DCC5FA1BFDC4E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="first_run_Capture.PNG" title="first_run_Capture.PNG" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13955i09776188C0FB72F1/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="second_run_Capture.PNG" title="second_run_Capture.PNG" /&gt;</description>
      <pubDate>Thu, 15 Jun 2017 09:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367284#M275243</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-15T09:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367286#M275244</link>
      <description>&lt;P&gt;I have run in 5 minutes interval and still the same issue. Matter of fact it is just 33K. Since the hdfs file is not getting deleted and only the table structure - the next datastep run appends both files into the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check my last reply with code and screenshots. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 09:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367286#M275244</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-15T09:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367288#M275245</link>
      <description>&lt;P&gt;Looks strange what happens if you execute the drop table directly through SQL passthrough using&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;drop table &amp;lt;tablename&amp;gt; purge&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 09:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367288#M275245</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-15T09:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367293#M275246</link>
      <description>&lt;P&gt;Same outcome. I have used the purge option and there is no error / warning. Just a note that "No rows were selected".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have even set the skipTrash to true in libname properties.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 09:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367293#M275246</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-15T09:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367297#M275247</link>
      <description>&lt;P&gt;did you use&lt;/P&gt;
&lt;PRE&gt;execute (drop table ...) by hadoop&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 09:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367297#M275247</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-15T09:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367301#M275248</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hivlib.ext_test_default_ak;
	set sashelp.cars;
run;

proc sql;
	connect to hadoop(server="&amp;amp;hive_server" 
		port=&amp;amp;hive_port 
		schema="&amp;amp;hive_schema" 
		properties="hive.warehouse.data.skiptrash=true;" 
		hdfs_tempdir="&amp;amp;hdfs_tmpdir" 
		uri="jdbc:hive2://&amp;amp;hive_server:&amp;amp;hive_port/&amp;amp;hive_schema;transportMode=http;httpPath=cliservice;principal=&amp;amp;principal?hive.fetch.task.conversion=minimal;hive.fetch.task.conversion.threshold=1;hive.exec.scratchdir=&amp;amp;hdfs_tmpdir;");
		select * from connection to hadoop (
		select count(*) from ext_test_default_ak
		);
		select * from connection to hadoop (
		describe formatted ext_test_default_ak
		);
		execute (
		drop table ext_test_default_ak purge
		)by hadoop;
	disconnect from hadoop;
quit;

proc datasets lib=hivlib nodetails nolist;
	delete ext_test_default_ak;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, Same outcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used proc delete / proc dataset - delete / proc sql - drop table / pass through - execute (drop table with purge option).&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 10:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367301#M275248</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-15T10:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367305#M275249</link>
      <description>&lt;P&gt;Sorry corrected a typo and sql pass through with purge option deleted both metadata and hdfs file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But using the datastep (without sql pass thorugh) - using proc sql drop / proc delete / proc dataset delete - still the same issue where metadata in hive warehouse is deleted but not the underlying hdfs file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The replace option in the datastep is&amp;nbsp;not supported either for hive libraries afaik.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 10:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367305#M275249</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-15T10:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367620#M275250</link>
      <description>&lt;P&gt;What happens if you do the drop table without the purge? Again using SQL Passthrough&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the follwoing options to see which HiveQL is passed from to SAS to Hive:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options
  sastrace=",,,d"
  sastraceloc=saslog
  nostsuffix
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 07:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367620#M275250</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-16T07:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367656#M275251</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Without purge&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;execute (&lt;BR /&gt;41&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;drop table ext_test_default_ak&lt;BR /&gt;42&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;)by hadoop;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;HADOOP_26: Executed: on connection 2&lt;BR /&gt;drop table ext_test_default_ak&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;43&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;disconnect from hadoop;&lt;BR /&gt;44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;With purge&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;execute (&lt;BR /&gt;41&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;drop table ext_test_default_ak purge&lt;BR /&gt;42&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;)by hadoop;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;HADOOP_26: Executed: on connection 2&lt;BR /&gt;drop table ext_test_default_ak purge&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;43&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;disconnect from hadoop;&lt;BR /&gt;44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 10:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367656#M275251</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-16T10:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367682#M275252</link>
      <description>&lt;P&gt;Thanks for the feedback, since you use SQL pass through, we see exactly the same statement from the trace as the one you have written.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What impact did the "drop table ..." without the purge option have on the HDFS file, was it deleted as well?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you use the Proc DELETE data=, a DROP TABLE statement will be passed to Hive.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 11:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367682#M275252</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-16T11:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367768#M275253</link>
      <description>&lt;P&gt;* proc delete / proc dataset - delete / proc sql drop table - none of them are deleting the underlying hdfs file *&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What I think is, there is an issue whe using proc sql -drop / proc delete / proc dataset with hive tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My theory is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to Hive documentation.&lt;BR /&gt;If you drop an EXTERNAL TABLE, the Hive engine will drop the table metadata and does not delete the hdfs data.&lt;/P&gt;&lt;P&gt;If you drop a MANAGED TABLE, the Hive engine will drop the table metadata and deletes the hdfs data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to SAS documentation.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="xis-keyword"&gt;DBCREATE_TABLE_EXTERNAL=&lt;/SPAN&gt;YES -&amp;gt; creates an &lt;SPAN class="xis-userSuppliedValue"&gt;external&lt;/SPAN&gt; table—one that is stored outside of the Hive warehouse.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="xis-keyword"&gt;DBCREATE_TABLE_EXTERNAL=&lt;/SPAN&gt;NO&amp;nbsp;&amp;nbsp; -&amp;gt; creates a &lt;SPAN class="xis-userSuppliedValue"&gt;managed&lt;/SPAN&gt; table—one that is managed within the Hive warehouse.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source : &lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0k3b8dw0vz3jxn1jjqouodozcqc.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0k3b8dw0vz3jxn1jjqouodozcqc.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By default the &lt;SPAN class="xis-keyword"&gt;DBCREATE_TABLE_EXTERNAL is &lt;/SPAN&gt;NO, which means SAS will create a managed table i.e. Deleting the table should drop both metadata and deletes the hdfs data. But I think this is not the case (at least in my case), the default option is dropping the hive table structure and &lt;STRONG&gt;not&lt;/STRONG&gt; the underlying hdfs file using sas procs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works using "sql pass through" using "purge" option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note : In the libname, I also have hive.warehouse.data.skipTrash to true and also tried setting the &lt;SPAN class="xis-keyword"&gt;DBCREATE_TABLE_EXTERNAL=&lt;/SPAN&gt;NO in the data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 15:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/367768#M275253</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-16T15:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/368174#M275254</link>
      <description>&lt;P&gt;So you are saying:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;drop table tableName purge&lt;/FONT&gt;, does delete the Hive metadata as well as the HDFS file&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;drop table tableName&lt;/FONT&gt;, does delete the Hive metadata, BUT NOT the HDFS file&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 07:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/368174#M275254</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-19T07:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete hive tables using datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/368253#M275255</link>
      <description>&lt;P&gt;&lt;STRONG&gt;SQL - Pass through&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----------------------------&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Case 1 : &lt;FONT face="Courier New"&gt;drop table tableName purge -- deletes &lt;/FONT&gt;the Hive metadata &lt;STRONG&gt;as well as&lt;/STRONG&gt; the HDFS file. (&lt;STRONG&gt;WORKS !&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;Case 2 : &lt;FONT face="courier new,courier"&gt;drop table tableName -- &lt;/FONT&gt;deletes the Hive metadata&amp;nbsp;but not the HDFS file. (&lt;STRONG&gt;NOT WORKING&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data Step&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;--------------&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Case 1 : &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data hive_lib.table;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set sashelp.cars;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Proc delete&amp;nbsp; -- Deletes the hive metadata but not the HDFS file.(&lt;STRONG&gt;NOT WORKING&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;2. Proc dataset&amp;nbsp; delete -- Deletes the hive metadata but not the HDFS file.(&lt;STRONG&gt;NOT WORKING&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;3. Proc SQL&amp;nbsp; drop table -- Deletes the hive metadata but not the HDFS file.(&lt;STRONG&gt;NOT WORKING&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Case&amp;nbsp;2 : &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table hive_lib.table as select * from &lt;/STRONG&gt;&lt;STRONG&gt;sashelp.cars;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Proc delete&amp;nbsp; -- Deletes the hive metadata but not the HDFS file.(&lt;STRONG&gt;NOT WORKING&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;2. Proc dataset&amp;nbsp; delete -- Deletes the hive metadata but not the HDFS file.(&lt;STRONG&gt;NOT WORKING&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;3. Proc SQL&amp;nbsp; drop table -- Deletes the hive metadata but not the HDFS file.(&lt;STRONG&gt;NOT WORKING&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note : In all the above cases, skipTrash is set in hive library. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Summary : In Data step - both in case 1 and 2 - I am not able to delete the underlying HDFS file.&amp;nbsp; I can suceessfully drop hive table in hive cli / beeline so no permission issue.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 13:56:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-hive-tables-using-datastep/m-p/368253#M275255</guid>
      <dc:creator>AK23</dc:creator>
      <dc:date>2017-06-19T13:56:45Z</dc:date>
    </item>
  </channel>
</rss>

