title: How to save Data in HDFS from Spark specifying a user
body: <p>I would like to save a file in HDFS from Spark, I just try using the next line:</p>
  
  <pre><code>df.write.format("com.databricks.spark.csv").save(s"hdfs://hdp.asier.es:8020/assetgroup/$index/1-20170131")
  </code></pre>
  
  <p>But it throws the next error:</p>
  
  <pre><code>Exception in thread "main" org.apache.hadoop.security.AccessControlException: Permission denied: user=agomez, access=WRITE, inode="/assetgroup/1/1-20170131/_temporary/0":hdfs:hdfs:drwxr-xr-x
  </code></pre>
  
  <p>It is evident that the problem is because it tries to connect using the <code>user: agomez</code>, how can I configure to use another user with the adequate permission?</p>