<?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 Avinash Ghanekar on Medium]]></title>
        <description><![CDATA[Stories by Avinash Ghanekar on Medium]]></description>
        <link>https://medium.com/@avinash.a.ghanekar?source=rss-efc5d4ea4ef0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*scGECtHg4X0BTEgZK8usCA.jpeg</url>
            <title>Stories by Avinash Ghanekar on Medium</title>
            <link>https://medium.com/@avinash.a.ghanekar?source=rss-efc5d4ea4ef0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:09:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@avinash.a.ghanekar/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[Databricks lakeflow declarative pipeline: One DAG, one schedule, one failure surface: why it need…]]></title>
            <link>https://medium.com/@avinash.a.ghanekar/databricks-lakeflow-declarative-pipeline-one-dag-one-schedule-one-failure-surface-why-it-need-fc325dae19d5?source=rss-efc5d4ea4ef0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc325dae19d5</guid>
            <category><![CDATA[data-architecture]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[databricks-lakeflow]]></category>
            <dc:creator><![CDATA[Avinash Ghanekar]]></dc:creator>
            <pubDate>Sun, 08 Nov 2026 17:54:48 GMT</pubDate>
            <atom:updated>2026-11-08T17:54:48.689Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Databricks lakeflow declarative pipeline: One DAG, one schedule, one failure surface: why it need splitting</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d-Fnj8HmycAL7HLmq9oxyw.png" /></figure><h3><em>Why a single pipeline turns 150 table configs into one DAG, one schedule and one failure surface, and how to fix it.</em></h3><p>This post is for data analysts and engineers who build or use metadata-driven pipelines on Databricks. You will learn why loading every table config into one Lakeflow Declarative Pipeline gets hard to run, and how to split the work into grouped pipelines without rewriting your framework.</p><h3>The setup</h3><p>A metadata-driven framework stores one config per table. A typical config looks like this:</p><p>yaml</p><pre># configs/sales_orders.yaml<br>target: silver.sales_orders<br>source: bronze.sales_orders<br>group: hourly</pre><p>Now picture 150 files like this one, all loaded by a single pipeline. That works at first. Then the problems start.</p><h3>What one pipeline does with 150 configs</h3><p>A pipeline builds one dependency graph, called a DAG, from every table defined in it. One run of that pipeline is an update. Think of a kitchen with one order ticket: every dish goes on the same ticket and is cooked together.</p><p>At the start of an update, the pipeline finds all defined tables and views and checks them for errors such as invalid column names, missing dependencies and syntax errors. A typo in one config is therefore found in the same update as the other 149 tables. <a href="https://docs.databricks.com/aws/en/ldp/updates">databricks</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lIWAPICmGGdbxQ49K8oZgA.png" /></figure><h3>Problem 1: every table shares one schedule</h3><p>A sales table needs a refresh every hour. A finance table needs one every night. In a single pipeline, both refresh in the same update. Community guidance says a pipeline is the unit of refresh, so per-table schedules inside one pipeline are not supported. <a href="https://community.databricks.com/t5/data-engineering/adhoc-table-refresh-in-lakeflow-spark-declarative-pipelines-sdp/m-p/160174">databricks</a></p><h3>Problem 2: selective refresh is a manual tool</h3><p>You can refresh only chosen tables, or only the failed ones. The API accepts refresh_selection and full_refresh_selection. This helps with recovery and debugging. It does not replace a schedule, because someone has to choose the tables each time. <a href="https://learn.microsoft.com/lb-lu/azure/databricks/ldp/updates">microsoft</a><a href="https://docs.databricks.com/aws/en/ldp/updates">databricks</a></p><h3>Problem 3: limits arrive earlier than expected</h3><p>A pipeline that lists files individually has a limit of 100 source files, or 50 entries when you include folders. One file per config reaches that limit quickly. <a href="https://docs.databricks.com/gcp/en/ldp/limitations">databricks</a></p><h3>The fix: one codebase, several pipelines</h3><p>Keep the framework. Add the group field from the example above, and have each pipeline load only its own group:</p><p>python</p><pre># Fragment: runs inside the pipeline&#39;s source file<br>group = spark.conf.get(&quot;pipeline.group&quot;)<br>configs = [c for c in all_configs if c[&quot;group&quot;] == group]</pre><p>Then define one pipeline per group in your Databricks Asset Bundle:</p><p>yaml</p><pre>resources:<br>  pipelines:<br>    sales_hourly:<br>      configuration:<br>        pipeline.group: hourly<br>    sales_nightly:<br>      configuration:<br>        pipeline.group: nightly</pre><p>Splitting needs one rule: a dataset can be defined only once across pipelines, with an exception for streaming tables fed by append flows. Every table must belong to exactly one pipeline. <a href="https://learn.microsoft.com/en-us/Azure/databricks/ldp/limitations">microsoft</a></p><p>Databricks documents the same pattern for dlt-meta: tables are grouped into pipelines in the metadata, so you generate the number of pipelines you need. That project is a Databricks Labs project, offered without Databricks support or SLAs, so treat it as a reference, not a dependency. <a href="https://docs.databricks.com/gcp/en/ldp/developer/dlt-meta">databricksdatabricks</a></p><h3>How to choose groups</h3><p>Start with refresh frequency, because it solves Problem 1 directly. Then split further if you need to:</p><ul><li><strong>Refresh frequency:</strong> hourly, nightly, weekly.</li><li><strong>Domain or source system:</strong> a failure stays inside one business area.</li><li><strong>Layer:</strong> bronze, silver, gold.</li></ul><h3>Check your work</h3><p>Open each pipeline’s graph in the Databricks UI. You should see only the tables from that pipeline’s group. Add up the tables across all pipelines. The total should match your config count, with no table listed twice.</p><h3>Next steps</h3><p>Use a Lakeflow Job to schedule each pipeline and order the dependencies between them. Keep selective refresh for recovery.</p><p>If you read these tables as an analyst, the effect is freshness. Your key dashboard table no longer waits for the same run as rarely used tables, and a broken config delays only its own group.</p><p><strong>Rule of thumb:</strong> one pipeline per refresh schedule and ownership boundary, not one per company.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc325dae19d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Vault vs Traditional Data Models: A Pragmatic Comparison]]></title>
            <link>https://medium.com/@avinash.a.ghanekar/data-vault-vs-traditional-data-models-a-pragmatic-comparison-4be4d6b575d5?source=rss-efc5d4ea4ef0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4be4d6b575d5</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-architecture]]></category>
            <category><![CDATA[data-vault]]></category>
            <category><![CDATA[modern-data-architecture]]></category>
            <category><![CDATA[data-modelling]]></category>
            <dc:creator><![CDATA[Avinash Ghanekar]]></dc:creator>
            <pubDate>Sun, 28 Sep 2025 20:49:01 GMT</pubDate>
            <atom:updated>2025-09-28T20:49:01.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qAnTER-V6AWr-cUcBwWtSA.png" /></figure><h3>What Is Data Vault?</h3><p><strong>Definition &amp; Rationale</strong><br> Data Vault is a hybrid, modular data modeling approach, designed to provide adaptability, auditability, and scalability in enterprise data warehouses.</p><p>Data Vault emphasizes “all the data, all the time” (storing historical/raw changes) rather than enforcing immediate cleansing. It separates the structural, relational, and descriptive elements of data into different components (so that changes in one area minimally impact others)</p><h3>Core Components of a Data Vault</h3><p>In the standard (Raw) Data Vault model, there are three main building blocks:</p><ol><li><strong>Hubs</strong></li></ol><ul><li>Represent core <strong>business entities</strong> (e.g. Customer, Product, Store)</li><li>Store the <strong>business key(s)</strong> (natural key) plus minimal technical metadata (e.g. load timestamp, source)</li><li>Each business key appears only once in a hub (i.e. one row per key)</li></ul><p><strong>2. Links</strong></p><ul><li>Capture relationships between hubs (i.e. associations / transactions). For example, which Customer bought which Product at what Store.</li><li>Link tables hold foreign keys to the participating Hubs and metadata (e.g. load date, source)</li><li>Links are often many-to-many (or conceptually so) and may also have their own satellites for attributes of the relationship.</li></ul><p><strong>3. Satellites</strong></p><ul><li>Store <strong>descriptive attributes</strong> and their <strong>history</strong> over time (e.g. status, address, price) associated with a hub or link.</li><li>They are append-only (new rows for changes) and typically include timestamp or start/end/validity dates, record source, etc.</li><li>You can split attributes into multiple satellites by rate of change or source system, to optimize loading and querying.</li></ul><p>In more advanced designs (Data Vault 2.0), there may also be additional components such as <strong>effectivity satellites</strong> (for validity periods on Links), <strong>point-in-time (PIT) tables</strong>, <strong>bridge tables</strong>, and a <strong>Business Vault</strong> layer (which can house derived, cleansed, or aggregated logic).</p><p>The architecture is often layered:</p><ul><li><strong>Raw Vault</strong> (or “integration vault”): capturing the raw, unmodified data ingestion from sources.</li><li><strong>Business Vault</strong>: applying business rules, derived values, conformed logic, etc.</li><li><strong>Data Marts / Presentation Layer</strong>: exposing star schemas or other models optimized for querying.</li></ul><h3>Simple Retail Example</h3><p>Let’s illustrate with a small fictional retail company scenario (online + physical store):</p><p><strong>Key Entities / Hubs</strong></p><ul><li>HUB_Customer (business key: customer_id)</li><li>HUB_Product (product_sku)</li><li>HUB_Store (store_id)</li></ul><p><strong>Relationship / Link</strong></p><ul><li>LINK_Sale (connects Customer, Product, Store) — meaning a customer purchased a product at a store</li><li>It holds the foreign keys: customer_id, product_sku, store_id</li><li>Plus metadata: load_date, record_source, etc.</li></ul><p><strong>Satellites</strong></p><ul><li>SAT_Customer_Details → attributes like name, email, address, with history</li><li>SAT_Product_Info → attributes like product name, category, price (which can change over time)</li><li>SAT_Store_Details → e.g. store name, location, region</li><li>SAT_Sale_Details (satellite on LINK_Sale) → attributes such as sale_amount, discount_code, transaction_type, with timestamp</li></ul><p>Thus, when a new sale event arrives from a POS or e-commerce source:</p><ol><li>You load or ensure the hub records exist (Customer, Product, Store).</li><li>You insert a row into LINK_Sale linking those hubs.</li><li>You insert a new row in SAT_Sale_Details describing the specifics of the sale event with relevant metadata (e.g. load timestamp).</li><li>If any descriptive attribute has changed (e.g. product price, customer address), you insert a new record into the respective satellite(s).</li></ol><p>Because the descriptive data is separated, you can change attributes frequently without touching the hub or link tables. Also, you retain full history of changes.</p><p>For reporting, you might build a star schema or views that join hub → link → satellite to produce dimensional views optimized for business queries.</p><h3>Why Was Data Vault Introduced?</h3><p>Over time, practitioners noticed limitations with traditional data warehousing / dimensional modeling / normalized models under dynamic, multi-source, evolving environments. Some motivating factors:</p><ul><li><strong>Schema rigidity</strong>: In classical star/snowflake designs or normalized models, changes to source systems (adding new columns, new relationships) often require refactoring many tables, ETL pipelines, and downstream dependencies.</li><li><strong>Slow onboarding of new sources</strong>: Integrating new systems or changing schemas often causes ripple effects across the warehouse.</li><li><strong>Auditability and lineage</strong>: Many warehouses overwrite old values or “cleanse” incoming data before loading; reconstructing original lineage or original values is difficult.</li><li><strong>Historical tracking</strong>: Handling slowly changing dimensions (SCD Type 2, etc.) becomes complex and error prone at scale.</li><li><strong>Parallel loading / scalability</strong>: To scale to large volumes, one wants a model that supports parallel ingestion and minimal coupling.</li><li><strong>Separation of concerns</strong>: By decoupling structural (keys), relational (links), and descriptive (satellites) elements, you isolate impacts of change.</li></ul><p>Data Vault attempts to solve these by:</p><ul><li>Always capturing raw data (i.e. minimal transformations) so that downstream layers can handle cleansing.</li><li>Enabling easier incremental extension: new hubs, satellites, links can be added without substantial rewiring.</li><li>Retaining full history and lineage (through timestamps, record source).</li><li>Enabling parallel loads (because hubs, links, satellites can often be processed independently)</li><li>Encouraging metadata-driven automation (templates, generative ETL) rather than hand-coding.</li></ul><p>In effect, Data Vault is a methodology and pattern discipline to make enterprise-scale, evolving data warehouses more maintainable and resilient to change.</p><h3>Some downsides of Data Vault (Strictly based on personal experience)</h3><p>While Data Vault has clear strengths, it is not without drawbacks. Some of the commonly cited challenges:</p><ol><li><strong>Complexity &amp; cognitive load</strong></li></ol><ul><li>Many more tables (hubs, links, satellites, PITs, bridges) than a classic star schema.</li><li>Understanding which satellite links to which hub or link, and writing queries that assemble the “state” can be more complex.</li><li>In large deployments, the model itself becomes intricate to manage and reason about.</li></ul><p><strong>2. Query performance / join overhead</strong></p><ul><li>Because data is normalized across many tables, analytical queries often require many joins (hub → link → satellite chains).</li><li>Unless appropriately indexed, materialized, or pre-aggregated, performance can suffer.</li><li>Many teams mitigate this by building denormalized marts or summary layers on top, which reduces the purity of the vault approach.</li></ul><p><strong>3. Latency / complexity of load pipelines</strong></p><ul><li>The ETL/ELT logic to correctly maintain and load hubs, links, satellites (particularly handling change detection, deduplication, hashing, etc.) can be complex.</li><li>Ensuring correct alignment, concurrency, and consistency across parallel loads is nontrivial.</li></ul><p><strong>4. Steep learning curve / skills</strong></p><ul><li>Requires practitioners experienced in Data Vault modeling, methodology, good metadata management, tooling, and disciplined development practices.</li><li>Many teams underestimate the governance, metadata, and automation infrastructure required.</li></ul><p><strong>5. Overhead / storage expansion</strong></p><ul><li>Because you store every historical change in satellites (and even for small changes), storage usage is higher.</li><li>Some redundancy arises in metadata columns (timestamps, record source) across many rows.</li></ul><p><strong>6. Not always necessary for simpler contexts</strong></p><ul><li>If the data domain is stable, sources are few, and change is limited, the overhead of Data Vault may not justify the benefits.</li></ul><p><strong>7. Fragmentation and performance tuning</strong></p><ul><li>In practice, you may end up fragmenting or consolidating satellites, and you need careful design (partitioning, indexing) to maintain performance.</li></ul><p>Given these tradeoffs, building and maintaining a Data Vault often demands a mature data engineering organization, strong metadata tooling, and vigilant monitoring.</p><h3>Does Data Vault Still Make Sense? with the introduction of The “Lakehouse / Modern Architecture Factor”</h3><p>In modern data architectures, especially with the rise of <strong>lakehouse</strong> platforms, the relevance of Data Vault is being reexamined. A “lakehouse” is essentially a paradigm combining the openness and flexibility of a data lake with management, governance, and performance capabilities of a data warehouse.</p><p>Here’s how lakehouse architecture shifts the equation:</p><ul><li><strong>Scalable storage &amp; compute separation</strong><br> Lakehouses leverage decoupled storage (e.g. object stores) and compute engines (e.g. Spark, Delta Lake, Apache Iceberg). This allows handling very large data volumes with performance scaling up.</li><li><strong>Schema-on-read / flexible ingestion</strong><br> You can ingest raw semi-structured data without upfront schema enforcement; transformation happens later.</li><li><strong>Performance optimizations</strong><br> Modern lakehouses support features like data skipping, clustering, indexing, caching, and materialized views to accelerate queries.</li><li><strong>Delta / versioned tables</strong><br> Versioning (time travel), ACID guarantees, and merge/upsert support reduce burden of manual historical logic.</li><li><strong>Unified design</strong><br> Many lakehouse stacks facilitate building directly in a structure that supports both raw and curated layers, rather than forcing a rigid “vault” layer.</li></ul><p>Because the lakehouse already provides scalability, versioning, and performance optimizations, some of the problems that Data Vault addresses (particularly around volume, storage, and parallelism) are less severe. In a lakehouse, you might:</p><ul><li>Ingest raw data as-is</li><li>Store multiple versions via delta/merge</li><li>Use views or curated tables for analytics (denormalized, dimensional)</li><li>Rely on the compute engine to optimize join, caching, partition pruning, etc.</li></ul><p>Thus, some argue (as in the video referenced) that layering Data Vault logic on top of a lakehouse can be overkill, adding complexity without as much marginal benefit, because the lakehouse already mitigates many scaling and adaptability concerns.</p><p>However, proponents of Data Vault would counter that the methodology, lineage, auditability, and modular modeling still add value even in a lakehouse context. Indeed, many implementations adapt Data Vault to a lakehouse (e.g. vault built on top of a lakehouse’s Silver layer)</p><p>In short: lakehouse architectures reduce some of the pain points (scalability, storage, ingest flexibility) that motivated Data Vault originally. That shifts the cost/benefit balance back toward simpler models, at least for many use cases.</p><h3>Opinion: Is Data Vault Worth the Complexity — or Does Lakehouse “Solve” It?</h3><ul><li>It provides strong guarantees around auditability, lineage, historical completeness, and robustness to change.</li><li>But it’s inherently more complex to build, maintain, and query than more direct models.</li><li>Many teams underestimate the metadata, tooling, governance, and monitoring overhead.</li></ul><p>Given that modern lakehouse architectures already address key pains (scalability, versioning, ingestion, performance), can organizations lean toward a hybrid approach: use a <strong>raw ingestion / staging layer</strong> in the lakehouse, apply <strong>curated models</strong> (dimensional or denormalized) for downstream consumption, and use <strong>lightweight lineage/capture techniques</strong> rather than a full-blown vault unless audit/regulation demands it.</p><p>For many practical cases, the complexity of a vault may not yield sufficient ROI when lakehouse-native methods (versioned tables, incremental merges, caching, materialized views) can deliver high performance with simpler designs.</p><p>I’d love to hear perspectives from fellow data architects and practitioners on where Data Vault still adds value in today’s lakehouse-driven world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4be4d6b575d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating Legacy Hive Metastore to Unity Catalog in Databricks]]></title>
            <link>https://medium.com/@avinash.a.ghanekar/migrating-legacy-hive-metastore-to-unity-catalog-in-databricks-7b79c39d83ea?source=rss-efc5d4ea4ef0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b79c39d83ea</guid>
            <category><![CDATA[data-architecture]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[unity-catalog]]></category>
            <category><![CDATA[data-governance]]></category>
            <dc:creator><![CDATA[Avinash Ghanekar]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 20:55:44 GMT</pubDate>
            <atom:updated>2025-09-22T20:55:44.198Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAoevMxccs2TIl_kT5KSGQ.png" /><figcaption>AI powered Image</figcaption></figure><h3>1. Why Migrate to Unity Catalog</h3><p>Databricks’ Unity Catalog is now the recommended way to handle governance, security, and metadata for lakehouse data assets. Many organizations today still use the legacy Hive Metastore (HMS) — either the workspace-local Hive Metastore or external ones — but there are increasing limitations and risks to staying on HMS. Some of the key motivations for migrating are:</p><ul><li><strong>Better governance &amp; access control</strong>: Unity Catalog supports fine-grained access control (on catalogs, schemas, tables, columns), unified identity management, more robust auditing, and lineage features. Hive Metastore has more coarse-grained controls, and some legacy features (like credential passthrough, or table ACLs) are deprecated in some contexts.</li><li><strong>Security posture</strong>: With shared metastore, or when multiple workspaces attach to a single Unity Catalog metastore, you can enforce consistent policies across the organization. The risk of drift in permissions is much higher with per-workspace HMS. Also, in some compute modes, the legacy table access controls may have restrictions or be less tightly enforced.</li><li><strong>Operational consistency &amp; consolidation</strong>: Unity Catalog centralizes catalogs/schemas, simplifies having multiple environments (dev/prod/etc.), reduces duplication of metadata, and helps avoid “siloed” workspaces. It also simplifies managing external locations, storage credentials, etc.</li><li><strong>Future-proofing &amp; feature access</strong>: New Databricks features are increasingly being built with Unity Catalog in mind: data lineage, ACID behavior, better Delta support, richer auditing, integration with other tools (security/compliance). Some newer features may not be — or less so — available or supported for legacy Hive tables.</li><li><strong>Reduced risk of technical debt</strong>: Leaving legacy HMS in place risks accumulating debts: having to support two metadata systems, having to keep workflows around for compatibility, risk of future depreciation, etc. Migrating early helps avoid that.</li></ul><p>Because of all that, many organizations are evaluating or beginning migrations from legacy Hive Metastore to Unity Catalog, either fully or gradually.</p><h3>2. Different Migration Approaches: What They Are &amp; When to Use Them</h3><p>There are several approaches to migrate tables, views, schemas, etc. from legacy Hive Metastore into Unity Catalog. The choice among them depends on things like: how many tables you have; whether they are external or managed; whether you can tolerate downtime; how much copy of data you want; whether you want to keep “hybrid” operation for a while; etc. Below are the main approaches with details and usage scenarios.</p><p><strong>1. Sync commands (SQL </strong><strong>SYNC / </strong><strong>SYNC SCHEMA)</strong><br> This method creates Unity Catalog external tables by syncing metadata from Hive Metastore.</p><ul><li><strong>How it works:</strong> Registers HMS tables as UC external tables, leaving data in place.</li><li><strong>Pros &amp; Cons:</strong></li><li>✅ Fast and cost-effective since no data is copied.</li><li>✅ Supports gradual, hybrid adoption.</li><li>❌ Limited mainly to external tables.</li><li>❌ Still requires maintaining HMS until cutover.</li><li><strong>When to use:</strong> Best for environments with many external tables or when you want a low-disruption, incremental migration path.</li></ul><p><strong>2. Upgrade Wizard (Catalog Explorer UI)</strong><br> A UI-driven option for bulk migration with minimal scripting.</p><ul><li><strong>How it works:</strong> Provides a wizard in Databricks Catalog Explorer to bulk upgrade schemas/tables, including scheduled syncs.</li><li><strong>Pros &amp; Cons:</strong></li><li>✅ Simple, intuitive, and reduces manual effort.</li><li>✅ Good for bulk migrations of external tables.</li><li>❌ Limited flexibility and doesn’t cover all edge cases.</li><li><strong>When to use:</strong> Ideal for teams that prefer a visual workflow and want quick, low-risk wins.</li></ul><p><strong>3. Deep Clone (</strong><strong>CREATE TABLE CLONE)</strong><br> A powerful option for migrating managed Delta tables into Unity Catalog.</p><ul><li><strong>How it works:</strong> Copies both data and metadata into UC-managed storage.</li><li><strong>Pros &amp; Cons:</strong></li><li>✅ Produces fully managed UC-native tables.</li><li>✅ Minimal disruption to workflows.</li><li>❌ Requires additional storage and compute resources.</li><li>❌ Doesn’t preserve full transaction history.</li><li><strong>When to use:</strong> Right for compliance-heavy environments or when you want UC’s full governance capabilities on managed tables.</li></ul><p><strong>4. CTAS (</strong><strong>CREATE TABLE AS SELECT)</strong><br> A flexible but manual migration method.</p><ul><li><strong>How it works:</strong> Creates new UC tables by running a CREATE TABLE AS SELECT query against HMS tables.</li><li><strong>Pros &amp; Cons:</strong></li><li>✅ Lets you modernize schemas, partitions, and formats during migration.</li><li>✅ Useful for re-engineering legacy tables.</li><li>❌ Manual and time-consuming for large datasets.</li><li>❌ Doesn’t preserve historical lineage.</li><li><strong>When to use:</strong> Best when you want to clean up or restructure data models as part of the migration.</li></ul><p><strong>5. UCX Tooling (Databricks Labs)</strong><br> Automation-focused tooling to scale migrations in large environments.</p><ul><li><strong>How it works:</strong> Provides scripts for auditing, migrating permissions, and bulk table migration.</li><li><strong>Pros &amp; Cons:</strong></li><li>✅ Automates repetitive migration tasks.</li><li>✅ Helps migrate complex permissions and external locations.</li><li>❌ Community-supported, not a fully managed product.</li><li><strong>When to use:</strong> Recommended for enterprises with hundreds or thousands of tables where manual migration is not feasible.</li></ul><p><strong>6. Hive Metastore Federation (Foreign Catalogs)</strong><br> A transitional approach for gradual adoption.</p><ul><li><strong>How it works:</strong> Exposes HMS as a foreign catalog inside Unity Catalog.</li><li><strong>Pros &amp; Cons:</strong></li><li>✅ Enables immediate access to HMS tables via UC.</li><li>✅ Requires no data movement initially.</li><li>❌ Limited UC governance features on federated objects.</li><li>❌ Creates dual-system complexity.</li><li><strong>When to use:</strong> Best for organizations needing a low-risk, step-by-step transition before fully committing to UC.</li></ul><p><strong>Some important caveats &amp; trade-offs to consider in choosing an approach:</strong></p><ul><li><strong>Data history / time travel</strong>: many migration approaches do <em>not</em> preserve full version history / transaction log prior to cloning or CTAS; deep clone and CTAS treat the data after the point of copy as new. If you rely on past history of the table (for audit or rollback), check how much of it you can preserve.</li><li><strong>Formats &amp; storage</strong>: Some tables might not be in Delta format; external tables in formats not supported by Unity Catalog may need conversion. Storage locations must be accessible from Unity Catalog, credentials, external locations etc must be configured.</li><li><strong>Permissions &amp; security</strong>: Migrating metadata is not the same as migrating permissions. Ensuring role‐mapping, user/group mapping, ownerships, storage credentials, external location permissions all get correctly set is critical. Mistakes here can lead to either overly permissive or overly restrictive access. Tools like UCX help.</li><li><strong>Workload / code changes</strong>: Any code, notebooks, jobs, dashboards, SQL queries that refer to hive_metastore.&lt;schema&gt;.&lt;table&gt; will need updating to new catalog.schema.table naming. Also path references, mounts, external location URIs etc. Need testing.</li><li><strong>Cost &amp; performance</strong>: Data copy (for CTAS or CLONE) uses storage and compute. Also there may be latency or resource consequences during migration. Plan windows, possibly incremental migration.</li></ul><h3>3. Conclusion</h3><p>Migrating from a legacy Hive Metastore to Unity Catalog in Databricks is increasingly essential for organizations looking to elevate their data governance, security, and operational maturity. The benefits — better access controls, unified identity management, improved auditing &amp; lineage, and future-readiness — are compelling.</p><p>However, there is no one-size-fits-all solution: smaller setups may adopt external registration via SYNC or the Upgrade Wizard, while larger, governed-by-compliance environments may require full managed table migrations (via deep clone or CTAS), with tooling like UCX to automate and reduce risk. Federation may be the bridge for gradual transition.</p><p>In any migration, pay careful attention to: data format and storage constraints; history preservation; permission and identity migration; updating downstream dependencies (jobs, dashboards, code); and doing thorough testing. Migration is not just metadata, but an organizational and tooling effort.</p><h3>References</h3><ul><li><a href="https://docs.databricks.com/aws/en/data-governance/unity-catalog/migrate"><em>Upgrade Hive tables and views to Unity Catalog</em></a></li><li><a href="https://docs.databricks.com/aws/en/data-governance/unity-catalog/hive-metastore"><em>Work with the legacy Hive metastore alongside Unity Catalog</em></a></li><li>Tredence blog: <a href="https://www.tredence.com/blog/migrating-to-unity-catalog"><em>Unity Catalog Migration: A Step by Step Guide in 2025</em></a></li><li>Databricks Labs / UCX tooling blog-Medium: <a href="https://medium.com/databricks-unity-catalog-sme/ucx-to-the-rescue-834a7a226d6e"><em>UCX to the Rescue! Why you need tooling to migrate to Unity Catalog</em></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b79c39d83ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migration Journey from On-Prem Netezza PDA to Netezza Performance Server (NPS) on Cloud]]></title>
            <link>https://medium.com/@avinash.a.ghanekar/migration-journey-from-on-prem-netezza-pda-to-netezza-performance-server-nps-on-cloud-d15966ebb508?source=rss-efc5d4ea4ef0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d15966ebb508</guid>
            <category><![CDATA[data-warehouse-solutions]]></category>
            <category><![CDATA[database-migration]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[netezza]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Avinash Ghanekar]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 12:56:50 GMT</pubDate>
            <atom:updated>2025-06-28T13:09:29.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GLv-SAhf4hji5L-fRKIn0A.png" /></figure><p>Thought of documenting and sharing few learnings of modernisation program to upgrade on-prem netezza to cloud NPSaaS</p><ol><li><strong>Why we selected NPSaaS (Netezza Performance Server) for netezza migration?</strong></li></ol><p>When we were exploring options to modernize our on-prem Netezza PDA setup, IBM’s Netezza Performance Server (NPS) on cloud stood out. It gave us a relatively easy path forward without needing to rebuild everything from scratch. With its lift-and-shift capabilities, we could reuse most of our existing SQL logic, which saved us both time and effort.</p><p><strong>Key Benefits:</strong></p><ul><li><strong>Quick migration time</strong> thanks to high compatibility with legacy workloads.</li><li><strong>No infrastructure headaches</strong> — it’s fully managed by IBM.</li><li><strong>Scalable and cloud-native</strong>, with support for IBM Cloud Pak for Data.</li><li><strong>Retains our existing investments</strong> in Netezza-based solutions.</li></ul><p><strong>2. Overview of Netezza Performance Server</strong></p><p>IBM Netezza Performance Server (NPS) is the next-gen version of the familiar Netezza platform. It’s a fully managed data warehouse that runs on Red Hat OpenShift and can be deployed across IBM Cloud, AWS, Azure.</p><p><strong>What’s cool about NPS:</strong></p><ul><li>Built on the trusted Netezza engine.</li><li>Supports horizontal scaling.</li><li>Compatible with legacy Netezza workloads — so no major rewrites.</li><li>Available as a service</li></ul><p><strong>3. Setting Up Netezza Performance Server (NpSaaS) on Azure</strong></p><p>We setup the NPS as a service (NpSaaS) on Azure, and it was pretty straightforward. Instance setup was just like any other azure service but from IBm cloud, so we mainly had to focus on networking and access controls.</p><p><strong>Basic setup steps:</strong></p><ul><li>Create an azure subscription for netezza on cloud</li><li>Get the instance provisioned through IBM cloud. There are multiple Contours you can choose from based on your on-prem workloads</li></ul><p><strong>NCStart:</strong> Entry-level instance for BI and UAT workloads to get started with Netezza Performance Server.</p><p><strong>NC0:</strong> Query processing parallelism for lower volume BI EDW, single function Data marts, Test and UAT.</p><p><strong>NC1:</strong> Expands on the NC0 contour query parallelism to drive workload requiring higher degree of compute for BI, Data marts and advanced analytics.</p><p><strong>NC2:</strong> Query processing parallelism best suited for cross functional and descriptive analytic use cases such as Dash-boarding, BI and Data exploration.</p><p><strong>NC3:</strong> Builds on NC2 contour query parallelism to drive sophisticated workloads requiring greater abundance of compute, IO and memory for resource intensive workloads.</p><p>Some quick links to IBM documentation.</p><p><a href="https://cloud.ibm.com/docs/netezza?topic=netezza-getstarted">https://cloud.ibm.com/docs/netezza?topic=netezza-getstarted</a></p><p><a href="https://cloud.ibm.com/nzsaas/create">https://cloud.ibm.com/nzsaas/create</a></p><ul><li>Set up VNETs and private links for secure communication.</li></ul><p><a href="https://cloud.ibm.com/docs/netezza?topic=netezza-connecting-overview">https://cloud.ibm.com/docs/netezza?topic=netezza-connecting-overview</a></p><ul><li>Hooked it up with Azure AD/IAM or Native access management for authentication.</li><li>Used tools like nzsql , DBeaver, Aginity or IBM Data Studio to interact with the database.</li></ul><p>Bonus: It integrates nicely with ETL tools like Azure Data Factory, Informatica using ODBC conenctors which makes the data factory pipeline</p><p>A quick blog to integrate NPSaaS to ADF.</p><p><a href="https://medium.com/@johnkarthix/integrate-azure-data-factory-with-netezza-performance-server-on-cloud-d068ce4565a6">https://medium.com/@johnkarthix/integrate-azure-data-factory-with-netezza-performance-server-on-cloud-d068ce4565a6</a></p><p><strong>4. Preparation Before Migration</strong></p><p>Before jumping into the migration, we did a good round of cleanup and optimization to avoid carrying over any junk: Turned out only 30% of the data was needed to migrate compared to On-prem</p><ul><li><strong>Cleaned up unused tables and views.</strong></li><li><strong>Updated stats</strong> on all major tables.</li><li><strong>Purged / Avoided old logs and history tables.</strong></li></ul><p><strong>5. Migration Process</strong></p><p>We followed a hybrid migration approach using both nz_migrate and nzbackup/nzrestore. This allowed us to move both schema objects and bulk data efficiently.</p><p><strong>a. Using </strong><strong>nz_migrate</strong></p><p>Pros:</p><ul><li>It helped move over DDLs, stored procs, and UDFs with ease.</li><li>A migration is generally going to be much faster than nzbackup and nzrestore</li><li>It does not require external storage to be provisioned</li><li>It provides a lot more flexibility and options. But more options means a bit more complexity</li><li>This only supports a “full” migration of a table.</li></ul><p>Cons:</p><ul><li>There is no support for a “-differential”</li><li>Migration speed depends on the network bandwidth between on-prem and cloud</li></ul><pre>nz_migrate -host &lt;target_nps_host&gt; -u &lt;user&gt; -pw &lt;password&gt; -db &lt;target_db&gt; -f &lt;input_file&gt;</pre><p><em>PS: the full + delta approch provided in nz_migrate documentation doesn’t work due to issue of locking the database during nz_migrate.</em></p><p><strong>b. Using </strong><strong>nzbackup and </strong><strong>nzrestore</strong></p><p>Pros:</p><ul><li>Great for migrating heavy data sets quickly and reliably.</li><li>Can do differential backup (full + delta)</li></ul><pre># On source (PDA)<br>nzbackup -u admin -pw password -db sourcedb -dir /nz/backup<br><br>#we mounted azure storage account (NFS enabled) onto on-prem server to copy <br>#backup directly on blob storage<br><br>#use the same storage account to restore the backup<br>#On target (NPS)<br>nzrestore -u admin -pw password -db targetdb -dir /nz/backup -prefix sourcedb_backup</pre><p>Cons:</p><ul><li>Time consuming process as it requires backup + transfer + restore approach (unless you use same staging storage as us)</li><li>Delta backup may not be possible if your pipelines have daily grooming on tables.</li></ul><p><strong>6. Comparison with Other Cloud Data Warehouses</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*kVW385_-TpEy4m6sJiN7gg.png" /></figure><p>Netezza Performance Server may not be the flashiest new tool on the block, but if you’re already in the Netezza world, the ability to move without rewriting everything is a huge win.</p><p><strong>Closing Thoughts</strong></p><p>This migration to NPS gave us the best of both worlds — modern infrastructure with minimal changes to our existing stack. The process was smoother than expected, and the managed services approach means we spend less time firefighting infra and more time delivering insights. If you’re running on Netezza PDA and thinking about modernization, NPS is definitely worth a serious look.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d15966ebb508" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Apache Spark Workloads: Addressing the 5S’s]]></title>
            <link>https://medium.com/@avinash.a.ghanekar/optimizing-apache-spark-workloads-addressing-the-5ss-e1ac605a7821?source=rss-efc5d4ea4ef0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1ac605a7821</guid>
            <category><![CDATA[spark-tuning]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[performance-tuning]]></category>
            <dc:creator><![CDATA[Avinash Ghanekar]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 20:04:03 GMT</pubDate>
            <atom:updated>2025-04-18T20:04:03.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_p2X5sCP40NJehxXK02CRg.png" /><figcaption>well the GPT model did a good job illustrating the blog</figcaption></figure><p>Apache Spark is a powerful tool for big data processing. However, to harness its full potential, it’s essential to understand and mitigate common performance issues. This guide delves into the five primary culprits — known as the 5S’s — that can hinder Spark’s performance: Skew, Spill, Shuffle, Serialization, and Storage.</p><h3>The Importance of Tuning Spark Pipelines</h3><p>Efficient Spark pipelines are crucial for:</p><ul><li><strong>Performance</strong>: Ensuring faster data processing.</li><li><strong>Resource Utilization</strong>: Making optimal use of cluster resources.</li><li><strong>Cost Efficiency</strong>: Reducing operational costs by avoiding unnecessary computations.</li></ul><p>Without proper tuning, Spark jobs can become sluggish, leading to increased costs and resource wastage.</p><h3>The 5S’s: Common Spark Performance Challenges</h3><h3>1. Skew</h3><p><strong>Issue</strong>: Data skew occurs when certain partitions have significantly more data than others, leading to uneven workload distribution.</p><p><strong>Mitigations</strong>:</p><ul><li><strong>Adaptive Query Execution (AQE)</strong>: Automatically detects and handles skewed partitions by splitting them into smaller ones. Enabled by default in Spark 3.2 and above.</li></ul><pre>spark.conf.set(&quot;spark.sql.adaptive.skewedJoin.enabled&quot;, True)</pre><ul><li><strong>Salting</strong>: Manually adding a random value to skewed keys to distribute data more evenly across partitions.</li></ul><p>Let’s say we have sales data where we join on the field region_id. Assume the distribution of the dataset is skewed as follows:</p><p><strong>Skewed Data Example</strong></p><pre># Skewed dataset (synthetic)<br>sales_data = spark.createDataFrame([<br>    (1, &#39;Online&#39;), (1, &#39;Online&#39;), (1, &#39;Online&#39;), (1, &#39;Online&#39;),<br>    (1, &#39;Online&#39;), (1, &#39;Online&#39;), (1, &#39;Online&#39;), (1, &#39;Online&#39;),<br>    (1, &#39;Online&#39;), (1, &#39;Online&#39;), (1, &#39;Online&#39;), (1, &#39;Online&#39;),<br>    (2, &#39;Online&#39;), (2, &#39;Online&#39;),<br>    (3, &#39;Online&#39;), (3, &#39;Online&#39;),<br>    (4, &#39;Online&#39;), (4, &#39;Online&#39;),<br>], [&#39;region_id&#39;, &#39;sales_channel&#39;])</pre><pre>region_id=1 → 12 rows  <br>region_id=2 → 2 rows  <br>region_id=3 → 2 rows  <br>region_id=4 → 2 rows</pre><p>Joining this dataset with another (say, regional metadata) on region_id will cause a skew during shuffle because region_id=1 is overrepresented.</p><p>We create a <strong>salted key</strong> by adding a random salt (a, b) to the skewed join key, region_id. This will distribute the large number of rows with region_id=1 into multiple buckets.</p><h4>Step 1: Add Salt to Skewed Dataset</h4><pre>from pyspark.sql.functions import col, concat_ws, lit, rand, when<br># Define a UDF-free salt column using rand()<br>sales_data_salted = sales_data.withColumn(<br>    &quot;salt&quot;,<br>    when(rand() &gt; 0.5, lit(&quot;a&quot;)).otherwise(lit(&quot;b&quot;))<br>).withColumn(<br>    &quot;salted_region_id&quot;,<br>    concat_ws(&quot;&quot;, col(&quot;region_id&quot;), col(&quot;salt&quot;))<br>)</pre><h4>Step 2: Salt the Smaller Dataset Too</h4><p>Assuming the dimension table (regional metadata) is small:</p><pre>region_data = spark.createDataFrame([<br>    (1, &#39;North&#39;), (2, &#39;South&#39;), (3, &#39;East&#39;), (4, &#39;West&#39;)<br>], [&#39;region_id&#39;, &#39;region_name&#39;])<br><br># Duplicate region_data for both salt values<br>from itertools import product<br>region_values = [1, 2, 3, 4]<br>salts = [&#39;a&#39;, &#39;b&#39;]<br>region_data_salted = spark.createDataFrame([<br>    (rid, rname, f&quot;{rid}{s}&quot;)<br>    for rid, rname in region_data.collect()<br>    for s in salts<br>], [&#39;region_id&#39;, &#39;region_name&#39;, &#39;salted_region_id&#39;])</pre><h4>Step 3: Perform the Join on salted_region_id</h4><pre>joined_df = sales_data_salted.join(<br>    region_data_salted,<br>    on=&quot;salted_region_id&quot;,<br>    how=&quot;inner&quot;<br>)</pre><p><em>Before Salting</em></p><p>region_id=1 → 12 rows in 1 partition</p><p>Joins skewed and memory-intensive</p><p><em>After Salting</em></p><p>region_id=1a → 6 rows, region_id=1b → 6 rows</p><p>Joins balanced and efficient</p><h3>2. Spill</h3><p><strong>Issue</strong>: When data doesn’t fit into memory during processing, Spark spills it to disk, leading to performance degradation.</p><p><strong>Mitigations</strong>:</p><ul><li><strong>Increase Memory</strong>: Allocate more memory to executors.</li><li><strong>Repartitioning</strong>: Adjust the number of partitions to balance data distribution and reduce memory pressure.</li></ul><pre>df.repartition(num_partitions)</pre><h3>3. Shuffle</h3><p><strong>Issue</strong>: Shuffle operations involve data movement across the cluster, which can be time-consuming.</p><p><strong>Mitigations</strong>:</p><ul><li><strong>Column Pruning</strong>: Select only necessary columns to reduce data volume.</li></ul><pre>df.select(&quot;needed_column1&quot;, &quot;needed_column2&quot;)</pre><ul><li><strong>Broadcast Joins</strong>: For small datasets, broadcasting can prevent shuffles.</li></ul><pre>from pyspark.sql.functions import broadcast df_large.join(broadcast(df_small), &quot;key&quot;)</pre><ul><li><strong>Bucketing</strong>: Pre-partitioning data based on a column to optimize joins.</li></ul><pre># Write non-bucketed table<br>df.write.format(&quot;parquet&quot;).saveAsTable(&quot;unbucketed&quot;)<br><br># Write bucketed table<br>df.write.format(&quot;parquet&quot;).bucketBy(16, &quot;key&quot;).sortBy(&quot;value&quot;).saveAsTable(&quot;bucketed&quot;)</pre><h3>4. Serialization</h3><p><strong>Issue</strong>: Serialization converts data into a format for transmission or storage. Inefficient serialization can slow down processing.</p><p><strong>Mitigations</strong>:</p><ul><li><strong>Avoid Python UDFs</strong>: They can be slow due to serialization overhead.</li><li><strong>Use Pandas UDFs</strong>: Introduced in Spark 2.3, they leverage Apache Arrow for efficient serialization.</li></ul><pre>from pyspark.sql.functions import pandas_udf @pandas_udf(&quot;return_type&quot;) def efficient_udf(column):     # function logic</pre><h3>5. Storage</h3><p><strong>Issue</strong>: Improper file sizes can lead to performance issues.</p><p><strong>Best Practices</strong>:</p><ul><li><strong>Optimal File Sizes</strong>: Aim for partition sizes between 128MB and 1GB.</li><li><strong>Avoid Small Files</strong>: Too many small files can overwhelm the file system and slow down processing.</li><li><strong>Repartitioning</strong>: Adjust partitions to achieve optimal file sizes.</li></ul><pre>df.repartition(num_partitions).write.format(&quot;parquet&quot;).save(&quot;path&quot;)</pre><p>By understanding and addressing these five challenges, you can significantly enhance the performance and efficiency of your Apache Spark workloads.</p><p><strong>Reference:</strong></p><p><a href="https://blog.scottlogic.com/2022/07/04/data_ai.html">https://blog.scottlogic.com/2022/07/04/data_ai.html</a> <a href="https://spark.apache.org/docs/2.3.2/tuning.html">https://spark.apache.org/docs/2.3.2/tuning.html</a> <a href="https://spark.apache.org/docs/2.4.2/sql-performance-tuning.html">https://spark.apache.org/docs/2.4.2/sql-performance-tuning.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1ac605a7821" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DWH Roadmap — QuickCard]]></title>
            <link>https://medium.com/@avinash.a.ghanekar/dwh-roadmap-quickcard-ddb1a211acc2?source=rss-efc5d4ea4ef0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddb1a211acc2</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-architecture]]></category>
            <dc:creator><![CDATA[Avinash Ghanekar]]></dc:creator>
            <pubDate>Thu, 17 Apr 2025 21:20:26 GMT</pubDate>
            <atom:updated>2025-04-17T21:20:26.813Z</atom:updated>
            <content:encoded><![CDATA[<h3>DWH Roadmap — QuickCard</h3><p>Data engineers work tirelessly to process data into DWH or Lakehouses. However, understanding how these structures are built can be incredibly handy. 🏗️✨ Check out this snappy quick reference slide I created, detailing the step-by-step process for a successful Data Warehouse implementation. From gathering requirements to maintenance and monitoring, this has you covered. Perfect for data pros looking to streamline their DWH projects.</p><p>Tell me, in which stage does the schema definition happen? 🧐</p><p>Disclaimer: This is brewed from my own understanding and experience, so it might stray a bit from the textbook recipes. 📚</p><p><strong>Slide template</strong>: MS PowerPoint “ Product Roadmap Timeline”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxO9A5QFwAojEQRkMAB9PQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddb1a211acc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Efficiently Managing Incremental Loads in Spark: A Guide to CDC at Source and During ETL]]></title>
            <link>https://medium.com/@avinash.a.ghanekar/efficiently-managing-incremental-loads-in-spark-a-guide-to-cdc-at-source-and-during-etl-7a15da1160cb?source=rss-efc5d4ea4ef0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a15da1160cb</guid>
            <category><![CDATA[incremental-data-loading]]></category>
            <category><![CDATA[azure-databricks]]></category>
            <category><![CDATA[cdc]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[spark-streaming]]></category>
            <dc:creator><![CDATA[Avinash Ghanekar]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 11:11:41 GMT</pubDate>
            <atom:updated>2024-06-29T11:28:08.467Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*TIVcr1ucC6t2VBQN_V8TQA.png" /></figure><p>Handling large datasets efficiently is a critical task for data engineers, especially when dealing with incremental loads. Change Data Capture (CDC) is a popular technique used to identify and capture changes made to the data at the source. This blog post will explore how to efficiently manage incremental loads in Spark using CDC both at the source and during the ETL process.</p><p><strong>Understanding Change Data Capture (CDC)</strong></p><p>CDC is a design pattern used to identify and capture changes in data. These changes can include inserts, updates, and deletes. By implementing CDC, you can ensure that only the modified data is processed and moved, reducing the amount of data handled and optimising performance.</p><p><strong>CDC at the Source</strong></p><p>Implementing CDC at the source involves tracking changes in the data as they occur. This can be achieved through various methods:</p><p>1. <strong>Database Logs</strong>: Many databases, such as MySQL, PostgreSQL, and SQL Server, provide mechanisms to capture changes through transaction logs or binlogs. These changes can be streamed into Apache Kafka, from where they can be consumed by Spark.</p><p>2. <strong>Triggers and Change Tables</strong>: Triggers can be set up to log changes into a separate change table. This approach, while more intrusive, allows for fine-grained control over what changes are captured and when.</p><p>3. <strong>Timestamp Columns</strong>: Adding timestamp columns to track the last modified time of records can be a simple and effective way to identify changed data. Queries can then be written to select only records that have changed since the last load.</p><p><strong>CDC During ETL with Spark</strong></p><p>Once the changes have been captured at the source, Spark can be used to process these changes efficiently. Here’s how you can manage incremental loads in Spark:</p><p>1. <strong>Loading Incremental Data</strong>: Use Spark’s ability to read from various data sources, such as Kafka, Delta Lake, or traditional RDBMS. For example, when using Delta Lake, you can use the ‘readStream’ method to read only the latest changes.</p><pre>%python<br>incremental_df = spark.readStream.format(“delta”).table(“source_table”)</pre><p>2. <strong>Merge Operations</strong>: Spark’s Delta Lake provides a powerful ‘MERGE’ operation that allows you to apply updates and deletes to your target tables. This is similar to the SQL ‘MERGE’ statement and helps maintain the state of your data warehouse accurately.</p><pre><br> deltaTable.alias(“tgt”).merge(<br> source=incremental_df.alias(“src”),<br> condition=”tgt.id = src.id”<br> ).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute()</pre><p>3. <strong>Optimised Checkpoints</strong>: Using checkpoints in structured streaming ensures that the state of your stream is saved periodically, allowing for fault tolerance and exactly-once processing guarantees.</p><pre>query = incremental_df.writeStream.format(“delta”) \<br>.outputMode(“append”).option(“checkpointLocation”, “path/to/checkpoint”) \<br>.start(“path/to/delta/table”)</pre><p>4. <strong>Efficient Partitioning</strong>: Partition your data based on frequently queried fields. This will speed up the read operations and ensure that your incremental loads are applied efficiently.</p><p><strong>Change Data Feed (CDF) Functionality</strong></p><p>Delta Lake’s Change Data Feed (CDF) feature is a powerful addition that simplifies the process of tracking changes. CDF enables you to query and extract only the changes made to a Delta table over a specific period. Here’s how you can leverage CDF in your Spark ETL pipeline:</p><p>1. <strong>Enable CDF on Delta Table</strong>: To start using CDF, you need to enable it on your Delta table.</p><pre><br> ALTER TABLE delta_table SET TBLPROPERTIES (delta.enableChangeDataFeed = true)</pre><p>2. <strong>Read Changes Using CDF</strong>: You can then query the changes by specifying a version or a timestamp range.</p><pre> changes_df = spark.read.format(“delta”).option(“readChangeData”, “true”).table(“delta_table”)</pre><p>3. <strong>Process Changes</strong>: Use the changes data frame in your ETL pipeline to apply the necessary transformations and load them into your target system.</p><p><strong>Best Practices</strong></p><p><strong>Monitor and Tune Performance</strong>: Regularly monitor the performance of your incremental loads and tune Spark configurations for optimal performance. Use tools like Ganglia or Spark’s built-in UI to identify bottlenecks. (Will try to document differenent ways to performance monitoring in my next writes)<br><strong>Data Quality Checks</strong>: Implement data quality checks to ensure that the changes being applied do not corrupt the data warehouse. Tools like Great Expectations can help automate these checks.<br><strong>Scalability</strong>: Design your CDC pipeline to be horizontally scalable to handle increasing data volumes without degradation in performance.</p><p><strong>Conclusion</strong></p><p>Managing incremental loads efficiently in Spark using CDC both at the source and during ETL is crucial for maintaining up-to-date and accurate data warehouses. By leveraging tools like Delta Lake and best practices in Spark, you can optimize your data processing pipelines, ensuring they are both performant and reliable. Implementing CDC effectively will not only improve your ETL processes but also pave the way for real-time analytics and faster data-driven decisions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a15da1160cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>