Dataframe.saveAsTable -- need clarifications

Dataframe.saveAsTable -- need clarifications
3.0 1

#1

I have noticed this behaviour with saveAsTable. Please explain why this happens.

case 1:
df=sqlContext.sql(“select * from customers”)
df.write.saveAsTable(“cust”)
This uses parquet format by default. In hive when I query this table, it throws parquet parsing exceptions but displays the results finally

case 2:
df=sqlContext.sql(“select * from customers”)
df.registerTempTable(“tmp”)
sqlContext.sql(“create table cust as select * from tmp”)
This creates a proper table. When I query in hive, I get the results without exceptions.