<?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 Pubudu Dewagama on Medium]]></title>
        <description><![CDATA[Stories by Pubudu Dewagama on Medium]]></description>
        <link>https://medium.com/@pubududewagama?source=rss-162b8b5baf36------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*op2zmtdCbeDruXiQ.jpg</url>
            <title>Stories by Pubudu Dewagama on Medium</title>
            <link>https://medium.com/@pubududewagama?source=rss-162b8b5baf36------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:10:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pubududewagama/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[How to Create a Custom Bullet Chart in Power BI Using Deneb (Vega-Lite)]]></title>
            <link>https://medium.com/@pubududewagama/how-to-create-a-custom-bullet-chart-in-power-bi-using-deneb-vega-lite-002bc2c67a60?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/002bc2c67a60</guid>
            <category><![CDATA[deneb]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[data-visuliazation]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Sat, 14 Nov 2026 00:05:51 GMT</pubDate>
            <atom:updated>2026-11-14T00:05:51.161Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Learn how to build advanced bullet charts in Microsoft Power BI to visualize sales performance, compare targets, and create professional business intelligence dashboards.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsFOhjuvn5PJPWnLm1n7zg.png" /></figure><h3>Introduction</h3><p>Data visualization is one of the most important components of Business Intelligence. While Microsoft Power BI provides several built-in visualizations, sometimes we need more flexibility to represent complex business metrics effectively.</p><p>One such visualization is the <strong>Bullet Chart</strong>, which provides a compact and powerful way to compare actual performance against targets while displaying additional reference values.</p><p>In this tutorial, we explore how to create a custom Bullet Chart in Power BI using <strong>Deneb and Vega-Lite</strong>.</p><p>Unlike traditional bar charts, bullet charts allow us to combine actual values, targets, and performance ranges into a single visual, making them particularly useful for KPI monitoring and performance analysis.</p><h3>Watch the Complete Video Tutorial</h3><p>🎥 <strong>How to Create a Custom Bullet Chart in Power BI Using Deneb</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQBdKaClJ9HM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQBdKaClJ9HM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQBdKaClJ9HM%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e028d3a9cda1fd1570446d1371ca5cfb/href">https://medium.com/media/e028d3a9cda1fd1570446d1371ca5cfb/href</a></iframe><p>In this video, I demonstrate how to create a professional bullet chart using a sales performance dataset, with minimum, average, maximum, actual sales, and target values.</p><h3>1. What Is a Bullet Chart?</h3><p>A bullet chart is a data visualization technique designed to compare a primary performance measure against a target or benchmark.</p><p>It typically contains:</p><ul><li><strong>Actual Value:</strong> Represents the current performance.</li><li><strong>Target Value:</strong> Indicates the expected performance.</li><li><strong>Minimum Value:</strong> Represents the lower reference level.</li><li><strong>Average Value:</strong> Represents the average or intermediate performance benchmark.</li><li><strong>Maximum Value:</strong> Represents the upper reference level.</li></ul><p>By combining these elements, bullet charts help users quickly identify whether performance is below, meeting, or exceeding expectations.</p><h3>2. Why Use Bullet Charts in Power BI?</h3><p>Traditional bar charts are excellent for comparing categories, but they often require multiple visuals to display actual performance, targets, and performance ranges.</p><p>Bullet charts overcome this limitation by combining multiple indicators into a compact visualization.</p><p><strong>Key benefits include:</strong></p><ul><li>Comparing actual performance against targets.</li><li>Monitoring KPIs across multiple categories.</li><li>Identifying underperforming and high-performing areas.</li><li>Displaying reference ranges in a single chart.</li><li>Reducing dashboard complexity.</li><li>Supporting faster business decisions.</li></ul><p>For example, a sales manager can quickly identify which products or business units are achieving their targets and which require attention.</p><h3>3. What Is Deneb in Power BI?</h3><p>Deneb is a custom Power BI visual that enables developers and analysts to create advanced data visualizations using Vega and Vega-Lite specifications.</p><p>It provides greater flexibility than many standard Power BI visuals.</p><p>With Deneb, we can customize:</p><ul><li>Chart layouts and orientations.</li><li>Colors and visual styles.</li><li>Data labels and legends.</li><li>Reference lines and target markers.</li><li>Layered visualizations.</li><li>Interactive tooltips.</li><li>Statistical and performance indicators.</li></ul><p><strong>Deneb is particularly useful when the required visualization cannot be easily created using standard Power BI charts.</strong></p><h3>4. Example: Sales Performance vs. Targets</h3><p>In this tutorial, we use a sales performance dataset containing information about different companies, product categories, and sales targets.</p><p>The dataset includes:</p><p>FieldDescriptionCompanyBusiness or customer nameRegionSales regionProduct CategoryElectronics, Software, etc.Actual SalesRecorded sales amountTargetExpected sales amountMinimumLower performance benchmarkAverageAverage performance benchmarkMaximumUpper performance benchmark</p><p>Our goal is to create a horizontal bullet chart that displays these performance measures for each category.</p><p><strong>Visual representation:</strong></p><ul><li>Dark blue bars represent actual sales performance.</li><li>Light blue backgrounds represent reference ranges.</li><li>Orange vertical markers indicate target values.</li><li>The horizontal axis displays sales amounts in USD.</li><li>Each row represents a company, region, and product category.</li></ul><p>This approach allows decision-makers to compare multiple sales categories without switching between different charts.</p><h3>5. How to Create a Bullet Chart Using Deneb</h3><p>The process involves several steps.</p><h3>Step 1: Prepare the Dataset</h3><p>Import your sales dataset into Microsoft Power BI.</p><p>Ensure that numerical fields such as Actual Sales, Target, Minimum, Average, and Maximum are correctly formatted.</p><h3>Step 2: Install Deneb</h3><p>Open Power BI Desktop and navigate to the Visualizations pane.</p><p>Select <strong>Get more visuals</strong>, search for Deneb, and add it to your report.</p><h3>Step 3: Add the Required Fields</h3><p>Insert the Deneb visual and add the necessary dataset columns.</p><p>These typically include the category label, actual sales, target, and reference values.</p><h3>Step 4: Create a Vega-Lite Specification</h3><p>Deneb uses JSON-based Vega-Lite specifications to define visual elements.</p><p>For our bullet chart, we combine several layers:</p><ul><li>Background bars for reference ranges.</li><li>Foreground bars for actual sales.</li><li>Vertical rules for target markers.</li><li>Axes and labels for better readability.</li></ul><h3>Step 5: Customize the Visualization</h3><p>Adjust the chart colors, bar thickness, spacing, legends, and axis formatting to create a professional appearance.</p><h3>Step 6: Validate the Results</h3><p>Compare the chart values against your source dataset to ensure that the target markers and performance ranges are displayed correctly.</p><h3>6. Real-World Applications of Bullet Charts</h3><p>Bullet charts can be used across many industries.</p><p><strong>Sales and Marketing</strong></p><p>Compare actual revenue against sales targets across products, regions, or teams.</p><p><strong>Financial Analytics</strong></p><p>Monitor actual expenditure against budgets and financial performance benchmarks.</p><p><strong>Education Analytics</strong></p><p>Compare student assessment performance against expected competency levels.</p><p><strong>Healthcare Analytics</strong></p><p>Track clinical performance indicators against defined targets.</p><p><strong>Operations Management</strong></p><p>Monitor production performance, service delivery, and operational efficiency.</p><p><strong>Project Management</strong></p><p>Track project KPIs and progress against planned targets.</p><h3>7. Why Learn Vega-Lite and Deneb?</h3><p>As business reporting requirements become more complex, Power BI developers increasingly need advanced visualization capabilities.</p><p>Learning Deneb and Vega-Lite provides greater control over chart design and enables the creation of highly customized dashboards.</p><p>These skills are particularly valuable for Data Analysts, BI Developers, Data Scientists, and Data Engineers who want to move beyond standard reporting visuals.</p><h3>8. Key Takeaways</h3><p>In this tutorial, we explored how to:</p><ul><li>Understand the purpose of bullet charts.</li><li>Use Deneb for advanced Power BI visualizations.</li><li>Compare actual performance with target values.</li><li>Display minimum, average, and maximum reference ranges.</li><li>Build custom charts using Vega-Lite.</li><li>Design professional business intelligence dashboards.</li></ul><h3>Conclusion</h3><p>Bullet charts are an effective way to visualize business performance by combining multiple indicators into a single, easy-to-understand chart.</p><p>Using <strong>Deneb and Vega-Lite in Power BI</strong>, we can create flexible, professional, and highly customized bullet charts that go beyond traditional visualization options.</p><p>Whether you are analyzing sales, financial results, operational KPIs, or educational assessment data, bullet charts can help communicate performance more effectively.</p><p>🎥 <strong>Watch the complete step-by-step video tutorial:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQBdKaClJ9HM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQBdKaClJ9HM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQBdKaClJ9HM%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e028d3a9cda1fd1570446d1371ca5cfb/href">https://medium.com/media/e028d3a9cda1fd1570446d1371ca5cfb/href</a></iframe><h3>Follow for More Data Analytics Tutorials</h3><p>I regularly share practical tutorials covering:</p><ul><li>Microsoft Power BI</li><li>Deneb and Vega-Lite</li><li>Data Analytics and Visualization</li><li>SQL and Python</li><li>Data Engineering</li><li>Microsoft Fabric</li><li>Azure Databricks</li><li>Data Science</li></ul><p><strong>Keep learning, keep exploring, and turn data into meaningful insights!</strong></p><p><em>DataCafe | Data Engineering • Data Science • Business Intelligence</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=002bc2c67a60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Display Statistical Information in Power BI | DataCafe Tutorial]]></title>
            <link>https://medium.com/@pubududewagama/how-to-display-statistical-information-in-power-bi-datacafe-tutorial-97c1402e2cb6?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/97c1402e2cb6</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[power-bi-tutorials]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 19:41:28 GMT</pubDate>
            <atom:updated>2026-11-02T19:41:28.545Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Learn how to create meaningful statistical visualizations in Microsoft Power BI and transform raw data into actionable insights.</em></p><p><strong>By DataCafe | Data Engineering, Data Science &amp; Business Intelligence</strong></p><h3>Introduction</h3><p>Data visualization plays an important role in understanding and interpreting information. While traditional charts display trends and comparisons, statistical visualizations provide deeper insights into data distribution, variability, and overall performance.</p><p>Microsoft Power BI offers powerful capabilities for presenting statistical information through interactive dashboards and customized visuals.</p><p>In this tutorial, we explore how to display statistical measures such as Minimum, Maximum, Mean, Average Score, Highest Value, Lowest Value, and Standard Deviation in a single Power BI chart.</p><p>Whether you are a Data Analyst, Business Intelligence Developer, Data Scientist, or Power BI enthusiast, this tutorial will help you create more informative and professional dashboards.</p><h3>Watch the Video Tutorial</h3><p><strong>Display Statistical Information in Power BI | DataCafe</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVE8Zfy9EDVU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVE8Zfy9EDVU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVE8Zfy9EDVU%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8319fc0bc10eeb0ecd92d8fc5993db1/href">https://medium.com/media/b8319fc0bc10eeb0ecd92d8fc5993db1/href</a></iframe><p>In this video, I demonstrate how to visualize multiple statistical measures in Power BI using an example of student assessment performance across different weeks.</p><h3>1. Understanding Statistical Information in Power BI</h3><p>Statistical analysis helps us understand patterns, distributions, and variations within a dataset.</p><p>Some of the most commonly used statistical measures include:</p><p><strong>Minimum (Min): </strong>The smallest value in a dataset</p><p><strong>Maximum (Max)</strong>:The largest value in a dataset</p><p><strong>Mean: </strong>The arithmetic average of the values</p><p><strong>Average Score: </strong>The average performance score</p><p><strong>Highest Value: </strong>The highest recorded score</p><p><strong>Lowest Value: </strong>The lowest recorded score</p><p><strong>Standard Deviation: </strong>A measure of how widely values vary around the mean</p><p>Although Mean and Average Score can represent the same calculation, Average Score is often used as a business-friendly label in performance reporting. Similarly, Minimum and Lowest Value, and Maximum and Highest Value, may refer to the same underlying measures.</p><h3>2. Why Visualize Statistical Measures?</h3><p>Traditional bar charts are useful for comparing values, but they do not always communicate the complete statistical picture.</p><p>For example, two student groups may have the same average assessment score but very different performance distributions.</p><p>By incorporating statistical measures into Power BI visuals, we can:</p><ul><li>Identify minimum and maximum performance levels.</li><li>Compare average scores across different periods.</li><li>Understand the variability of results.</li><li>Identify unusual performance patterns.</li><li>Support evidence-based decision-making.</li><li>Present complex information in a single dashboard.</li></ul><h3>3. Example: Student Assessment Performance Dashboard</h3><p>Consider a dataset containing student assessment scores collected across multiple weeks.</p><p>Instead of displaying only the average score for each week, we can create a statistical visualization that combines several measures.</p><p><strong>Example dashboard components:</strong></p><ul><li>Light blue bars representing score ranges.</li><li>Markers representing average scores and other summary statistics.</li><li>Error bars representing statistical variability.</li><li>Weekly comparisons for identifying performance changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*Lt6SmTxGoWQoFJ1hk8KAzg.png" /><figcaption>Boxplot</figcaption></figure><p>This visualization allows users to understand both the overall performance and the distribution of scores across assessment periods.</p><h3>4. Creating Statistical Measures in Power BI Using DAX</h3><p>Power BI supports Data Analysis Expressions (DAX) for creating calculated measures.</p><p>Assuming your dataset is named AssessmentScores and contains a numeric column called Score, you can create the following measures.</p><p><strong>Minimum Score</strong></p><pre>Minimum Score =<br>MIN(AssessmentScores[Score])</pre><p><strong>Maximum Score</strong></p><pre>Maximum Score =<br>MAX(AssessmentScores[Score])</pre><p><strong>Mean Score</strong></p><pre>Mean Score =<br>AVERAGE(AssessmentScores[Score])</pre><p><strong>Average Score</strong></p><pre>Average Score =<br>AVERAGE(AssessmentScores[Score])</pre><p><strong>Standard Deviation</strong></p><pre>Standard Deviation =<br>STDEV.P(AssessmentScores[Score])</pre><p>STDEV.P calculates population standard deviation. If your data represents a sample rather than the full population, use STDEV.S.</p><p>These measures can be used in Power BI charts, tables, KPI cards, and custom visuals.</p><h3>5. Designing a Statistical Visualization</h3><p>A well-designed statistical chart should communicate complex information without overwhelming the reader.</p><p>When developing your Power BI visualization, consider the following principles:</p><p><strong>Use consistent colors:</strong> Assign meaningful colors to statistical measures so users can distinguish them easily.</p><p><strong>Include clear labels:</strong> Display values and units wherever necessary.</p><p><strong>Show variability:</strong> Use ranges and error bars to illustrate variation in the dataset.</p><p><strong>Provide context:</strong> Add titles, legends, and descriptions to help users interpret the information.</p><p><strong>Keep the design simple:</strong> Avoid unnecessary visual elements that distract from the data.</p><h3>6. Real-World Applications</h3><p>Statistical visualizations are useful across many industries.</p><p><strong>Education Analytics:</strong> Analyze student assessment performance, average scores, and learning progress.</p><p><strong>Healthcare Analytics:</strong> Monitor clinical indicators, patient outcomes, and variations in measurements.</p><p><strong>Financial Analytics:</strong> Analyze financial performance, transaction patterns, and risk indicators.</p><p><strong>Business Intelligence:</strong> Compare sales performance, operational metrics, and organizational KPIs.</p><p><strong>Data Science:</strong> Explore distributions and variability before conducting advanced analysis.</p><h3>7. Key Takeaways</h3><p>Displaying statistical information in Power BI helps transform traditional reporting into more informative analytical dashboards.</p><p>By combining measures such as Minimum, Maximum, Mean, Average Score, and Standard Deviation, we can better understand both performance and variability.</p><p>The goal is not simply to display numbers, but to communicate meaningful insights that support better decisions.</p><h3>Conclusion</h3><p>Microsoft Power BI provides flexible tools for creating statistical visualizations that communicate complex information clearly.</p><p>In the accompanying video tutorial, I demonstrate an approach to displaying statistical information within a single Power BI chart.</p><p><strong>Watch the complete tutorial on YouTube:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVE8Zfy9EDVU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVE8Zfy9EDVU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVE8Zfy9EDVU%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8319fc0bc10eeb0ecd92d8fc5993db1/href">https://medium.com/media/b8319fc0bc10eeb0ecd92d8fc5993db1/href</a></iframe><p>If you found this article helpful, follow <strong>DataCafe</strong> for more practical tutorials covering:</p><ul><li>Microsoft Power BI and Business Intelligence</li><li>Data Analytics and Data Visualization</li><li>SQL and Python</li><li>Data Engineering</li><li>Microsoft Fabric and Azure Databricks</li><li>Data Science and Cloud Technologies</li></ul><p><strong>Let’s turn data into insights!</strong></p><p><em>DataCafe — Exploring Data Engineering, Data Science, and Data Analytics.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97c1402e2cb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Dim_Date Table with Medallion Architecture: From Silver to Gold]]></title>
            <link>https://medium.com/@pubududewagama/building-a-dim-date-table-with-medallion-architecture-from-silver-to-gold-9794286c8c74?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/9794286c8c74</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[fabric]]></category>
            <category><![CDATA[azure-data-lake]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 21:07:15 GMT</pubDate>
            <atom:updated>2025-08-21T21:07:15.145Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*VfVs4sVi-YD5czHBenWgDw.png" /></figure><p>In the world of modern data platforms, raw data alone isn’t enough — it needs to be organized, cleaned, and transformed into business-ready insights. That’s where the <strong>Medallion Architecture</strong> comes in. Popularized by Databricks and now widely adopted in Microsoft Fabric, the Medallion framework structures your data into three layers: <strong>Bronze (raw)</strong>, <strong>Silver (cleaned &amp; standardized)</strong>, and <strong>Gold (business-ready)</strong>.</p><p>One of the most essential,yet often overlooked ,building blocks in analytics is the <strong>Date Dimension (Dim_Date)</strong>. Almost every report, dashboard, or data model needs a reliable calendar table for time-based analysis, whether it’s tracking sales over months, calculating year-to-date metrics, or comparing growth across quarters.</p><p>In this post, I’ll walk you through how to create a <strong>Silver layer </strong><strong>silver_dim_date table</strong> as a clean, standardized foundation, and then transform it into a <strong>Gold layer </strong><strong>Dim_Date table</strong> that’s optimized for reporting and analytics. By the end, you’ll see how the Medallion approach ensures data consistency, reusability, and scalability — while keeping your models simple and robust.</p><h3>Step 1: Load Packages</h3><p>We start by importing the required <strong>PySpark functions, types, and datetime utilities</strong>.<br> These packages allow us to manipulate dates, extract components like year or month, and define the schema for our dimension table.</p><blockquote>from pyspark.sql.functions import *</blockquote><blockquote>from datetime import datetime, timedelta</blockquote><blockquote>from pyspark.sql.types import *</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f4IGihNWO_UhonheNXh14Q.png" /></figure><h3>Step 2: Define Boundaries</h3><p>Next, we set the <strong>date range</strong> for our Date Dimension.<br> In this example, we build a calendar that spans from <strong>January 1, 2000</strong> to <strong>December 31, 2030</strong>.<br> This ensures we have enough historical and future dates to support reporting and forecasting needs.</p><blockquote>start_date = ‘2000–01–01’</blockquote><blockquote>end_date = ‘2030–12–31’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4_bxWCE3fe87v67pY-bBg.png" /></figure><h3>Step 3: Define Schema, Holidays, and Transformations</h3><p>Here, we generate a continuous sequence of dates within our boundaries using Spark’s sequence function.</p><ul><li>We define a <strong>schema</strong> for the Dim_Date table (all columns like Year, Month, Quarter, Day of Week, etc.).</li><li>We also add a list of <strong>holidays</strong> for 2024–2025, which can later be used to flag working vs. non-working days.</li><li>Finally, we enrich the raw date sequence by extracting multiple attributes (e.g., Year_Quarter, Month_Short_Name, Week_Number_Of_Year) and build a clean DataFrame ready for analytics.</li></ul><blockquote>date_df = spark.sql(f”””</blockquote><blockquote>SELECT sequence(to_date(‘{start_date}’), to_date(‘{end_date}’), interval 1 day) as date_seq</blockquote><blockquote>“””).selectExpr(“explode(date_seq) as Date”)</blockquote><blockquote># Define schema for DimDate</blockquote><blockquote>dim_date_schema = StructType([</blockquote><blockquote>StructField(“Date_SK”, IntegerType(), False),</blockquote><blockquote>StructField(“Date”, DateType(), False),</blockquote><blockquote>StructField(“Year”, IntegerType(), False),</blockquote><blockquote>StructField(“Year_Short”, IntegerType(), False),</blockquote><blockquote>StructField(“Quarter_Number”, IntegerType(), False),</blockquote><blockquote>StructField(“Year_Quarter”, StringType(), False),</blockquote><blockquote>StructField(“Quarter”, StringType(), False),</blockquote><blockquote>StructField(“Year_Month”, StringType(), False),</blockquote><blockquote>StructField(“Year_Month_Number”, IntegerType(), False),</blockquote><blockquote>StructField(“Month_Name”, StringType(), False),</blockquote><blockquote>StructField(“Month_Short_Name”, StringType(), False),</blockquote><blockquote>StructField(“Year_Month_Name”, StringType(), False),</blockquote><blockquote>StructField(“Year_Month_Short_Name”, StringType(), False),</blockquote><blockquote>StructField(“Month_Number”, IntegerType(), False),</blockquote><blockquote>StructField(“Day_Of_Month”, IntegerType(), False),</blockquote><blockquote>StructField(“Day_Of_Week_Number”, IntegerType(), False),</blockquote><blockquote>StructField(“Day_Of_Week_Name”, StringType(), False),</blockquote><blockquote>StructField(“Day_Of_Week_Short_Name”, StringType(), False),</blockquote><blockquote>StructField(“Week_Number_Of_Month”, IntegerType(), False),</blockquote><blockquote>StructField(“Week_Number_Of_Year”, IntegerType(), False),</blockquote><blockquote>StructField(“Day_Of_Year”, IntegerType(), False)</blockquote><blockquote>])</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q0Poq1-9ebWUy4DAPETOtg.png" /></figure><blockquote>holidays_2024_2025 = [</blockquote><blockquote>‘2024–01–01’, # New Year’s Day</blockquote><blockquote>‘2024–02–19’, # Family Day</blockquote><blockquote>‘2024–03–29’, # Good Friday</blockquote><blockquote>‘2024–04–21’, # Easter Monday</blockquote><blockquote>‘2024–05–20’, # Victoria Day</blockquote><blockquote>‘2024–07–01’, # Canada Day</blockquote><blockquote>‘2024–08–05’, # British Columbia Day</blockquote><blockquote>‘2024–09–02’, # Labour Day</blockquote><blockquote>‘2024–09–30’, # Truth and Reconciliation</blockquote><blockquote>‘2024–10–14’, # Thanksgiving</blockquote><blockquote>‘2024–11–11’, # Remembrance Day</blockquote><blockquote>‘2024–12–24’, # Christmas Eve</blockquote><blockquote>‘2024–12–25’, # Christmas Day</blockquote><blockquote>‘2024–12–24’, # Christmas Eve</blockquote><blockquote>‘2024–12–26’, # Boxing D,ay</blockquote><blockquote>‘2024–12–31’, # New Year’s Eve</blockquote><blockquote>‘2025–01–01’, # New Year’s Day</blockquote><blockquote>‘2025–02–17’, # Family Day</blockquote><blockquote>‘2025–04–18’, # Good Friday</blockquote><blockquote>‘2025–04–21’, # Easter Monday</blockquote><blockquote>‘2025–05–19’, # Victoria Day</blockquote><blockquote>‘2025–07–01’, # Canada Day</blockquote><blockquote>‘2025–08–04’, # British Columbia Day</blockquote><blockquote>‘2025–09–01’, # Labour Day</blockquote><blockquote>‘2025–09–30’, # Truth and Reconciliation</blockquote><blockquote>‘2025–10–13’, # Thanksgiving</blockquote><blockquote>‘2025–11–11’, # Remembrance Day</blockquote><blockquote>‘2025–12–24’, # Christmas Eve</blockquote><blockquote>‘2025–12–25’, # Christmas Day</blockquote><blockquote>‘2025–12–26’, # Boxing Day</blockquote><blockquote>‘2025–12–31’ # New Year’s Eve</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47nvfrJH4Xp0awsk6tHkFA.png" /></figure><blockquote># Extract date parts to populate the DimDate table</blockquote><blockquote>dim_date_df = date_df.withColumn(“Date_SK”, date_format(col(“Date”), “yyyyMMdd”).cast(“int”)) \</blockquote><blockquote>.withColumn(“Year”, year(col(“Date”)).cast(“int”)) \</blockquote><blockquote>.withColumn(“Year_Short”, date_format(col(“Date”), “yy”).cast(“int”)) \</blockquote><blockquote>.withColumn(“Quarter_Number”, quarter(col(“Date”)).cast(“int”)) \</blockquote><blockquote>.withColumn(“Year_Quarter”, expr(“concat(Year, ‘-Q’, Quarter_Number)”)) \</blockquote><blockquote>.withColumn(“Quarter”, expr(“concat(‘Q’, Quarter_Number)”)) \</blockquote><blockquote>.withColumn(“Year_Month”, date_format(col(“Date”), “yyyy-MM”)) \</blockquote><blockquote>.withColumn(“Year_Month_Number”, date_format(col(“Date”), “yyyyMM”).cast(“int”)) \</blockquote><blockquote>.withColumn(“Month_Name”, date_format(col(“Date”), “MMMM”)) \</blockquote><blockquote>.withColumn(“Month_Short_Name”, date_format(col(“Date”), “MMM”)) \</blockquote><blockquote>.withColumn(“Year_Month_Name”, expr(“concat( Year, ‘-’,date_format(Date, ‘MMMM’))”)) \</blockquote><blockquote>.withColumn(“Year_Month_Short_Name”, expr(“concat(Year , ‘-’,date_format(Date, ‘MMM’) )”)) \</blockquote><blockquote>.withColumn(“Month_Number”, month(col(“Date”)).cast(“int”)) \</blockquote><blockquote>.withColumn(“Day_Of_Month”, dayofmonth(col(“Date”)).cast(“int”)) \</blockquote><blockquote>.withColumn(“Day_Of_Week_Number”, dayofweek(col(“Date”)).cast(“int”)) \</blockquote><blockquote>.withColumn(“Day_Of_Week_Name”, date_format(col(“Date”), “EEEE”)) \</blockquote><blockquote>.withColumn(“Day_Of_Week_Short_Name”, date_format(col(“Date”), “EEE”)) \</blockquote><blockquote>.withColumn(“Week_Number_Of_Month”, expr(“ceil(dayofmonth(Date)/7)”).cast(“int”)) \</blockquote><blockquote>.withColumn(“Week_Number_Of_Year”, weekofyear(col(“Date”)).cast(“int”)) \</blockquote><blockquote>.withColumn(“Day_Of_Year”, dayofyear(col(“Date”)).cast(“int”))</blockquote><blockquote># Reorder columns</blockquote><blockquote>columns_order = [‘Date_SK’]+[c for c in dim_date_df.columns if c not in [‘Date_SK’,’Is_UCW_Working’, ‘Is_UCW_Holiday’,’Fiscal_Year’,’Academic_Year’]]</blockquote><blockquote>dim_date_df = dim_date_df.select(columns_order)</blockquote><blockquote># Apply the schema to the DataFrame</blockquote><blockquote>dim_date_df = spark.createDataFrame(dim_date_df.rdd, schema=dim_date_schema)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ToL4cKUT-5v-lspDZ_tuwQ.png" /></figure><h3>Step 4: Create the Silver Layer Table</h3><p>The <strong>Silver Layer</strong> represents <strong>clean, structured, and enriched data</strong>.<br> Here, we create the silver_dim_date table with a <strong>Delta Lake format</strong>, which supports ACID transactions and time travel.<br> This table provides a single source of truth for all standardized date-related attributes.</p><blockquote>%%sql</blockquote><blockquote>CREATE TABLE silver_dim_date (</blockquote><blockquote>Date_SK INT NOT NULL,</blockquote><blockquote>Date DATE,</blockquote><blockquote>Year INT,</blockquote><blockquote>Year_Short INT,</blockquote><blockquote>Quarter_Number INT,</blockquote><blockquote>Year_Quarter STRING,</blockquote><blockquote>Quarter STRING,</blockquote><blockquote>Year_Month STRING,</blockquote><blockquote>Year_Month_Number INT,</blockquote><blockquote>Month_Name STRING,</blockquote><blockquote>Year_Month_Name STRING,</blockquote><blockquote>Month_Short_Name STRING,</blockquote><blockquote>Year_Month_Short_Name STRING,</blockquote><blockquote>Month_Number INT,</blockquote><blockquote>Day_Of_Month INT,</blockquote><blockquote>Day_Of_Week_Number INT,</blockquote><blockquote>Day_Of_Week_Name STRING,</blockquote><blockquote>Day_Of_Week_Short_Name STRING,</blockquote><blockquote>Week_Number_Of_Month INT,</blockquote><blockquote>Week_Number_Of_Year INT,</blockquote><blockquote>Day_Of_Year INT</blockquote><blockquote>) USING DELTA;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*WWlAq8mKkfjrxYsP4vB0Ig.png" /></figure><h3>Step 5: Write Data to Silver Layer</h3><p>We then write our transformed dim_date_df DataFrame into the silver_dim_date Delta table.<br> This makes the Silver layer available for downstream processes and ensures consistency across the platform.</p><blockquote>dim_date_df.write.format(“delta”).mode(“overwrite”).saveAsTable(“silver_dim_date”)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*1pP18qDh6ABTZlc9U1ZGRg.png" /></figure><h3>Step 6: Create the Gold Layer Table</h3><p>The <strong>Gold Layer</strong> is where data is optimized for <strong>business consumption</strong>.<br> We create the dim_date table as a Gold layer entity.<br> This layer is typically consumed directly by BI tools like Power BI or used for advanced reporting and analytics.</p><blockquote>%%sql</blockquote><blockquote>CREATE TABLE dim_date (</blockquote><blockquote>Date_SK INT NOT NULL,</blockquote><blockquote>Date DATE,</blockquote><blockquote>Year INT,</blockquote><blockquote>Year_Short INT,</blockquote><blockquote>Quarter_Number INT,</blockquote><blockquote>Year_Quarter STRING,</blockquote><blockquote>Quarter STRING,</blockquote><blockquote>Year_Month STRING,</blockquote><blockquote>Year_Month_Number INT,</blockquote><blockquote>Month_Name STRING,</blockquote><blockquote>Year_Month_Name STRING,</blockquote><blockquote>Month_Short_Name STRING,</blockquote><blockquote>Year_Month_Short_Name STRING,</blockquote><blockquote>Month_Number INT,</blockquote><blockquote>Day_Of_Month INT,</blockquote><blockquote>Day_Of_Week_Number INT,</blockquote><blockquote>Day_Of_Week_Name STRING,</blockquote><blockquote>Day_Of_Week_Short_Name STRING,</blockquote><blockquote>Week_Number_Of_Month INT,</blockquote><blockquote>Week_Number_Of_Year INT,</blockquote><blockquote>Day_Of_Year INT</blockquote><blockquote>) USING DELTA;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*6Y6QpC8suB5cgcWTRgANqw.png" /></figure><h3>Step 7: Write Data to Gold Layer</h3><p>We publish the enriched and standardized Silver data into the <strong>Gold </strong><strong>dim_date table</strong>.<br> This makes it easy for business users and analysts to query a reliable Date Dimension without worrying about data preparation.</p><blockquote>gold_dim_date_table_path = ‘Tables/dim_date’</blockquote><blockquote>dim_date_df.write.format(“delta”).mode(“overwrite”).save(gold_dim_date_table_path)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*TaiE5JJBgSClQKAOY2F5mQ.png" /></figure><h3>Step 8: View Data in Gold Layer</h3><p>Finally, we validate the pipeline by loading the Gold dim_date table back into a Spark DataFrame and displaying the first few rows.<br> This confirms that our Silver → Gold pipeline has successfully produced a ready-to-use <strong>Date Dimension</strong> for analytics.</p><blockquote># Load table into a Spark DataFrame</blockquote><blockquote>df = spark.read.table(&quot;dim_date&quot;)</blockquote><blockquote># Show rws</blockquote><blockquote>display(df)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*eEDIxsjajS4CC5E9H9wauw.png" /></figure><h3>Conclusion</h3><p>The <strong>Date Dimension</strong> is one of the most fundamental building blocks in any analytics solution. By implementing it through the <strong>Medallion Architecture</strong>, we ensure that the data is not only complete and accurate but also reusable across multiple use cases.</p><p>In this walkthrough, we built a silver_dim_date table in the <strong>Silver layer</strong> to capture a clean and enriched view of calendar data, and then published it into the <strong>Gold </strong><strong>dim_date table</strong>, which is optimized for business consumption. This separation of concerns keeps our pipeline maintainable, scalable, and aligned with best practices.</p><p>With a strong Dim_Date foundation in place, downstream reporting in tools like Power BI or advanced analytics in notebooks becomes simpler and more consistent. And while we demonstrated this with dates, the same Silver → Gold approach applies to other dimensions and facts in your data model.</p><p>By following this layered design, you’re not just creating a Date Dimension, you’re building a <strong>robust data foundation</strong> that supports accurate, reliable, and trustworthy analytics across your organization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9794286c8c74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Microsoft Fabric?]]></title>
            <link>https://medium.com/event-driven-utopia/what-is-microsoft-fabric-1f5f93e3a2d4?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f5f93e3a2d4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[fabric]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Wed, 07 Feb 2024 21:18:10 GMT</pubDate>
            <atom:updated>2024-04-07T17:05:39.764Z</atom:updated>
            <content:encoded><![CDATA[<p>Microsoft Fabric is an all-in-one analytics solution for enterprises that covers everything from data movement to data science, real-time analytics, and business intelligence. It offers a comprehensive suite of services, including a data lake, data engineering, and data integration, all in one place.</p><p>To Watch the video tutorial, you can access:-<a href="https://www.youtube.com/watch?v=13CTq4NQpiA&amp;t=129s">https://www.youtube.com/watch?v=13CTq4NQpiA&amp;t=129s</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sIwq3ZWNUhLyB1RS2hsjWw.png" /></figure><p>You no longer have to patch together various services from various vendors when using Fabric. Instead, you can benefit from a fully integrated, all-encompassing, and user-friendly platform that is created to make your analytics needs simpler.</p><p>The platform is based on Software as a Service (SaaS), which raises the bar for simplicity and integration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cC8UK2L7DwX1uErmLI2PGw.png" /></figure><p><strong>Data Engineering: </strong>In order to do large-scale data transformation and democratize data through the lakehouse, data engineers need a top-notch Spark platform with exceptional writing experiences. This is what Data Engineering Experience offers. Spark tasks and notebooks can be planned to the integration of Microsoft Fabric Spark with Data Factory.</p><p><strong>Data Factory:</strong> Azure Data Factory combines the simplicity of Power Query with the scale and power of Azure Data Factory. You can use more than 200 native connectors to connect to data sources on-premises and in the cloud.</p><p><strong>Data Science: </strong>The Data Science experience enables you to build, deploy, and operationalize machine learning models seamlessly within your Fabric experience. It integrates with Azure Machine Learning to provide built-in experiment tracking and a model registry. Data scientists are empowered to enrich organizational data with predictions and allow business analysts to integrate those predictions into their BI reports. This way, it shifts from descriptive to predictive insights.</p><p><strong>Data Warehouse:</strong> Data Warehouse experience provides industry-leading SQL performance and scale. It fully separates compute from storage, enabling independent scaling of both components. Additionally, it natively stores data in the open Delta Lake format.</p><p><strong>Real-Time Analytics:</strong> observational data, which is collected from various sources such as apps, IoT devices, human interactions, and so many more. It’s currently the fastest-growing data category. This data is often semi-structured in formats like JSON or text. It comes in at high volume, with shifting schemas. These characteristics make it hard for traditional data-warehousing platforms to work with. Real-Time Analytics is best-in-class engine for observational data analytics.</p><p><strong>Power BI:</strong> Power BI is the world’s leading business intelligence platform. It ensures that business owners can access all the data in Fabric quickly and intuitively to make better decisions with the data.</p><p><strong>OneLake</strong> is the backbone of Microsoft Fabric. The data lake is the foundation on which all the fabric services are built. Microsoft Fabric Lake is also known as OneLake. It’s built into the Fabric service and provides a unified location to store all organizational data where the experiences operate.</p><p>OneLake is built on top of ADLS (Azure Data Lake Storage) Gen2. It provides a single SaaS experience and a tenant-wide store for data that serves both professional and citizen developers. The OneLake SaaS experience simplifies the experiences, eliminating the need for users to understand any infrastructure concepts such as resource groups, RBAC (Role-Based Access Control), Azure Resource Manager, redundancy, or regions. Additionally it doesn’t require the user to even have an Azure account.</p><p><strong>Microsoft Purview</strong> is a comprehensive data governance solution designed to empower organizations in discovering, classifying, and managing their data assets across the enterprise. This platform addresses challenges related to data sprawl, regulatory compliance, and data privacy by providing features such as data discovery and cataloging, automated data classification, sensitivity labeling, data lineage tracking, and impact analysis. Purview offers a centralized hub for understanding the data landscape, supporting users in visualizing data relationships, and ensuring compliance with data protection policies. It integrates seamlessly with other Microsoft services like Azure Synapse Analytics, Azure Data Factory, and Power BI, contributing to a cohesive and efficient data ecosystem. For the latest and most detailed information about Microsoft Purview, it is recommended to refer to Microsoft’s official documentation or website.</p><p>Thank you !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f5f93e3a2d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/event-driven-utopia/what-is-microsoft-fabric-1f5f93e3a2d4">What is Microsoft Fabric?</a> was originally published in <a href="https://medium.com/event-driven-utopia">Tributary Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing Delta Lake Performance with Indexing: A Comprehensive Guide]]></title>
            <link>https://medium.com/event-driven-utopia/enhancing-delta-lake-performance-with-indexing-a-comprehensive-guide-099455821334?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/099455821334</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[index]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[query-optimization]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Mon, 29 Jan 2024 16:50:30 GMT</pubDate>
            <atom:updated>2024-01-30T09:15:36.918Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7zRx302wfrbvAOqw" /><figcaption>Photo by <a href="https://unsplash.com/@syinq?utm_source=medium&amp;utm_medium=referral">Susan Q Yin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Delta Lake is a powerful open-source storage layer that brings ACID transactions to Apache Spark and big data workloads. It provides reliability and performance improvements over traditional data lakes by enabling features such as s<strong>chema enforcement</strong>, <strong>data versioning</strong>, and <strong>unified batch</strong> and <strong>streaming processing</strong>. Delta tables, at the core of Delta Lake, offer a structured and efficient way to organize and manage data within a data lake environment.</p><p>While Delta Lake offers several benefits, the size and complexity of data lakes can lead to performance challenges. As datasets grow, query response times may increase, impacting the overall efficiency of data access. This is where performance optimization becomes crucial, and one powerful tool for achieving this optimization is indexing.</p><h3>Why Indexing Matters</h3><p>Indexing plays a pivotal role in improving query performance by creating a data structure that allows for faster data retrieval. In the context of Delta tables, indexing involves creating an organized reference to the table’s data based on selected columns. This organizational structure significantly reduces the time it takes to search for and locate specific records, resulting in quicker and more efficient query execution.</p><p>Traditional data lakes often rely on full table scans, which can become inefficient as the volume of data grows. Indexing in Delta tables provides a contrast by offering a more targeted approach to data retrieval. Instead of scanning the entire dataset, indexed queries can swiftly pinpoint relevant information, resulting in a substantial reduction in query execution times. This distinction becomes particularly pronounced as datasets scale up, making Delta Lake a compelling choice for performance-conscious data lake architectures.</p><h3>Delta Table Basics</h3><p>Delta tables maintain the advantages of traditional Parquet-based data lakes while incorporating transactional capabilities. They support operations like insert, update, delete, and merge, making them a versatile choice for data lake management. Delta tables also introduce the concept of delta commits, ensuring atomicity, consistency, isolation, and durability (ACID) properties in data operations.</p><p>Delta tables address some of the inherent challenges of data lakes, such as lack of transactional support and slow query performance. They provide a unified data management platform that seamlessly integrates batch and streaming data processing. The ability to evolve schemas over time and maintain a version history of the data sets Delta tables apart as a robust solution for modern data lake architectures.</p><h3>Implementing Indexing in Delta Tables</h3><p><strong>Step 1: Creating a Delta Table</strong></p><p>Creating a Delta table involves defining the schema and inserting data into the table. This can be achieved using Apache Spark and Delta Lake’s Python API, as shown in the sample code.</p><pre># Sample code for creating a Delta table<br>from delta import DeltaTable<br><br># Define your DataFrame<br>data = [...]<br><br># Create Delta table<br>delta_table = DeltaTable.createOrReplace(spark, &quot;your_delta_table_path&quot;).alias(&quot;delta_table&quot;)<br>delta_table.insert(data)</pre><p><strong>Step 2: Understanding the Columns to be Indexed</strong></p><p>Before adding an index, it’s essential to identify the columns that will benefit the most from indexing. Analyze query patterns and select columns frequently used in filtering or sorting operations.</p><p><strong>Step 3: Use Delta’s </strong><strong>OPTIMIZE Command to Add an Index</strong></p><p>Once the target columns are identified, the OPTIMIZE command can be used to add an index to the Delta table. This process involves rearranging the data in a way that facilitates faster access to the selected columns.</p><pre># Sample code for adding an index to a Delta table<br>delta_table = DeltaTable.forPath(spark, &quot;your_delta_table_path&quot;).alias(&quot;delta_table&quot;)<br><br># Define columns to be indexed<br>indexed_columns = [&quot;column1&quot;, &quot;column2&quot;]<br><br># Add index using OPTIMIZE command<br>delta_table.optimize(indexed_columns)</pre><p>This step-by-step guide sets the foundation for optimizing Delta tables with indexes, enhancing the overall performance of data retrieval operations.</p><h3>Choosing the Right Columns for Indexing</h3><p>Selecting the right columns for indexing is a critical decision that impacts the overall effectiveness of indexing. It’s important to consider the cardinality of the columns, the frequency of their use in queries, and the trade-off between performance gains and storage requirements.</p><p>While indexing improves query performance, it comes with the cost of increased storage requirements. Striking a balance between performance gains and storage overhead is crucial. Prioritize columns that offer substantial performance improvements while being mindful of the additional storage space required for maintaining indexes.</p><h3>Monitoring and Managing Indexes</h3><p>Monitoring the performance of indexes is essential for maintaining a well-optimized data lake. Utilize the tools and techniques provided by Delta Lake to track index performance, identify bottlenecks, and make informed decisions for further optimizations.</p><p>Data requirements and access patterns may evolve over time, necessitating adjustments to existing indexes. Learn how to modify or remove indexes when needed to accommodate changing query patterns and optimize performance accordingly.</p><h3>Performance Testing and Benchmarking</h3><p>After implementing indexes, it’s crucial to conduct performance tests to evaluate the impact on query execution times. Explore strategies for designing and executing effective performance tests, considering factors such as query complexity, dataset size, and concurrent user loads.</p><h3>Conclusion</h3><p>In conclusion, indexing in Delta tables is not merely a technical enhancement; it’s a strategic investment in the efficiency and agility of your data lake. With the right indexing strategy, you can navigate the complexities of large-scale data processing with confidence, ensuring that your data remains a valuable asset, easily accessible, and responsive to the evolving needs of your organization. Happy indexing!</p><p>Thank you !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=099455821334" width="1" height="1" alt=""><hr><p><a href="https://medium.com/event-driven-utopia/enhancing-delta-lake-performance-with-indexing-a-comprehensive-guide-099455821334">Enhancing Delta Lake Performance with Indexing: A Comprehensive Guide</a> was originally published in <a href="https://medium.com/event-driven-utopia">Tributary Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When to partition tables on Data Lake]]></title>
            <link>https://medium.com/event-driven-utopia/when-to-partition-tables-on-data-lake-6debb24feb4a?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/6debb24feb4a</guid>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[query-optimization]]></category>
            <category><![CDATA[partition]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Mon, 22 Jan 2024 20:00:04 GMT</pubDate>
            <atom:updated>2024-01-26T19:58:39.347Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vJHlJ0O1eFULfqf2" /><figcaption>Photo by <a href="https://unsplash.com/@sunday_digital?utm_source=medium&amp;utm_medium=referral">Nastuh Abootalebi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Partitioning is a fundamental concept in distributed data systems like Databricks, aimed at improving data organization and retrieval efficiency. When dealing with vast datasets, breaking them down into smaller, more manageable partitions based on specific columns is crucial. Databricks supports both static and dynamic partitioning. Static partitioning involves explicitly defining partition values, while dynamic partitioning automatically creates partitions based on the data.</p><p>Table partitioning plays a pivotal role in optimizing query performance and resource utilization. By organizing data into partitions, Databricks can efficiently skip irrelevant portions of the dataset during query execution, reducing the overall processing time. Understanding the nuances of static and dynamic partitioning is essential for tailoring partitioning strategies to specific use cases and dataset characteristics.</p><h3><strong>When to Partition Tables:</strong></h3><p>Determining when to partition tables is a critical decision that impacts query performance and resource efficiency. One key consideration is the size of the dataset. When dealing with large datasets, partitioning becomes instrumental in distributing the computational load and enhancing parallel processing capabilities. Additionally, analyzing common query patterns helps identify columns frequently used in WHERE clauses, which are prime candidates for partitioning. If data distribution is uneven, partitioning can help balance the workload across computing resources.</p><p>Deciding when to partition also involves assessing the nature of the data and its distribution. If certain columns are frequently filtered or involved in joins, partitioning on those columns can significantly improve query performance. Understanding the specific characteristics of the dataset and query patterns is essential for making informed decisions about when to implement table partitioning.</p><h3><strong>Choosing the Right Columns for Partitioning:</strong></h3><p>Choosing the right columns for partitioning is a strategic decision that directly impacts query efficiency. Columns that are frequently used in WHERE clauses for filtering or involved in join conditions are prime candidates for partitioning. By partitioning on these columns, Databricks can perform more targeted scans, reducing the amount of data processed during query execution. Date or time columns are often suitable choices for partitioning, especially in scenarios involving time-series data.</p><p>The decision-making process should involve a careful analysis of the dataset and an understanding of how queries interact with the data. The goal is to select columns that align with common filtering and joining operations, optimizing the partitioning strategy for the specific use case.</p><h3>Avoid Over-Partitioning:</h3><p>While partitioning is a powerful optimization technique, over-partitioning can lead to unintended consequences. Each partition comes with metadata overhead, and an excessive number of partitions can increase storage costs and complicate management. It’s essential to strike a balance between optimizing query performance and avoiding unnecessary overhead.</p><p>Finding the right partition size is crucial. If partitions are too small, the metadata overhead can outweigh the benefits of partitioning. Conversely, if partitions are too large, the advantages of parallel processing may diminish. Regular monitoring and adjustment of the partitioning strategy help maintain an optimal balance, ensuring that the benefits of partitioning are realized without unnecessary drawbacks.</p><h3>Dynamic vs. Static Partitioning:</h3><p>Dynamic and static partitioning offer different approaches to organizing data into partitions, each with its advantages and use cases. Dynamic partitioning is particularly useful when dealing with columns with high cardinality, where the number of distinct values is substantial. In this scenario, Databricks can automatically create partitions based on the actual data values, providing flexibility and adaptability.</p><p>On the other hand, static partitioning allows for more control over the partitioning strategy. It involves explicitly defining partition values, which is beneficial when dealing with columns with lower cardinality. This approach enables fine-tuning of the partitioning scheme to align with specific query patterns and use cases. The choice between dynamic and static partitioning depends on the nature of the data and the desired level of control over the partitioning strategy.</p><h3>Optimizing Table Storage Formats:</h3><p>The choice of table storage format is crucial for both storage efficiency and query performance. Databricks supports various file formats, and selecting the appropriate one depends on the specific requirements of the use case. Delta Lake, a reliable open-source storage layer, is often recommended for its ACID compliance and support for schema evolution.</p><p>Compressing data is another optimization technique that can significantly reduce storage requirements and improve data retrieval speed. By compressing data, Databricks can store more information in the same amount of space, leading to cost savings and faster query execution. However, it’s essential to strike a balance, as excessive compression can impact query performance.</p><p>Optimizing table storage formats involves considering the trade-offs between compression ratios, query performance, and storage costs. By selecting the right combination of storage format and compression settings, users can achieve an optimal balance that meets their specific requirements.</p><h3>Maintenance Considerations:</h3><p>Table partitioning is not a one-time configuration; it requires ongoing maintenance and optimization as the dataset evolves. Regularly analyzing and adjusting partitioning strategies based on changes in data distribution, query patterns, and overall system performance is essential for ensuring continued efficiency.</p><p>Monitoring query performance is a key aspect of maintenance. By leveraging Databricks’ monitoring tools, users can track query execution times, resource utilization, and other performance metrics. This information provides insights into the effectiveness of the current partitioning strategy and guides adjustments to maintain optimal performance.</p><p>Maintenance also involves keeping an eye on the overall health of the data platform. As new data is ingested, and query patterns evolve, periodic reviews and adjustments to the partitioning strategy help ensure that the system continues to operate efficiently.</p><h3>Implementing Table Partitioning in Databricks:</h3><p>Implementing table partitioning in Databricks involves a series of steps, and the process can vary depending on the chosen partitioning approach (dynamic or static). Providing a step-by-step guide with code examples is crucial for users looking to implement partitioning in their Databricks environment.</p><p>For dynamic partitioning, users typically leverage Databricks’ capabilities to automatically create partitions based on the data. This may involve configuring the appropriate settings when writing data to the table or leveraging Databricks utilities that support dynamic partition creation.</p><p>In the case of static partitioning, users need to explicitly define partition values during the table creation or modification process. This often requires understanding the specific syntax and conventions for static partitioning in Databricks.</p><p>A comprehensive guide should walk users through the entire process, highlighting key considerations, providing code snippets, and addressing common challenges or pitfalls during the implementation phase.</p><h3>Monitoring and Performance Tuning:</h3><p>Monitoring and performance tuning are ongoing processes that help ensure the continued effectiveness of the partitioning strategy. Databricks provides a set of monitoring tools that users can leverage to gain insights into query performance, resource utilization, and system health.</p><p>Query performance metrics, such as execution times and resource usage, offer valuable feedback on the impact of the partitioning strategy. Users can identify queries that may benefit from further optimization or adjustments to the partitioning scheme.</p><p>Performance tuning involves making informed decisions based on the monitoring data. This may include refining the partitioning strategy, adjusting storage formats or compression settings, and optimizing queries for better efficiency. Regular reviews and proactive tuning contribute to a data platform that consistently delivers optimal performance.</p><h3>Conclusion:</h3><p>In conclusion, table partitioning in Databricks is a powerful optimization technique that, when used judiciously, can significantly enhance query performance and reduce resource overhead. By understanding the principles of partitioning, choosing the right columns, avoiding over-partitioning, selecting appropriate storage formats, and implementing dynamic or static partitioning strategies, users can unlock the full potential of their big data analytics environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6debb24feb4a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/event-driven-utopia/when-to-partition-tables-on-data-lake-6debb24feb4a">When to partition tables on Data Lake</a> was originally published in <a href="https://medium.com/event-driven-utopia">Tributary Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive Guide to Connecting Power BI with Databricks]]></title>
            <link>https://medium.com/event-driven-utopia/how-to-connect-power-bi-with-databricks-baacf44f626b?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/baacf44f626b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 23:41:34 GMT</pubDate>
            <atom:updated>2024-01-18T07:40:44.236Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2ODNkB21jVUS35Bg" /><figcaption>Photo by <a href="https://unsplash.com/@waldemarbrandt67w?utm_source=medium&amp;utm_medium=referral">Waldemar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In today’s data-driven landscape, businesses seek powerful solutions to harness the full potential of their data. This post aims to guide you through the process of connecting Power BI, a leading business intelligence tool, with Databricks, a robust analytics platform. By seamlessly integrating these two technologies, users can unlock a myriad of advantages.</p><p><strong>Advantages of Connecting Power BI with Databricks:</strong></p><ol><li><strong>Unified Data Processing and Visualization:</strong> Combine the powerful data processing capabilities of Databricks with the intuitive visualization tools of Power BI for a unified end-to-end analytics solution.</li><li><strong>Real-time Data Exploration:</strong> Leverage the real-time data processing capabilities of Databricks to enable Power BI to visualize and analyze the most up-to-date information.</li><li><strong>Scalability and Performance:</strong> Databricks, built on Apache Spark, offers scalable and high-performance data processing, ensuring that Power BI can handle large datasets efficiently.</li><li><strong>Advanced Data Transformations:</strong> Utilize the data transformation capabilities of Power BI in tandem with Databricks’ data wrangling capabilities, allowing for advanced and seamless data preparation.</li><li><strong>Collaboration and Data Sharing:</strong> Foster collaboration among data teams by integrating Databricks notebooks and Power BI reports, enabling the sharing of insights and analyses in a collaborative environment.</li><li><strong>Enhanced Predictive Analytics:</strong> Databricks’ machine learning capabilities can be seamlessly integrated with Power BI, enhancing predictive analytics and enabling the creation of more sophisticated data models.</li><li><strong>Cost-Effective and Cloud-Ready: </strong>Leverage the cloud-ready architecture of both Power BI and Databricks for a cost-effective and scalable analytics solution suitable for cloud platforms like Azure and AWS.</li></ol><h3>2. Prerequisites</h3><p>Before embarking on the journey to connect Power BI with Databricks, it’s crucial to ensure that you have the following prerequisites in place:</p><p><strong>Power BI Desktop: </strong>Ensure that you have installed Power BI Desktop. If you don’t have one, you can download it from the Microsoft site.</p><p>Download Link:<a href="https://powerbi.microsoft.com/en-us/downloads/">https://powerbi.microsoft.com/en-us/downloads/</a></p><p><strong>Databricks Workspace Access: </strong>Access to a Databricks workspace is essential. If you don’t have a Databricks account, sign up for one and create a Databricks workspace.</p><h3>3. Setting up Databricks Community Edition</h3><p>Databricks Community Edition provides a free, cloud-based environment for learning and experimenting with Databricks capabilities. Follow these steps to create your Databricks Community Edition account and set up a workspace:</p><ol><li><strong>Go to the Databricks Community Edition website:</strong> Open your web browser and navigate to the Databricks Community Edition website.</li><li><strong>Sign Up for an Account:</strong> Click on the “Sign Up” button to create a new account. You may need to provide your email address and create a password.</li><li><strong>Verification Email:</strong> Check your email inbox for a verification email from Databricks. Click on the verification link to confirm your account.</li><li><strong>Create a New Workspace:</strong> Once your account is verified, log in to the Databricks Community Edition platform.</li><li><strong>Access the Databricks Workspace:</strong> After logging in, you’ll be directed to the Databricks workspace. Here, you can create and manage clusters, notebooks, and libraries.</li><li><strong>Create a Cluster:</strong> To get started, create a cluster. A cluster is a set of computation resources that you can use to run notebooks and jobs.</li></ol><ul><li>Click on the “Clusters” tab in the sidebar.</li><li>Click the “Create Cluster” button.</li><li>Provide a cluster name and configure the cluster settings based on your requirements.</li><li>Click the “Create Cluster” button.</li></ul><p>7. <strong>Create a notebook: </strong>Next, create a notebook where you can run Spark code.</p><ul><li>Click on the “Workspace” tab in the sidebar.</li><li>Click the “Create” button and select “Notebook.”</li><li>Choose the default language (Scala, Python, or SQL) for your notebook.</li><li>Provide a name for the notebook, and select the cluster you created.</li><li>Click the “Create” button.</li></ul><p>8. <strong>Explore the Databricks Workspace: </strong>Take some time to explore the Databricks workspace. Familiarize yourself with the different tabs, such as “Clusters,” “Workspace,” and “Data.”</p><h3>4. Create a Delta table with sample data.</h3><p>Databricks File System (DBFS) is a distributed file system that allows you to store data persistently in Databricks. Follow these steps to create a database and delta table in the Databricks environment.</p><ul><li>Open a Python notebook and create a database called ’<strong>landing</strong>’.</li></ul><pre>spark.sql(&quot;create database if not exists landing&quot;)</pre><p>then you can see the database as below in the Databricks Catelog section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*ozJj2r_52znbl8KG8u04rQ.png" /></figure><p>Then you can create Delta table with sample data by using Dataframe.</p><pre>student_data = [(1,&quot;Pubudu&quot;,10,10000),<br>                (2,&quot;Suranga&quot;,20,20000),<br>                (3,&quot;Dewagama&quot;,30,30000)  <br>]<br><br>student_schema = [&quot;studentId&quot;,&quot;StudentName&quot;,&quot;DeptNo&quot;,&quot;Salary&quot;]<br><br>df = spark.createDataFrame(data=student_data, schema = student_schema)</pre><p>Table creation script:</p><pre>df.write.format(&quot;delta&quot;).saveAsTable(&quot;landing.Student_Table&quot;)</pre><p>You can view the sample data by executing the below query.</p><pre>%sql<br>select * from landing.Student_Table</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*-uTdB8tiwFlEvIffl1g1AA.png" /></figure><h3>5. Connecting Databricks to Power BI</h3><ul><li>Open Power BI Desktop:</li><li>Launch Power BI Desktop on your local machine.</li><li>In Power BI Desktop, click on “Get Data” from the Home tab.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*aAC9X63cIvyufe_vlOzO9g.png" /></figure><ul><li>Choose Databricks:In the “Get Data” window, select &quot;More&quot; and find “Databricks” in the list of available connectors.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*wavdLZaGiWeUtBqG1PtxQg.png" /></figure><ul><li>Enter Connection Details: In the Databricks connector window, enter the following details:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*IBUBBoMqort9zAOuhNqD1w.png" /><figcaption>We can get those from Databricks Cluster configuration section</figcaption></figure><p>Server URL: The URL of your Databricks workspace.</p><p>HTTP Path: Leave it blank unless you have a specific HTTP path to your workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*74JNARW5M6cY4QqGyX_2rg.png" /><figcaption>Coonection details for Power BI Desktop.</figcaption></figure><p>Then you have to enter the credentials for the Databricks environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iJ0AQ_3XqvOECbAZf1cARg.png" /></figure><ul><li>After configuring the connection, click “Connect” to establish the connection to your Databricks workspace.</li><li>Choose the desired tables, views, or write custom queries to load data into Power BI.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*IlA10jaI69ksiq4Qe6Infg.png" /></figure><h3>6. Creating Visualizations</h3><p>Click on the “Report” view in Power BI to start building visualizations.</p><p>In the Fields pane on the right, you’ll see the tables and fields imported from Databricks.</p><p>Drag and drop the desired fields onto the report canvas to start creating visualizations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Go5XlnsfVpehL97ZDooEEA.png" /></figure><h3>7. Refreshing Data</h3><p>If we change the data in the Delta table, we have to refresh the dataset in PowerBI Desktop. In order to refresh, you can click on the Refresh button in the Home Menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnSMQHHSyDRjWPoveSy52w.png" /></figure><h3>8. Conclusion</h3><p>In this comprehensive guide, we’ve explored the seamless integration of Power BI with Databricks, combining the robust data processing capabilities of Databricks with the intuitive visualization tools of Power BI. By following the step-by-step instructions, users can harness the power of these two platforms to unlock valuable insights from their data.</p><p>As you embark on your journey with Power BI and Databricks integration, consider exploring additional features, such as scheduled data refresh, data governance best practices, and optimization techniques. Stay connected with the vibrant communities around both platforms for ongoing learning and troubleshooting.</p><p>Remember, the true power of this integration lies in your ability to adapt and tailor it to your specific business needs. Whether you’re creating financial dashboards, predictive analytics models, or exploring trends in your data, the combined force of Power BI and Databricks empowers you to turn your data into actionable insights.</p><p>As technology continues to evolve, staying informed about updates and new features in both Power BI and Databricks will be essential. The integration between these platforms is a journey, not a destination, and your commitment to learning and adapting will ensure you stay at the forefront of data analytics capabilities.</p><p>Here’s to the journey of turning raw data into meaningful stories, driving informed decisions, and unlocking the true potential of your data with Power BI and Databricks. Happy analyzing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baacf44f626b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/event-driven-utopia/how-to-connect-power-bi-with-databricks-baacf44f626b">A Comprehensive Guide to Connecting Power BI with Databricks</a> was originally published in <a href="https://medium.com/event-driven-utopia">Tributary Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring PySpark Filter Functions in Data Engineering]]></title>
            <link>https://medium.com/@pubududewagama/exploring-pyspark-filter-functions-in-data-engineering-f5beebc305f3?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5beebc305f3</guid>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Wed, 03 Jan 2024 21:02:57 GMT</pubDate>
            <atom:updated>2024-01-09T17:21:35.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8HF3MDECptC1tln7" /><figcaption>Photo by <a href="https://unsplash.com/@lukechesser?utm_source=medium&amp;utm_medium=referral">Luke Chesser</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the realm of data engineering, PySpark filter functions play a pivotal role in refining datasets for data engineers, analysts, and scientists. This post delves into various aspects of PySpark filtering, showcasing its applicability and versatility.</p><p><strong>Following are the main focus points:</strong></p><ol><li><strong>Filter with column condition</strong></li><li><strong>Filter with SQL expression</strong></li><li><strong>Filter with multiple conditions</strong></li><li><strong>Filter Based on List Values</strong></li><li><strong>Filter Based on Starts With, Ends With, Contains</strong></li><li><strong>Filter like and rlike</strong></li><li><strong>Filter on an Array column</strong></li><li><strong>Filter on Nested Struct columns</strong></li></ol><p>PySpark is the Python API for Apache Spark, a powerful and widely used distributed computing framework designed for processing large-scale data sets across clusters of computers. Spark provides high-level APIs in languages such as Scala, Java, Python, and R, making it accessible to a diverse range of developers. PySpark, specifically tailored for Python users, enables seamless integration with existing Python libraries and allows developers to leverage the capabilities of Spark for distributed data processing.</p><p>One fundamental aspect of working with PySpark involves manipulating distributed collections of data, such as RDDs (Resilient Distributed Datasets) or Data frames. The filter function is a crucial component in PySpark for extracting specific subsets of data based on user-defined conditions.</p><p>The filter operation in PySpark allows users to selectively retain elements from an RDD or rows from a Data frame that satisfy a given predicate. Predicates are expressions or conditions that evaluate to either true or false for each element or row. The filter function applies these predicates to the data, retaining only those elements that meet the specified criteria.</p><p>First, we can generate a sample data set using PySpark in the Databricks environment. at the end it will display the data and the schema of the data frame.</p><pre>from pyspark.sql.types import StructType,StructField <br>from pyspark.sql.types import StringType, IntegerType, ArrayType<br>data = [<br>    ((&quot;Pubudu&quot;,&quot;&quot;,&quot;Dewagama&quot;),[&quot;Java&quot;,&quot;Scala&quot;,&quot;C++&quot;],&quot;OH&quot;,&quot;M&quot;),<br>    ((&quot;Anna&quot;,&quot;Rose&quot;,&quot;&quot;),[&quot;Spark&quot;,&quot;Java&quot;,&quot;C++&quot;],&quot;NY&quot;,&quot;F&quot;),<br>    ((&quot;Julia&quot;,&quot;&quot;,&quot;Williams&quot;),[&quot;CSharp&quot;,&quot;VB&quot;],&quot;OH&quot;,&quot;F&quot;),<br>    ((&quot;Maria&quot;,&quot;Anne&quot;,&quot;Jones&quot;),[&quot;CSharp&quot;,&quot;VB&quot;],&quot;NY&quot;,&quot;M&quot;),<br>    ((&quot;Jen&quot;,&quot;Mary&quot;,&quot;Brown&quot;),[&quot;CSharp&quot;,&quot;VB&quot;],&quot;NY&quot;,&quot;M&quot;),<br>    ((&quot;Mike&quot;,&quot;Mary&quot;,&quot;Williams&quot;),[&quot;Python&quot;,&quot;VB&quot;],&quot;OH&quot;,&quot;M&quot;)<br> ]<br>        <br>schema = StructType([<br>     StructField(&#39;name&#39;, StructType([<br>        StructField(&#39;firstname&#39;, StringType(), True),<br>        StructField(&#39;middlename&#39;, StringType(), True),<br>        StructField(&#39;lastname&#39;, StringType(), True)<br>     ])),<br>     StructField(&#39;languages&#39;, ArrayType(StringType()), True),<br>     StructField(&#39;state&#39;, StringType(), True),<br>     StructField(&#39;gender&#39;, StringType(), True)<br> ])<br><br>df = spark.createDataFrame(data = data, schema = schema)<br>df.printSchema()<br>df.show(truncate=False)</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*T6WAWKxAB-ZawNTuyHPttw.png" /></figure><ol><li><strong>Filter with Column Condition: </strong>Introduce the fundamental concept of filtering based on a single column condition, elucidating its significance in isolating specific data subsets.</li></ol><p><strong>Example 1: Using equal condition.</strong></p><pre># Using equals condition<br>df.filter(df.state == &quot;OH&quot;).show(truncate=False)</pre><p>Output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*tTNavTIJE-7hq3-LG9ZCMw.png" /></figure><p><strong>Example 2: Using not equal condition(~).</strong></p><pre># not equals condition<br>df.filter(~(df.state == &quot;OH&quot;)) \<br>    .show(truncate=False)</pre><p>Output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*KCVEWK-KIvIrlxmhNJ69Hw.png" /></figure><p><strong>Example 3: Using not equal condition (!).</strong></p><pre># not equals condition<br>df.filter(df.state != &quot;OH&quot;) \<br>    .show(truncate=False) </pre><p>Output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*JYtjr5IQ6xSO8BB3mxRiUg.png" /></figure><p><strong>Example 4: Using not equal condition (col Function).</strong></p><pre>#Using SQL col() function<br>from pyspark.sql.functions import col<br>df.filter(col(&quot;state&quot;) == &quot;OH&quot;) \<br>    .show(truncate=False) </pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*z4XwmreTa1SeoNxSg1q_IQ.png" /></figure><p><strong>2. Filter with SQL Expression: </strong>Dive into the integration of SQL expressions within PySpark filtering, providing a bridge between traditional SQL syntax and PySpark functionality.</p><p><strong>Example 5: </strong>Using SQL Expression(==)<strong>.</strong></p><pre>#Using SQL Expression<br>df.filter(&quot;gender == &#39;M&#39;&quot;).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*t_6gdzQLbS8JCYwlx7RkVA.png" /></figure><p><strong>Example 6: </strong>For not equal(!=)</p><pre>#For not equal<br>df.filter(&quot;gender != &#39;M&#39;&quot;).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*jCeW0sfk4bkomJH0MNtoSw.png" /></figure><p><strong>Example 7: </strong>For not equal(&lt;&gt;)</p><pre>#For not equal<br>df.filter(&quot;gender &lt;&gt; &#39;M&#39;&quot;).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*IRo8uGzWyMH42stccjpwaQ.png" /></figure><p><strong>3. Filter with Multiple Conditions:</strong> Explore the nuances of applying multiple conditions in PySpark filters, showcasing the flexibility to refine data with precision.</p><p><strong>Example 8: </strong>Filter multiple condition</p><pre>#Filter multiple condition<br>df.filter( (df.state  == &quot;OH&quot;) &amp; (df.gender  == &quot;M&quot;) ) \<br>    .show(truncate=False)  </pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*WSnQWPOLb8CMpB8l1pMwAA.png" /></figure><p><strong>4. Filter Based on List Values: </strong>Uncover the methodology of filtering data based on a predefined list of values, demonstrating its utility in targeted data extraction.</p><p><strong>Example 9: </strong>Filter multiple condition</p><p>First we have to define list with sample data set.</p><pre>#Filter IS IN List values<br>li=[&quot;OH&quot;,&quot;CA&quot;,&quot;DE&quot;]<br>df.filter(df.state.isin(li)).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*qqxB_BN_ihnA4JhrklkIWg.png" /></figure><p>Then, we can filter based on list values as below.</p><pre># Filter NOT IS IN List values<br>#These show all records with NY (NY is not part of the list)<br>df.filter(~df.state.isin(li)).show()<br>df.filter(df.state.isin(li)==False).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*_DRV_pg6w1fpBUbdJeExqA.png" /></figure><p>5. <strong>Filter Based on Starts With, Ends With, Contains:</strong> Highlight the efficiency of PySpark filters in handling string manipulations, specifically focusing on starting, ending, or containing specific substrings.</p><p><strong>Example 10: </strong>Using startswith</p><pre><br>df.filter(df.state.startswith(&quot;N&quot;)).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*VXGVh_etc0mIgVPWiOebIQ.png" /></figure><p><strong>Example 11: </strong>Using endswith</p><pre><br>df.filter(df.state.endswith(&quot;H&quot;)).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*_zQHVifBp8u-N8gx0gwqXw.png" /></figure><p><strong>Example 12: </strong>Using contains</p><pre>df.filter(df.state.contains(&quot;H&quot;)).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*LEJeAnqZXj8w1vMt3vZ-Uw.png" /></figure><p>6. <strong>Filter like and rlike:</strong> Discuss the ‘like’ and ‘rlike’ operators in PySpark filters, shedding light on their role in pattern matching for intricate data extraction.</p><p><strong>Example 13: </strong>like and rlike</p><pre>data2 = [(2,&quot;Michael Rose&quot;),(3,&quot;Robert Williams&quot;),<br>     (4,&quot;Rames Rose&quot;),(5,&quot;Rames rose&quot;)<br>  ]<br>df2 = spark.createDataFrame(data = data2, schema = [&quot;id&quot;,&quot;name&quot;])<br><br># like - SQL LIKE pattern<br>df2.filter(df2.name.like(&quot;%rose%&quot;)).show()<br><br># rlike - SQL RLIKE pattern (LIKE with Regex)<br>#This check case insensitive<br>df2.filter(df2.name.rlike(&quot;(?i)^*rose$&quot;)).show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*WqQgnsRCypQ0_vYEKDIOww.png" /></figure><p>7. <strong>Filter on an Array Column:</strong> Showcase the capability of PySpark filters to operate on array-type columns, opening avenues for filtering based on array elements.</p><p><strong>Example 14: </strong>Filter on an Array column</p><pre>from pyspark.sql.functions import array_contains<br>df.filter(array_contains(df.languages,&quot;Java&quot;)) \<br>    .show(truncate=False)    </pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*Df_S7iy_8aGsj4VwJCGWAw.png" /></figure><p>8. <strong>Filter on Nested Struct Columns: </strong>Delve into the advanced feature of filtering nested struct columns, illustrating the application of PySpark filters in handling complex data structures.</p><p><strong>Example 15: </strong>Filter on an Array column</p><pre>df.filter(df.name.lastname == &quot;Williams&quot;) \<br>    .show(truncate=False)</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*ojkAXj_bfT8nb21FvSEPwA.png" /></figure><p>By navigating through these key focus points, data professionals can harness the full potential of PySpark filter functions, empowering them to efficiently filter and manipulate datasets in their data engineering endeavors.</p><p>Thank you!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5beebc305f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Data Engineering?]]></title>
            <link>https://medium.com/event-driven-utopia/what-is-data-engineering-68c68347c62a?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/68c68347c62a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Wed, 22 Nov 2023 00:02:11 GMT</pubDate>
            <atom:updated>2024-01-03T19:26:23.242Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dJRbvpEYMp_NYKBq" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The data engineer will frequently work with many types of data to execute numerous operations utilizing a variety of scripting or coding languages relevant to their specific organization.</p><h3><strong>Types of data</strong></h3><p><strong>Structured: </strong>Structured data is typically derived from table-based source systems, such as a relational database, or from flat files, such as a comma-separated (CSV) file. The main feature of a structured file is that the rows and columns are continuously aligned throughout the file.</p><p><strong>Semi-structured:</strong> Semi-structured data is data like JavaScript object notation (JSON) files that may need to be flattened before being loaded into your source system. This data does not have to fit nicely into a table structure when flattened.</p><p><strong>Unstructured: </strong>Unstructured data is data that is stored as key-value pairs and does not conform to typical relational models. Other common types of unstructured data include portable data format (PDF), word processor documents, and photographs.</p><h3><strong>Data operations</strong></h3><p>Some of the key activities you’ll undertake in Azure as a data engineer include data integration, data transformation, and data consolidation.</p><p><strong>Data integration:</strong> Data integration is the process of creating connections between data sources and operational and analytical services to allow for safe, dependable access to data across various systems. For instance, a data engineer may be needed to create connections between disparate systems in order to extract the necessary data from each one in order to support a business process that depends on data that is dispersed among them all.</p><p><strong>Data transformation: </strong>Although there is a growing variation in which you extract, load, and transform (ELT) the data, which is used to quickly ingest the data into a data lake and then apply “big data” processing techniques to transform it, operational data typically needs to be transformed into a suitable structure and format for analysis. Whichever method is employed, the data is ready to facilitate the requirements of subsequent analyses.</p><p><strong>Data consolidation: </strong>The process of merging data taken from several data sources into a standardized structure is known as data consolidation, and it is typically done to facilitate analytics and reporting. Typically, operational systems’ data is taken out, processed, and added to analytical repositories like data lakes or data warehouses.</p><h3><strong>Key ideas in data engineering</strong></h3><p>Data engineers should be familiar with a few fundamental ideas. Many of the tasks that data engineers must implement and support are based on these ideas.</p><p><strong>Operational and analytical data: </strong>Typically, applications generate and store transactional data, which is then saved in a relational or non-relational database as operational data. Data optimized for analysis and reporting is referred to as analytical data, and it is frequently stored in a data warehouse or data lake.</p><p>A data engineer’s primary duties include designing, implementing, and overseeing solutions that combine operational and analytical data sources or that take operational data and extract it from various systems, format it for analysis, and load it into an analytical data store (commonly called ETL solutions).</p><p><strong>Streaming data: </strong>Perpetual data sources that produce data values in real-time, frequently associated with particular events, are referred to as streaming data. Social media feeds and internet-of-things (IoT) devices are common sources of streaming data.</p><p>In order to integrate real-time data with other application data that is handled in batches, data engineers frequently have to put into practice solutions that capture real-time streams of data and ingest them into analytical data systems.</p><p><strong>Data pipelines:</strong>Data transformation and transfer operations are coordinated through the use of data pipelines. The main tool used by data engineers to create repeatable extract, transform, and load (ETL) solutions that can be set to run on a schedule or in reaction to events is a pipeline.</p><p><strong>Data Lakes: </strong>A data lake is a type of storage repository where large volumes of raw, native data are kept. The scalability of data lake repositories for enormous volumes of data (terabytes or petabytes) is optimized. The data may be unstructured, semi-structured, or structured, and it usually originates from a variety of diverse sources.</p><p>Keeping everything in its unaltered, original state is the goal of a data lake. Compared to a standard data warehouse, which processes and transforms data as it is ingested, this method is different.</p><p><strong>Data Warehouse: </strong>A central repository for integrated data from one or more different sources is called a data warehouse. Relational tables in data warehouses hold both historical and current data, arranged in a format designed to maximize efficiency for analytical queries.</p><p>Relational data warehouse design and implementation, as well as frequent data load management into tables, fall within the purview of data engineers.</p><p>The core Azure technologies used to implement data engineering workloads include:</p><p>Azure Synapse Analytics<br>Azure Data Lake Storage Gen2<br>Azure Stream Analytics<br>Azure Data Factory<br>Azure Databricks</p><p>Thank you !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68c68347c62a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/event-driven-utopia/what-is-data-engineering-68c68347c62a">What is Data Engineering?</a> was originally published in <a href="https://medium.com/event-driven-utopia">Tributary Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Load data from MySQL to Databricks]]></title>
            <link>https://medium.com/@pubududewagama/load-data-from-mysql-to-databricks-c00c3b531415?source=rss-162b8b5baf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/c00c3b531415</guid>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Pubudu Dewagama]]></dc:creator>
            <pubDate>Sun, 24 Sep 2023 02:04:40 GMT</pubDate>
            <atom:updated>2023-09-24T02:05:51.076Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog I’m going to explain you how to connect to MySQL database from Databricks environment.</p><ol><li><strong>Set Up Your Databricks Environment:</strong></li></ol><ul><li>Ensure you have access to a Databricks workspace and cluster. You can sign up for a Databricks workspace on the Databricks website.</li><li>Make sure you have the necessary permissions to perform data loading operations. You might need cluster administration and storage permissions depending on where you plan to save the data in Databricks.</li></ul><p><strong>2. Create a sample table in the MySQL Database. In this case I have created the MySQL database in the Amazon Web Service free tier as below.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*-uSoIzHcId2FbhS46Q8cFA.png" /></figure><p><strong>3. Connect to MySQL:</strong></p><p>To connect to your MySQL database from Databricks, follow these steps:</p><ul><li>Create a new notebook in your Databricks workspace.</li><li>In the notebook, select the programming language you prefer as Python.</li><li>Use the Databricks JDBC connector to establish a connection to MySQL</li></ul><blockquote><strong>driver = “org.mariadb.jdbc.Driver”<br>database_host = “&lt;database-host-url&gt;”<br>database_port = “3306” # update if you use a non-default port<br>database_name = “&lt;database-name&gt;”<br>table = “&lt;table-name&gt;”<br>user = “&lt;username&gt;”<br>password = “&lt;password&gt;”<br>url = f”jdbc:mysql://{database_host}:{database_port}/{database_name}”<br>print(url)</strong></blockquote><p>Once entered host and credentials details, It will display URL as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*GCEYKbDG36Excb5NzIQcuQ.png" /></figure><p>Using above URL we can retrieve the data as below.</p><blockquote><strong>mysql_table = (spark.read<br> .format(“jdbc”)<br> .option(“driver”, driver)<br> .option(“url”, url)<br> .option(“query”, “select * from Employee”) <br> .option(“user”, user)<br> .option(“password”, password)<br> .load()<br>)<br>display(mysql_table)</strong></blockquote><p>Output:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*fNGj7S_m07hCMZrc-YArVw.png" /></figure><p>Thank you !!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c00c3b531415" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>