Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COFirst of all thanks for the answer. I said the same behavior thing because i first created table with EXTERNAL keyword and Location clause and data was loaded in the table from s3 bucket(s3n://logs/july). Then, i created table without EXTERNAL keyword but with Location clause still data was loaded which i didn't expect. I thought it will try to find PATH(s3n://logs/july) in the hdfs. Which won't be there. Hence, nothing will be loaded.
      singulars
    2. COWell, first of all i apologise. But in the past also i have seen you downvoted a person just because he didn't have the enough reputation(50 points) to comment on a question. So, he used the answer window to put his point. Instead of downvoting you could'have told him using comment. And please don't embarrass a person asking to upvote after downvoting. Either at first place don't do it or do the upvote without asking. When it's "JUST ABOUT A DOWNVOTE" why do you dislike people who downvote you.
      singulars
    3. COYou are welcome. And there is absolutely no need to apologise. This is what I have learned over time as a SO user. I really appreciate the standard maintained by folks at SO and try to contribute to it. These are the things which make SO a beautiful place to learn and share. In the process we sometimes have to be a bit strict but that doesn't mean that I have any grudge against you or Arijit banarjee or anybody else. I had faced these things when I was new to SO and never complained about it like this as I respect the way SO works. But it's totally upto an individual.
      singulars
 

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