<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: partitioning concept in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4876323#M13463</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/307948"&gt;@Jeanxyz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, you’re absolutely right. If your Delta table is partitioned by &lt;STRONG&gt;department&lt;/STRONG&gt; but your merge condition is based on &lt;STRONG&gt;employee_id&lt;/STRONG&gt;, then the partitioning doesn’t really help during the merge. Spark will still need to scan all partitions to find the matching employee_id values, because the partition column isn’t part of the predicate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Partitioning only speeds things up when your filter, join, or merge condition includes the partition column itself. For example, a merge or query that filters on &lt;STRONG&gt;department = 'HR'&lt;/STRONG&gt; would benefit immediately, but a merge on employee_id won’t take advantage of department partitions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the general rule is:&lt;BR /&gt;Pick a partition column only if your downstream workloads actually filter or process data using that column. Otherwise, partitioning doesn’t provide much benefit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps — and glad the earlier correction was useful. If this answers your question, please mark it as Accepted Solution &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;– Gopi Krishna&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Nov 2025 16:05:29 GMT</pubDate>
    <dc:creator>Ugk161610</dc:creator>
    <dc:date>2025-11-15T16:05:29Z</dc:date>
    <item>
      <title>partitioning concept</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875767#M13453</link>
      <description>&lt;P&gt;I'm studying Apache Spark concepts, the concept of partitioning got my interest. I would like to check if my understanding below is correct:&lt;/P&gt;&lt;P&gt;The partitioning concept only works by writing the data into files, using pyspark code below:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;df.write \
  .mode("overwrite") \
  .partitionBy("department") \
  .parquet(output_path)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I write data into tables, I am not allowed to partition the data. The code below would throw an error:&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;df.write.mode("overwrite").format("delta").partitionBy("department").saveAsTable("data_withoutpart")&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;So if my understanding is correct,&amp;nbsp; partitioning is not useful in my case at all my data needs to be write into delta tables in the end for use by Power BI reports.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please correct me if I got it wrong or refer me to relevant tutorials.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 14 Nov 2025 15:56:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875767#M13453</guid>
      <dc:creator>Jeanxyz</dc:creator>
      <dc:date>2025-11-14T15:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: partitioning concept</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875813#M13454</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/307948"&gt;@Jeanxyz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Your understanding is close, but there’s one important detail missing: you can partition Delta tables — it just depends on where and how the table is created. The error you’re seeing doesn’t mean Spark doesn’t support partitioning; it usually means the target table already exists without partitions, or Fabric created the table with a different structure than what your write command expects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the table already exists as a non-partitioned Delta table, Spark won’t let you overwrite it with a partitioned version. In that case, you’d have to drop the table first and then recreate it with partitionBy(). But writing a partitioned Delta table itself is completely supported.&lt;/P&gt;&lt;P&gt;Also, even for Power BI scenarios, partitioning can help — especially when your dataset grows and you want faster refresh or more efficient incremental loads. Power BI doesn’t care whether the underlying data is partitioned; it only reads the Delta table through the SQL endpoint or Spark.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in short:&lt;BR /&gt;Partitioning is definitely not useless for Delta tables. The issue comes from trying to overwrite an existing table with a different partition structure. If you create the Delta table fresh with partitionBy(), it will work normally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps. If so, please give a Kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; or mark as Accepted Solution &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;– Gopi Krishna&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2025 16:41:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875813#M13454</guid>
      <dc:creator>Ugk161610</dc:creator>
      <dc:date>2025-11-14T16:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: partitioning concept</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875859#M13455</link>
      <description>&lt;P&gt;You are right. I made a syntax mistake when writing partitioned tables. below is the correct one:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;df2.write.mode(&lt;/SPAN&gt;&lt;SPAN&gt;"overwrite"&lt;/SPAN&gt;&lt;SPAN&gt;).format(&lt;/SPAN&gt;&lt;SPAN&gt;"delta"&lt;/SPAN&gt;&lt;SPAN&gt;).saveAsTable(&lt;/SPAN&gt;&lt;SPAN&gt;"data_withoutpart2"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;partitionBy&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"department"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 14 Nov 2025 17:59:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875859#M13455</guid>
      <dc:creator>Jeanxyz</dc:creator>
      <dc:date>2025-11-14T17:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: partitioning concept</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875860#M13456</link>
      <description>&lt;P&gt;You are right. I made a syntax mistake when writing partitioned tables. below is the correct one:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;df2.write.mode(&lt;/SPAN&gt;&lt;SPAN&gt;"overwrite"&lt;/SPAN&gt;&lt;SPAN&gt;).format(&lt;/SPAN&gt;&lt;SPAN&gt;"delta"&lt;/SPAN&gt;&lt;SPAN&gt;).saveAsTable(&lt;/SPAN&gt;&lt;SPAN&gt;"data_withoutpart2"&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;partitionBy&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"department"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 14 Nov 2025 17:59:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4875860#M13456</guid>
      <dc:creator>Jeanxyz</dc:creator>
      <dc:date>2025-11-14T17:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: partitioning concept</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4876243#M13460</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/307948"&gt;@Jeanxyz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Your understanding is close, but there’s an important detail to clarify. Partitioning &lt;STRONG&gt;does work&lt;/STRONG&gt; when writing Delta tables — it doesn’t only apply to writing files. The issue you hit is just the syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Spark, the partitionBy() method is always part of the &lt;STRONG&gt;writer&lt;/STRONG&gt;, not an argument inside saveAsTable. So your corrected syntax is the right one. When you write:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;df.write \&lt;BR /&gt;.mode("overwrite") \&lt;BR /&gt;.format("delta") \&lt;BR /&gt;.partitionBy("department") \&lt;BR /&gt;.saveAsTable("data_with_partition")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Spark will create a fully valid &lt;STRONG&gt;partitioned Delta table&lt;/STRONG&gt;, and this works perfectly fine with Power BI, Fabric Lakehouse, and SQL endpoint queries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So partitioning is still useful even if your final destination is a Delta table. As long as your table has a natural grouping column with reasonable cardinality (like department, date, region, category, etc.), partitioning can improve performance for large datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your updated example using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;saveAsTable("data_withoutpart2", partitionBy="department")&lt;/P&gt;&lt;P&gt;is also valid — it’s just an alternative syntax that Spark supports.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So yes, your data can be written as Delta &lt;STRONG&gt;and still be partitioned&lt;/STRONG&gt; without any problem. You weren’t running into a conceptual limitation, just a small syntax detail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps. If it does, please give a Kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; or mark as Accepted Solution &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;– Gopi Krishna&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Nov 2025 11:43:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4876243#M13460</guid>
      <dc:creator>Ugk161610</dc:creator>
      <dc:date>2025-11-15T11:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: partitioning concept</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4876321#M13462</link>
      <description>&lt;P&gt;Thanks for clarification,&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/920086"&gt;@Ugk161610&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;One last question: if my delta table is partitioned by 'department' but I'm running a merge query by 'employee_id', the partition won't help in the case. Is that correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Nov 2025 16:01:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4876321#M13462</guid>
      <dc:creator>Jeanxyz</dc:creator>
      <dc:date>2025-11-15T16:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: partitioning concept</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4876323#M13463</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/307948"&gt;@Jeanxyz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, you’re absolutely right. If your Delta table is partitioned by &lt;STRONG&gt;department&lt;/STRONG&gt; but your merge condition is based on &lt;STRONG&gt;employee_id&lt;/STRONG&gt;, then the partitioning doesn’t really help during the merge. Spark will still need to scan all partitions to find the matching employee_id values, because the partition column isn’t part of the predicate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Partitioning only speeds things up when your filter, join, or merge condition includes the partition column itself. For example, a merge or query that filters on &lt;STRONG&gt;department = 'HR'&lt;/STRONG&gt; would benefit immediately, but a merge on employee_id won’t take advantage of department partitions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the general rule is:&lt;BR /&gt;Pick a partition column only if your downstream workloads actually filter or process data using that column. Otherwise, partitioning doesn’t provide much benefit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps — and glad the earlier correction was useful. If this answers your question, please mark it as Accepted Solution &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;– Gopi Krishna&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Nov 2025 16:05:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/partitioning-concept/m-p/4876323#M13463</guid>
      <dc:creator>Ugk161610</dc:creator>
      <dc:date>2025-11-15T16:05:29Z</dc:date>
    </item>
  </channel>
</rss>

