title: Permission denied when using SPARK dataframes' method "saveAsTable"
body: <p>I´m using Spark 1.3 and I´m trying to generate a table from one RDD. This is the pseudo-code:</p>
  
  <pre><code>val sc = new org.apache.spark.SparkContext(conf)
  val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)
  import sqlContext.implicits._
  
  val rdd1=sc.textFile(path_1).map(........) // RDD[(string,Double)]
  val rdd2=sc.textFile(path_2).map(........) // RDD[(string,Double)]
  val rdd_join=rdd1.fullOuterJoin(rdd2)      // RDD[String,(Option(Double),Option(Double))) 
  val rdd_get = rdd_join.map(....}           // RDD[(String,Double,Double)]
  rdd_get.toDF().saveAsTable("database.tablename")
  </code></pre>
  
  <p>When running this code I´m getting the permissions error:</p>
  
  <p>org.apache.hadoop.security.AccessControlException: Permission denied: user=XXXXXXXX, access=WRITE, inode="/user/hive/warehouse":hive:hive:drwxrwx--x:user:hive:rwx,group::---,group:hive:rwx</p>
  
  <p>If I create the table as:</p>
  
  <pre><code>  rdd_get.toDF().registerTempTable("rdd_get_temp")
    sqlContext.sql("CREATE TABLE database.tablename AS SELECT * FROM rdd_get_temp")
  </code></pre>
  
  <p>Then It works and creates the table. It looks like saveAsTable() is trying to use my user to write into "/user/hive/warehouse" (this is forbiden by Kerberization) while, sqlContext.sql uses properly user "hive" to do it.</p>
  
  <p>Am I right?? Is this a bug?? Does it work in newer spark versions?</p>
  
  <p>Thanks all.</p>