title: Why after creating 5 partitions and 10 buckets, number of data files created at the backend is so high?
body: <p>Below is my code:</p>
  <pre><code>spark.range(1,10000).withColumn(&quot;hashId&quot;,col(&quot;id&quot;)%5).write.partitionBy(&quot;hashId&quot;).bucketBy(10,&quot;id&quot;).saveAsTable(&quot;learning.test_table&quot;)
  </code></pre>
  <p>Spark Configuration:</p>
  <pre><code>./spark-shell --master yarn --num-executors 10 --executor-cores 3 --executor-memory 5
  </code></pre>
  <p><strong>There are 5 partitions and inside each partition, there are 61 files:</strong></p>
  <pre><code>hdfs dfs -ls /apps/hive/warehouse/learning.db/test_table/hashId=0 | wc -l
  61
  </code></pre>
  <p>After creating this table when I checked the backend, it created 305 files + 1 _SUCCESS file.</p>
  <p>Could someone please explain why it is creating 305 files?</p>