Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When you use <strong>Location</strong> with a <strong>managed</strong> table, its purpose is to create a new directory dedicated to this table, which would otherwise go to the default location, <strong>/user/hive/warehouse/</strong>. So, when you do :</p> <pre><code>create table dummy(id int, value string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '~' STORED AS TEXTFILE LOCATION 's3n://logs/july'; </code></pre> <p>It'll create a new directory called <strong>s3n://logs/july</strong> for the table <strong>dummy</strong> instead of creating a directory <strong>dummy</strong> inside <strong>/user/hive/warehouse/</strong>.</p> <p>Same thing will happen if you use <strong>Location</strong> with an <strong>external</strong> table for a <strong>non-existing</strong> location. While creating an <strong>external</strong> table if you give a directory location which exists then all the files inside this directory will collectively constitute the data of this table. And if the directory does not exists, then you'll see the same behavior as with managed tables, i.e. table will get created with a blank directory at the location same as the location specified by you while issuing the create command. Say, you do :</p> <pre><code>create external table dummy(id int, value string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '~' STORED AS TEXTFILE LOCATION 's3n://logs/july'; </code></pre> <p>If <strong>s3n://logs/july</strong> exists then the table <strong>dummy</strong> will get created having data form the files present under <strong>s3n://logs/july</strong>. If <strong>s3n://logs/july</strong> doesn't exist then immediately after issuing the create command you'll see a brand new directory at this very same location. And if you delete this table, the directory <strong>s3n://logs/july</strong> will remain as it is, blank though(because you had pointed it to a non-existing location while table creation). </p> <p>If you delete a <strong>managed</strong> table, even if it was created with <strong>Location</strong> clause the directory represented by Location will get <strong>deleted</strong>. I don't know how you are getting same behavior in both the cases. Try this and let me know what do you observe.</p> <blockquote> <p>BTW, SO is a place to share knowledge and thoughts with spirit. And not to get hyper or to take stuff personally. If you disagree with somehitng, there is a proper way to put your point. And if it was just about a downvote, just let me know. I'll upvote all your questions and answers.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload