title: Where is an Avro schema stored when I create a hive table with 'STORED AS AVRO' clause?
body: <p>There are at least two different ways of creating a hive table backed with Avro data:</p>
  <ol>
  <li><p>Creating a table based on an Avro schema (in this example, stored in hdfs):</p>
  <p>CREATE TABLE users_from_avro_schema
  ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
  STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
  OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
  TBLPROPERTIES ('avro.schema.url'='hdfs:///user/root/avro/schema/user.avsc');</p>
  </li>
  <li><p>Creating a table by specifying hive columns explicitly with <code>STORED AS AVRO</code> clause:</p>
  <p>CREATE TABLE users_stored_as_avro(
  id INT,
  name STRING
  ) STORED AS AVRO;</p>
  </li>
  </ol>
  <p>Am I correct that in the first case the metadata of <code>users_from_avro_schema</code> table are not stored in Hive Metastore, but inferred from the SERDE class reading the avro schema file? Or maybe the table metadata are stored in the Metastore, added on table's creation, but then what is the policy for synchronising hive metadata with the Avro schema? I mean both cases:</p>
  <ol>
  <li>updating table metadata (adding/removing columns) and</li>
  <li>updating Avro schema by changing <code>avro.schema.url</code> property.</li>
  </ol>
  <p>In the second case when I call <code>DESCRIBE FORMATTED users_stored_as_avro</code> there is no <code>avro.schema.*</code> property defined, so I don't know which Avro schema is used to read/write data.  Is it generated dynamically based on the table's metadata stored in the Metastore?</p>
  <p>This <a href="https://books.google.pl/books?id=ZnckCAAAQBAJ&amp;pg=PA210&amp;lpg=PA210&amp;dq=When%20the%20DESCRIBE%20command%20is%20run,%20Hive%20shows%20the%20name%20and%20types%20of%20the%20columns.%20In%20the%20output%20below%20you%20will%20notice%20that%20the%20third%20column%20of%20output%20states%20%E2%80%9Cfrom%20deserializer%E2%80%9D.%20This%20shows%20that%20the%20SerDe%20itself%20returned%20the%20information%20from%20the%20column%20rather%20than%20static%20values%20stored%20in%20the%20metastore.&amp;source=bl&amp;ots=Tlf7mQjyng&amp;sig=gVaRtyA8lfdm7iDQR3SJrIVRI-o&amp;hl=pl&amp;sa=X&amp;ved=0ahUKEwis0un9kJfUAhUFLZoKHbYfBtUQ6AEIKDAA#v=onepage&amp;q=When%20the%20DESCRIBE%20command%20is%20run%2C%20Hive%20shows%20the%20name%20and%20types%20of%20the%20columns.%20In%20the%20output%20below%20you%20will%20notice%20that%20the%20third%20column%20of%20output%20states%20%E2%80%9Cfrom%20deserializer%E2%80%9D.%20This%20shows%20that%20the%20SerDe%20itself%20returned%20the%20information%20from%20the%20column%20rather%20than%20static%20values%20stored%20in%20the%20metastore.&amp;f=false" rel="nofollow noreferrer">fragment</a> of Programming Hive book discusses inferring info about columns from the SerDe class, but on the other hand <a href="https://issues.apache.org/jira/browse/HIVE-4703" rel="nofollow noreferrer">HIVE-4703</a> removes this <code>from deserializer</code> info form columns comments. How can I check then what is the source of column types for a given table (Metastore or Avro schema)?</p>