title: Exact behavior of ADD COLUMN with CASCADE in Hive
body: <p>Suppose the next table:</p>
  
  <pre><code>sch_test.test_cascade
      a    b    c
      -----------
      6    10   1
      6    10   1
      6    10   2
      6    10   2
  </code></pre>
  
  <p>a, b and c are integers and the table is partitioned by c. 
  When I add a column in Hive with CASCADE:</p>
  
  <pre><code>ALTER TABLE sch_test.test_cascade ADD COLUMNS (d int, e int) CASCADE;
  </code></pre>
  
  <p>it returns the next table:</p>
  
  <pre><code>sch_test.test_cascade
  a    b    d    e     c
  -------------------------
  6    10   1    NULL  1    
  6    10   1    NULL  1  
  6    10   2    NULL  2  
  6    10   2    NULL  2
  </code></pre>
  
  <p>That is, the first inserted column (d, in this case) takes the values of the partition column (Note that I've added two columns to show that the second one is NULL). But, if I add a column without CASCADE:</p>
  
  <pre><code>ALTER TABLE sch_test.test_cascade ADD COLUMNS (d int, e int);
  </code></pre>
  
  <p>it returns the next table:</p>
  
  <pre><code>sch_test.test_cascade
  a    b    d       e      c
  ----------------------------
  6    10   NULL    NULL   1
  6    10   NULL    NULL   1
  6    10   NULL    NULL   2
  6    10   NULL    NULL   2
  </code></pre>
  
  <p>That is, both inserted columns are NULL.</p>
  
  <p>I don't understand very well the difference between add a column with CASCADE or RESTRICT, in Hive documentation I can see:</p>
  
  <blockquote>
    <p>The CASCADE|RESTRICT clause is available in Hive 1.1.0. ALTER TABLE
    ADD|REPLACE COLUMNS with CASCADE command changes the columns of a
    table's metadata, and cascades the same change to all the partition
    metadata. RESTRICT is the default, limiting column changes only to
    table metadata.</p>
  </blockquote>
  
  <p>But it isn't clear to me the difference between <em>"cascades the same change to all the partition metadata"</em> and <em>"limiting column changes only to table metadata"</em>. (Does Restrict apply only to one partition and Cascade to all them? The previous example says the opposite). And if that is the reason why the first column inserted (in CASCADE mode) takes the value of the partition column.</p>