<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sankalp Shrivastava on Medium]]></title>
        <description><![CDATA[Stories by Sankalp Shrivastava on Medium]]></description>
        <link>https://medium.com/@sankalp1984?source=rss-97d6a1d0cf14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Sankalp Shrivastava on Medium</title>
            <link>https://medium.com/@sankalp1984?source=rss-97d6a1d0cf14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:39:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sankalp1984/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Are you really repartitioning or not ?]]></title>
            <link>https://medium.com/@sankalp1984/are-you-really-repartitioning-or-not-8aa95a60459e?source=rss-97d6a1d0cf14------2</link>
            <guid isPermaLink="false">https://medium.com/p/8aa95a60459e</guid>
            <category><![CDATA[repartition]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[coalsce]]></category>
            <dc:creator><![CDATA[Sankalp Shrivastava]]></dc:creator>
            <pubDate>Mon, 28 Sep 2026 08:39:23 GMT</pubDate>
            <atom:updated>2026-09-28T08:39:23.262Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. The Core Difference</h3><p>In Apache Spark’s source code, repartition(n) is a wrapper around coalesce(n, shuffle=true), while calling coalesce(n) directly defaults to coalesce(n, shuffle=false).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fu4nBiSiu-aOoERsls-c3A.png" /></figure><h3>2. repartition(n) — Full Shuffle</h3><ul><li>Triggers a <strong>wide transformation</strong>: a full data shuffle across the network, regardless of whether you’re increasing or decreasing partitions.</li><li>Uses a hash partitioner during the shuffle, redistributing data evenly across new partitions — this <strong>eliminates data skew</strong>.</li><li>Can both increase and decrease partition count.</li></ul><h3>3. coalesce(n) — No Shuffle</h3><h3>How it works under the hood</h3><p>Instead of using a hash function to redistribute every row, coalesce keeps existing executors intact and simply groups adjacent partitions together into a smaller number of target partitions.</p><ul><li><strong>No-shuffle mechanics:</strong> If you have 10 partitions and run coalesce(3), Spark doesn&#39;t launch a shuffle stage — it creates 3 new partition &quot;groups&quot; pointing to the original 10 (e.g., New Partition 1 reads from Old Partitions 1–3 on the same machine).</li><li><strong>Decrease-only rule:</strong> coalesce cannot increase partition count. Running coalesce(15) when you have 10 partitions is silently ignored — you stay at 10.</li></ul><h3>The data skew risk</h3><p>Because coalesce doesn&#39;t rebalance data, it can create severe skew.</p><ul><li>4 partitions × 100MB each, coalesce(2) → likely balanced (200MB + 200MB).</li><li>Same 4 partitions on 4 <em>different executors</em>, coalesce(1) → all data gets dragged onto one executor, creating a memory bottleneck while the other three sit idle.</li></ul><h3>When to use it</h3><ul><li><strong>Right before writing output.</strong> If your dataframe has 1,000 partitions, Spark writes 1,000 tiny files. .coalesce(10).write.parquet(...) merges them into 10 clean files without shuffle cost — solving the &quot;small file problem.&quot;</li><li><strong>Not early in a heavy pipeline.</strong> A drastic coalesce early on chokes parallelism, since Spark can push the reduced partition count upstream and force earlier stages to run with fewer tasks.</li></ul><h3>4. Why coalesce Can Cause OOM Errors</h3><p>Using coalesce(1) (or a very small number) right before saving can force a large volume of data onto a handful of executors.</p><ul><li>Since there’s no shuffle, data can’t be evenly redistributed — an oversized parent partition, or several large partitions merged onto one executor, can overflow the JVM heap and crash with an OutOfMemoryError.</li><li>It also collapses upstream parallelism, forcing prior stages to run with fewer tasks and slowing the whole job.</li></ul><h3>Fixes</h3><p><strong>Strategy 1 — Use </strong><strong>repartition for large datasets</strong> Pay the shuffle cost to keep executors balanced:</p><pre># Even distribution across executors prevents OOMs<br>df.repartition(10).write.parquet(&quot;hdfs:///output/path&quot;)</pre><p><strong>Strategy 2 — </strong><strong>repartitionByRange to control file size and ordering</strong> Shuffles data but keeps similar values (e.g., a date column) together, producing uniformly sized files:</p><pre>df.repartitionByRange(10, &quot;date_column&quot;).write.parquet(&quot;hdfs:///output/path&quot;)</pre><p><strong>Strategy 3 — Adaptive Query Execution (AQE), Spark 3.0+</strong> Let Spark dynamically coalesce small partitions at runtime instead of hardcoding numbers:</p><pre>spark.conf.set(&quot;spark.sql.adaptive.enabled&quot;, &quot;true&quot;)<br>spark.conf.set(&quot;spark.sql.adaptive.coalescePartitions.enabled&quot;, &quot;true&quot;)<br># Set target file size (e.g., 128MB)<br>spark.conf.set(&quot;spark.sql.adaptive.advisoryPartitionSizeInBytes&quot;, &quot;134217728&quot;)</pre><h3>5. Choosing the Right Strategy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hXnr34PvM_zjXZS1T9qntA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aa95a60459e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why mirroring, why not shortcut in Microsoft Fabric]]></title>
            <link>https://medium.com/@sankalp1984/why-mirroring-why-not-shortcut-in-microsoft-fabric-9a99d9fa5288?source=rss-97d6a1d0cf14------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a99d9fa5288</guid>
            <dc:creator><![CDATA[Sankalp Shrivastava]]></dc:creator>
            <pubDate>Sun, 20 Sep 2026 13:19:18 GMT</pubDate>
            <atom:updated>2026-09-20T13:19:18.085Z</atom:updated>
            <content:encoded><![CDATA[<p>Quick Decision Rule<br>Use Mirroring when your source is a database and you need performance + resilience. Use Shortcuts when your source is already cloud object storage and you want zero-copy access.</p><p>What is it ?</p><p>Mirroring: continuously replicates data from an external source (like Azure SQL DB, Snowflake, or Cosmos DB) into Fabric’s OneLake as a physical copy, kept in sync in near real-time.</p><p>Shortcuts: are virtual pointers to data stored outside or inside OneLake — the data never moves. Think of it like a symlink; Fabric reads it in place.</p><p>When to Use Mirroring:<br>-&gt; You need fast, reliable analytics and can’t afford query latency to an external system<br>-&gt; Your source is a transactional DB (SQL, Cosmos DB) not optimized for analytical queries<br>-&gt; You want the data available even if the source goes down<br>-&gt; You need full Fabric governance, sensitivity labels, and purview integration on the data<br>-&gt; You’re building a medallion architecture and want the raw layer in OneLake</p><p>When to Use Shortcuts:</p><p>-&gt; Data already lives in ADLS Gen2, S3, or GCS and moving it is wasteful<br>-&gt; You want zero-copy federation — avoid duplication costs<br>-&gt; The data is read-rarely or on-demand (no need for always-hot copy)<br>-&gt; You’re referencing data across Fabric workspaces (cross-workspace shortcuts)<br>-&gt; Source data is already in Delta/Parquet and well-optimized for reads<br>-&gt; You need to share data without copying across teams or domains<br> <br>Pros &amp; Cons Summary<br>Mirroring<br>✅ Best query performance<br>✅ Resilient to source unavailability<br>✅ Full Fabric-native governance<br>❌ Storage costs for the duplicate copy<br>❌ Limited to supported source systems<br>❌ Slight replication lag (not truly real-time)</p><p>Shortcuts</p><p>✅ No storage duplication or cost<br>✅ Always reflects live source data<br>✅ Works with many cloud storage sources<br>❌ Query speed depends on source<br>❌ Source must be reachable at query time<br>❌ Governance is split between Fabric and the source</p><p>Comparision:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*ja8YMssV20WfF3fZ" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a99d9fa5288" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[https://theclouddataarch.github.io/green_-/]]></title>
            <link>https://medium.com/@sankalp1984/https-theclouddataarch-github-io-green-5b06c34d8a44?source=rss-97d6a1d0cf14------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b06c34d8a44</guid>
            <dc:creator><![CDATA[Sankalp Shrivastava]]></dc:creator>
            <pubDate>Sun, 14 Jun 2026 11:13:03 GMT</pubDate>
            <atom:updated>2026-06-14T11:13:03.307Z</atom:updated>
            <content:encoded><![CDATA[<p>That Green μ in Your System Tray Was a Distributed Computing Engine</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b06c34d8a44" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>