<?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 Bysanitribhuvan on Medium]]></title>
        <description><![CDATA[Stories by Bysanitribhuvan on Medium]]></description>
        <link>https://medium.com/@bysanitribhuvan?source=rss-09c847523d1a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3IlHjVQ2AeMq0iK20rdXcg@2x.jpeg</url>
            <title>Stories by Bysanitribhuvan on Medium</title>
            <link>https://medium.com/@bysanitribhuvan?source=rss-09c847523d1a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:59:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bysanitribhuvan/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[I asked ChatGPT for a few Python questions. Here are their solutions]]></title>
            <link>https://medium.com/@bysanitribhuvan/i-asked-chatgpt-for-a-few-python-questions-here-are-their-solutions-3d0bb3c6f47f?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d0bb3c6f47f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-interview-question]]></category>
            <category><![CDATA[python-libraries]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Fri, 03 Oct 2025 17:17:03 GMT</pubDate>
            <atom:updated>2025-10-03T17:17:03.825Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Print numbers from 1 to 20.</li></ol><pre>n=20<br>for i in range(1,n+1):<br>    print(i)</pre><p>2. Print only even numbers from a list: [1,2,3,4,5,6,7,8]</p><pre>n=8<br>for i in range(1,n+1):<br>    if i%2==0:<br>        print(i)</pre><p>3. Check if a number is prime.</p><pre>##with use of math library<br>import math<br>def is_prime(n):<br>    if n&lt;2:<br>        return False<br>    for i in range(2,math.isqrt(n)+1):<br>       if n%i==0:<br>           return False<br>    return True<br><br>num=int(input(&#39;enter the number: &#39;))<br>if is_prime(num):<br>    print(f&quot;{num} is prime number&quot; )<br>else:<br>    print(f&quot;{num} is not prime number&quot;)</pre><pre>##without any math library<br>def is_prime(n):<br>    if n&lt;2:<br>        return False<br>    for i in range(2,int(n**0.5)+1):<br>       if n%i==0:<br>           return False<br>    return True<br><br>num=int(input(&#39;enter the number: &#39;))<br>if is_prime(num):<br>    print(f&quot;{num} is prime number&quot; )<br>else:<br>    print(f&quot;{num} is not prime number&quot;)</pre><p>4. Find the largest number in a list: [10, 25, 7, 42, 18]</p><pre>numbers=[10, 25, 7, 42, 18]<br>print(max(numbers))</pre><pre>numbers=[10, 25, 7, 42, 18]<br>largest=number[0]<br>for num in numbers:<br>    if num&gt;largest:<br>        largest=num<br>print(largest)<br>  </pre><p>5.Count vowels in a string: &quot;Tribhuvan&quot;</p><pre>name=&quot;Tribhuvan&quot;<br>lists=list(name.upper())<br>count=0<br>for i in lists:<br>    if i in (&#39;A&#39;,&#39;E&#39;,&#39;I&#39;,&#39;O&#39;,&#39;U&#39;):<br>        count+=1<br>print(count)</pre><p>6.Write a function to <strong>reverse a string</strong>.</p><pre>def reverse_string(name):<br>    reverse=name[::-1]<br>    return reverse<br>     <br>name=str(input(&quot;Enter the String Value :&quot;))<br><br>print(reverse_string(name))</pre><p>7.Write a function to <strong>check palindrome</strong> (e.g., &quot;madam&quot; → True).</p><pre>def reverse_string(n):<br>    reverse=n[::-1]<br>    return reverse<br>     <br>name=str(input(&quot;Enter the String Value :&quot;))<br>if name==reverse_string(name):<br>    print(True)<br>else: print(False)</pre><p>8.Write a function to <strong>calculate factorial</strong> of a number.</p><pre>def fact_num(n):<br>    if n&gt;=1:<br>        factorial=1<br>        for i in range(1,n+1):<br>            factorial*=i<br>        return factorial<br>    else :return 1<br>            <br>Num=int(input(&quot;Enter the number :&quot;))<br>fact=fact_num(Num)<br>print(fact)</pre><p>9.Merge two lists [1,2,3] and [4,5,6].</p><pre>list1=[1,2,3]<br>list2=[4,5,6]<br>print(list1+list2)</pre><p>10.Remove duplicates from a list [1,2,2,3,4,4,5].</p><pre>list1=[1,2,2,3,4,4,5]<br><br>print(list(set(list1)))</pre><pre>list1=[1,2,2,3,4,4,5]<br>list2=[]<br>for i in list1:<br>   if i not in list2:<br>       list2.append(i)<br>print(list2)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d0bb3c6f47f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks Data Engineer Associate Exam sample Question]]></title>
            <link>https://medium.com/@bysanitribhuvan/databricks-data-engineer-associate-exam-sample-question-27942221929d?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/27942221929d</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[databricks-certification]]></category>
            <category><![CDATA[mcqs-with-answers]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 11:54:11 GMT</pubDate>
            <atom:updated>2025-01-12T07:52:58.107Z</atom:updated>
            <content:encoded><![CDATA[<p>A data engineer wants to create a data entity from a couple of tables. The data entity must be used by other data engineers in other sessions. It also must be saved to a physical location. Which of the following data entities should the data engineer create?</p><p>A. Table</p><p>B. Function</p><p>C. View</p><p>D. Temporary view</p><pre>A</pre><p>A dataset has been defined using Delta Live Tables and includes an expectations clause: CONSTRAINT valid_timestamp EXPECT (timestamp &gt; ‘2020–01–01’) ON VIOLATION DROP ROW What is the expected behavior when a batch of data containing data that violates these constraints is processed?</p><p>A. Records that violate the expectation cause the job to fail.</p><p>B. Records that violate the expectation are added to the target dataset and flagged as invalid in a field added to the target dataset.</p><p>C. Records that violate the expectation are dropped from the target dataset and recorded as invalid in the event log.</p><p>D. Records that violate the expectation are added to the target dataset and recorded as invalid in the event log.</p><pre>C</pre><p>A data organization leader is upset about the data analysis team’s reports being different from the data engineering team’s reports. The leader believes the siloed nature of their organization’s data engineering and data analysis architectures is to blame. Which of the following describes how a data lakehouse could alleviate this issue?</p><p>A. Both teams would autoscale their work as data size evolves</p><p>B. Both teams would use the same source of truth for their work</p><p>C. Both teams would reorganize to report to the same department</p><p>D. Both teams would be able to collaborate on projects in real-time</p><p>E. Both teams would respond more quickly to ad-hoc requests</p><pre>B</pre><p>Which of the following describes a scenario in which a data team will want to utilize cluster pools?</p><p>A. An automated report needs to be refreshed as quickly as possible.</p><p>B. An automated report needs to be made reproducible.</p><p>C. An automated report needs to be tested to identify errors.</p><p>D. An automated report needs to be version-controlled across multiple collaborators.</p><p>E. An automated report needs to be runnable by all stakeholders.</p><pre>A</pre><p>Which of the following is hosted completely in the control plane of the classic Databricks architecture?</p><p>A. Worker node</p><p>B. JDBC data source</p><p>C. Databricks web application</p><p>D. Databricks Filesystem</p><p>E. Driver node</p><pre>C</pre><p>Which of the following benefits of using the Databricks Lakehouse Platform is provided by Delta Lake?</p><p>A. The ability to manipulate the same data using a variety of languages</p><p>B. The ability to collaborate in real time on a single notebook</p><p>C. The ability to set up alerts for query failures</p><p>D. The ability to support batch and streaming workloads</p><p>E. The ability to distribute complex data operations</p><pre>D</pre><p>Which of the following describes the storage organization of a Delta table?</p><p>A. Delta tables are stored in a single file that contains data, history, metadata, and other attributes.</p><p>B. Delta tables store their data in a single file and all metadata in a collection of files in a separate location.</p><p>C. Delta tables are stored in a collection of files that contain data, history, metadata, and other attributes.</p><p>D. Delta tables are stored in a collection of files that contain only the data stored within the table.</p><p>E. Delta tables are stored in a single file that contains only the data stored within the table.</p><pre>C</pre><p>Which of the following code blocks will remove the rows where the value in column age is greater than 25 from the existing Delta table my_table and save the updated table?</p><p>A. SELECT * FROM my_table WHERE age &gt; 25;</p><p>B. UPDATE my_table WHERE age &gt; 25;</p><p>C. DELETE FROM my_table WHERE age &gt; 25;</p><p>D. UPDATE my_table WHERE age &lt;= 25;</p><p>E. DELETE FROM my_table WHERE age &lt;= 25;</p><pre>C</pre><p>A data engineer has realized that they made a mistake when making a daily update to a table. They need to use Delta time travel to restore the table to a version that is 3 days old. However, when the data engineer attempts to time travel to the older version, they are unable to restore the data because the data files have been deleted. Which of the following explains why the data files are no longer present?</p><p>A. The VACUUM command was run on the table</p><p>B. The TIME TRAVEL command was run on the table</p><p>C. The DELETE HISTORY command was run on the table</p><p>D. The OPTIMIZE command was nun on the table</p><p>E. The HISTORY command was run on the table</p><pre>A</pre><p>Which of the following Git operations must be performed outside of Databricks Repos?</p><p>A. Commit</p><p>B. Pull</p><p>C. Push</p><p>D. Clone</p><p>E. Merge</p><pre>D</pre><p>Which of the following data lakehouse features results in improved data quality over a traditional data lake?</p><p>A. A data lakehouse provides storage solutions for structured and unstructured data.</p><p>B. A data lakehouse supports ACID-compliant transactions.</p><p>C. A data lakehouse allows the use of SQL queries to examine data.</p><p>D. A data lakehouse stores data in open formats.</p><p>E. A data lakehouse enables machine learning and artificial Intelligence workloads.</p><pre>B</pre><p>A data engineer needs to determine whether to use the built-in Databricks Notebooks versioning or version their project using Databricks Repos. Which of the following is an advantage of using Databricks Repos over the Databricks Notebooks versioning?</p><p>A. Databricks Repos automatically saves development progress</p><p>B. Databricks Repos supports the use of multiple branches</p><p>C. Databricks Repos allows users to revert to previous versions of a notebook</p><p>D. Databricks Repos provides the ability to comment on specific changes</p><p>E. Databricks Repos is wholly housed within the Databricks Lakehouse Platform</p><pre>B</pre><p>A data engineer has left the organization. The data team needs to transfer ownership of the data engineer’s Delta tables to a new data engineer. The new data engineer is the lead engineer on the data team. Assuming the original data engineer no longer has access, which of the following individuals must be the one to transfer ownership of the Delta tables in Data Explorer?</p><p>A. Databricks account representative</p><p>B. This transfer is not possible</p><p>C. Workspace administrator</p><p>D. New lead data engineer</p><p>E. Original data engineer</p><pre>C</pre><p>A data analyst has created a Delta table sales that is used by the entire data analysis team. They want help from the data engineering team to implement a series of tests to ensure the data is clean. However, the data engineering team uses Python for its tests rather than SQL. Which of the following commands could the data engineering team use to access sales in PySpark?</p><p>A. SELECT * FROM sales</p><p>B. There is no way to share data between PySpark and SQL.</p><p>C. spark.sql(“sales”)</p><p>D. spark.delta.table(“sales”)</p><p>E. spark.table(“sales”)</p><pre>E</pre><p>Which of the following commands will return the location of database customer360?</p><p>A. DESCRIBE LOCATION customer360;</p><p>B. DROP DATABASE customer360;</p><p>C. DESCRIBE DATABASE customer360;</p><p>D. ALTER DATABASE customer360 SET DBPROPERTIES (‘location’ = ‘/user’};</p><p>E. USE DATABASE customer360;</p><pre>C</pre><p>A data engineer wants to create a new table containing the names of customers that live in France. They have written the following command:</p><pre>Create table customersInFrance<br>________ As<br>select id,firstname,lastname From custumerLocations where country=&#39;France&#39;</pre><p>A senior data engineer mentions that it is organization policy to include a table property indicating that the new table includes personally identifiable information (PII). Which of the following lines of code fills in the above blank to successfully complete the task?</p><p>A. There is no way to indicate whether a table contains PII.</p><p>B. “COMMENT PII”</p><p>C. TBLPROPERTIES PII</p><p>D. COMMENT “Contains PII”</p><p>E. PII</p><pre>D</pre><p>Which of the following benefits is provided by the array functions from Spark SQL?</p><p>A. An ability to work with data in a variety of types at once</p><p>B. An ability to work with data within certain partitions and windows</p><p>C. An ability to work with time-related data in specified intervals</p><p>D. An ability to work with complex, nested data ingested from JSON files</p><p>E. An ability to work with an array of tables for procedural automation</p><pre>D</pre><p>Which of the following commands can be used to write data into a Delta table while avoiding the writing of duplicate records?</p><p>A. DROP</p><p>B. IGNORE</p><p>C. MERGE</p><p>D. APPEND</p><p>E. INSERT</p><pre>C</pre><pre># Answer B<br>from datetime import datetime<br><br># Check if today is Sunday (weekday() returns 6 for Sunday)<br>if datetime.today().weekday() == 6:<br>    # Execute the final query here<br>    spark.sql(&quot;SELECT * FROM final_query&quot;)<br>else:<br>    # Execute other queries or skip<br>    spark.sql(&quot;SELECT * FROM other_query&quot;)</pre><p>A data engineering team has two tables. The first table march_transactions is a collection of all retail transactions in the month of March. The second table april_transactions is a collection of all retail transactions in the month of April. There are no duplicate records between the tables. Which of the following commands should be run to create a new table all_transactions that contains all records from march_transactions and april_transactions without duplicate records?</p><p>A. CREATE TABLE all_transactions AS SELECT * FROM march_transactions INNER JOIN SELECT * FROM april_transactions;</p><p>B. CREATE TABLE all_transactions AS SELECT * FROM march_transactions UNION SELECT * FROM april_transactions;</p><p>C. CREATE TABLE all_transactions AS SELECT * FROM march_transactions OUTER JOIN SELECT * FROM april_transactions;</p><p>D. CREATE TABLE all_transactions AS SELECT * FROM march_transactions INTERSECT SELECT * from april_transactions;</p><p>E. CREATE TABLE all_transactions AS SELECT * FROM march_transactions MERGE SELECT * FROM april_transactions;</p><pre>B</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27942221929d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating a SQL Pipeline to Delta Live Tables]]></title>
            <link>https://medium.com/@bysanitribhuvan/migrating-a-sql-pipeline-to-delta-live-tables-f8c37e13aa7b?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8c37e13aa7b</guid>
            <category><![CDATA[delta-live-tables]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[databricks-sql]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 11:05:45 GMT</pubDate>
            <atom:updated>2025-01-11T11:05:45.066Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Delta Live Tables?</h3><p>Delta Live Tables is a declarative framework designed to simplify the creation of reliable and maintainable extract, transform, and load (ETL) pipelines. You specify what data to ingest and how to transform it, and Delta Live Tables automates key aspects of managing your data pipeline, including orchestration, compute management, monitoring, data quality enforcement, and error handling.<a href="https://docs.databricks.com/en/delta-live-tables/index.html#sql">https://docs.databricks.com/en/delta-live-tables/index.html#sql</a></p><p>Declare Bronze Table:</p><p>Declare a bronze table, That ingests CSV data incrementally(Using autoloader) from the simulated cloud source.</p><pre>-- Declare Bronze Table<br><br>CREATE OR REFRESH STREAMING LIVE TABLE table_name_bronze<br>AS SELECT current_timestamp() receipt_time, input_file_name() source_file, *<br>FROM cloud_files(&quot;dbfs:/FileStore/tables/*****&quot;, &quot;csv&quot;, map(&quot;cloudFiles.schemaHints&quot;, &quot;passenger_count INTEGER,trip_distance DOUBLE, total_amount DOUBLE&quot;,&quot;header&quot;, &quot;true&quot;, &quot;cloudFiles.inferColumnTypes&quot;, &quot;true&quot;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r_MxxwMk2kH8h5dfvFwx8A.png" /><figcaption>Output</figcaption></figure><p>Using a similar CTAS syntax, create a live table into the CSV data found in the data set.</p><pre>--Taxi Zones File<br><br>CREATE OR REFRESH STREAMING LIVE TABLE table_name<br>AS SELECT * FROM cloud_files(&quot;${datasets_path}/*****&quot;, &quot;csv&quot;, map(&quot;header&quot;, &quot;true&quot;, &quot;cloudFiles.inferColumnTypes&quot;, &quot;true&quot;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23zLihSLfse3E2AJuaoPLg.png" /><figcaption>output</figcaption></figure><p>Declare a Silver Tables</p><pre>-- VendorID,lpep_pickup_datetime,lpep_dropoff_datetime,passenger_count,<br>-- trip_distance,DOLocationID,total_amount,Borough,Zone,service_zone<br><br>CREATE OR REFRESH STREAMING LIVE TABLE table_name_Silver<br>(CONSTRAINT positive_passenger_count EXPECT (passenger_count &gt; 0) ON VIOLATION DROP ROW,<br>CONSTRAINT positive_trip_distance EXPECT (trip_distance &gt; 0.0) ON VIOLATION DROP ROW,<br>CONSTRAINT positive_total_amount EXPECT (total_amount &gt; 0.0) ON VIOLATION DROP ROW,<br>CONSTRAINT pickup_drop_datetime_not_same EXPECT (pickup_datetime!=dropoff_datetime ) ON VIOLATION DROP ROW<br> )<br>AS SELECT <br>a.VendorID,<br>a.lpep_pickup_datetime pickup_datetime,<br>a.lpep_dropoff_datetime dropoff_datetime,<br>CAST(a.passenger_count AS INTEGER) passenger_count, <br>CAST(a.trip_distance AS DOUBLE) trip_distance,<br>a.DOLocationID,<br>CAST(a.total_amount AS DOUBLE) total_amount, <br>b.Borough,<br>b.Zone,<br>b.service_zone<br>FROM STREAM(live.table_name_bronze) a<br>INNER JOIN STREAM(live.table_name) b<br>ON a.DOLocationID = b.LocationID;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Zrc2_NnJv-kRKYDkREYfA.png" /><figcaption>output</figcaption></figure><p>Gold Table</p><pre>-- Zone wise Passenger count for each vendor<br><br>CREATE OR REFRESH LIVE TABLE golden_table<br>COMMENT &quot;Total Passenger count for each taxi vendor for each zone&quot;<br>AS SELECT VendorID, Zone, sum(passenger_count) total_passenger_count<br>FROM live.table_name_Silver<br>GROUP BY VendorID, Zone;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZoBuhel5IdogFaANchxe8w.png" /><figcaption>out put</figcaption></figure><p>Create and configure a pipeline</p><p>In this section, you will create a pipeline using a notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*r0JAPAI3548mDiCtWws9TQ.png" /><figcaption>select Work flow</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KX__13Z423jtildQp7GrDQ.png" /><figcaption>select delta live table</figcaption></figure><p>click on create pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8o95t_Asg6L9yKEMwRx0g.png" /><figcaption>Provide all details</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1EGEL3vU6R8KQuOhG6S7Q.png" /><figcaption>click on start</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFgZGa6Nrmox5UloVs_9Mg.png" /></figure><p>Select any of the flow you can find</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*o_3ClLXgygz9ZinHdJNyEg.png" /></figure><p>In catalog you see the</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxulwNnywkSL4qHfDCCs8w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8c37e13aa7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Technical Interview Experience for the Azure Data Engineer Role at MNC company]]></title>
            <link>https://medium.com/@bysanitribhuvan/my-technical-interview-experience-for-the-azure-data-engineer-role-at-mnc-company-80023f948b30?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/80023f948b30</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[pysaprk]]></category>
            <category><![CDATA[interview-experience]]></category>
            <category><![CDATA[azure-data-engineer]]></category>
            <category><![CDATA[data-engineer-interview]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Fri, 26 Apr 2024 06:36:24 GMT</pubDate>
            <atom:updated>2024-04-26T06:36:24.944Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently had the opportunity to interview with MNC company for the Azure Data Engineer role, where I shared my three years of experience in the field. The interview was a comprehensive exploration of my skills and experiences, focusing on both technical expertise and problem-solving abilities.</p><p>The interview started with the basics, where I was asked to introduce myself and share my educational background. I then proceeded to discuss my project experience, detailing the challenges I faced while building pipelines, the actions I took to overcome them, and the valuable learnings I gained from these experiences.</p><p>One of the technical questions I was asked involved SQL, where I was presented with two tables. Table A consisted of five rows, with the first four rows containing the value ‘1’ and the fifth row being null. Table B, on the other hand, consisted of three rows, with the first two rows containing ‘1’ and the third row being null. I was asked to predict the output of left, inner, and right joins between these two tables, which tested my SQL proficiency.</p><p><a href="https://medium.com/@bysanitribhuvan/demystifying-the-data-flow-a-guide-to-scenario-based-azure-data-engineering-interviews-5483346c0f5d">https://medium.com/@bysanitribhuvan/demystifying-the-data-flow-a-guide-to-scenario-based-azure-data-engineering-interviews-5483346c0f5d</a><br>check the 5 question from this link</p><p>Moving on to PySpark, I was asked to write a query using a WHERE condition, which I successfully completed. I was also asked to write a query for joining two tables in PySpark, which I executed efficiently.</p><pre>pyspark.select(&#39;*&#39;).filter(col(&#39;&#39;)== ).show()<br><br>TableA.join(TableB,TableA[&#39;ID&#39;]==TableB[&#39;ID&#39;],&#39;inner&#39;).show()</pre><p>Finally, I was asked to explain the difference between the ‘show’ and ‘display’ functions in PySpark, where I faced a momentary confusion but managed to articulate the distinction effectively.</p><p>Overall, my technical round interview at MNC company was a challenging yet rewarding experience that allowed me to showcase my skills and knowledge in the field of Azure Data Engineering. I look forward to the next steps in the interview process and the opportunity to contribute to MNC company innovative projects in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80023f948b30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying the Data Flow: A Guide to Scenario-Based Azure Data Engineering Interviews]]></title>
            <link>https://medium.com/@bysanitribhuvan/demystifying-the-data-flow-a-guide-to-scenario-based-azure-data-engineering-interviews-5483346c0f5d?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5483346c0f5d</guid>
            <category><![CDATA[azure-data-engineer]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[pyspark-dataframes]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Sun, 25 Feb 2024 16:20:48 GMT</pubDate>
            <atom:updated>2024-02-25T16:20:48.517Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>you have a PySpark DataFrame named employee_data with the following columns: employee_id, department, salary, and hire_date.<br>You need to find the highest salary in each department and calculate the percentage of each employee’s salary compared to the department’s highest salary.</li></ol><p>Data:</p><pre>+-----------+--------------+------+----------+<br>|employee_id|    department|salary| hire_date|<br>+-----------+--------------+------+----------+<br>|        101|         Sales|  5125|02-02-2013|<br>|        102|         Sales|  5529|31-08-2013|<br>|        103|       Finance|  5125|16-06-2014|<br>|        104|     Logistics|  5329|10-07-2014|<br>|        105|Human Resource|  5529|16-07-2014|<br>|        106|         Sales|  5423|25-07-2014|<br>|        107|         Sales|  5125|31-07-2014|<br>|        108|       Finance|  5516|11-08-2014|<br>|        109|       Finance|  5564|11-08-2014|<br>|        110|     Logistics|  5446|12-08-2014|<br>+-----------+--------------+------+----------+</pre><pre>#caluclating maximum salary<br>df1=df.select(&quot;department&quot;,&quot;salary&quot;).groupBy(col(&quot;department&quot;)).max(&quot;salary&quot;).withColumnRenamed(&#39;max(salary)&#39;,&#39;max_salary&#39;)<br>#joining df to old and creating df<br>df2=df.alias(&quot;E&quot;).join(df1.alias(&quot;M&quot;),col(&#39;E.department&#39;)==col(&#39;M.department&#39;),&#39;left&#39;).select(&#39;E.employee_id&#39;,column(&#39;E.department&#39;).alias(&quot;Dept&quot;),&#39;E.salary&#39;,&#39;E.hire_date&#39;,&#39;M.max_salary&#39;)<br>#caluclating percentage<br>df3 = df2.withColumn(&#39;salary_percentage&#39;, F.col(&#39;salary&#39;) / F.col(&#39;max_salary&#39;) * 100)<br>df3.select(&quot;employee_id&quot;,&quot;dept&quot;,&quot;salary&quot;,&quot;max_salary&quot;,&quot;salary_percentage&quot;).show()</pre><pre>#Output<br>+-----------+--------------+------+----------+-----------------+<br>|employee_id|          dept|salary|max_salary|salary_percentage|<br>+-----------+--------------+------+----------+-----------------+<br>|        101|         Sales|  5125|      5529|92.69307288840658|<br>|        102|         Sales|  5529|      5529|            100.0|<br>|        103|       Finance|  5125|      5564| 92.1099928109274|<br>|        104|     Logistics|  5329|      5446|97.85163422695557|<br>|        105|Human Resource|  5529|      5529|            100.0|<br>|        106|         Sales|  5423|      5529|98.08283595586906|<br>|        107|         Sales|  5125|      5529|92.69307288840658|<br>|        108|       Finance|  5516|      5564|  99.137311286844|<br>|        109|       Finance|  5564|      5564|            100.0|<br>|        110|     Logistics|  5446|      5446|            100.0|<br>+-----------+--------------+------+----------+-----------------+</pre><p>2.jsonString = ‘{“id”:”2&quot;,”Name”:”XYZ”,”City”:”Chn”}’<br>data = [(1, ‘{“id”:”1&quot;,”Name”:”ABC”,”City”:”Chn”}’), (2, jsonString)]<br> # Output<br>Tuple 1:<br>{“id”:”1&quot;,”Name”:”XYZ”,”City”:”Chn”}<br> Tuple 2:<br>{“id”:”2&quot;,”Name”:”AB”,”City”:”Chn”}</p><pre>import json<br><br>def process_data(data):<br>    &quot;&quot;&quot;Processes a list of tuples, extracts JSON data, and corrects a potential error.<br><br>    Args:<br>        data: A list of tuples containing integers and JSON strings.<br><br>    Returns:<br>        A list of tuples where the second element in each tuple is the parsed JSON data.<br>    &quot;&quot;&quot;<br><br>    processed_data = []<br><br>    for index, (key, value) in enumerate(data):<br>        try:<br>            # Attempt to parse JSON with error handling<br>            parsed_data = json.loads(value)<br><br>            # Correct potential error if &quot;AB&quot; was intended instead of &quot;XYZ&quot;<br>            if parsed_data.get(&quot;Name&quot;) == &quot;XYZ&quot;:<br>                parsed_data[&quot;Name&quot;] = &quot;AB&quot;<br><br>            processed_data.append((key, parsed_data))<br>        except json.JSONDecodeError as e:<br>            print(f&quot;Error parsing JSON data for tuple {index + 1}: {e}&quot;)<br><br>    return processed_data<br><br>processed_data = process_data(data)<br><br>for key, value in processed_data:<br>    print(f&quot;Tuple {key}:&quot;)<br>    print(json.dumps(value, indent=4))</pre><pre>#output<br>Tuple 1:<br>{<br>    &quot;id&quot;: &quot;1&quot;,<br>    &quot;Name&quot;: &quot;ABC&quot;,<br>    &quot;City&quot;: &quot;Chn&quot;<br>}<br>Tuple 2:<br>{<br>    &quot;id&quot;: &quot;2&quot;,<br>    &quot;Name&quot;: &quot;AB&quot;,<br>    &quot;City&quot;: &quot;Chn&quot;<br>}</pre><p>3.Country<br>Ind<br>SL<br>Pak<br>Ban<br> Write a query to get the below output:<br> Output Expected:<br>Ind-SL<br>Ind-Pak<br>Ind-Ban<br>SL-Pak<br>SL-Ban<br>Pak-Ban</p><pre>create table data (Sno int,country varchar(20));<br>insert into data (sno,country) values (1,&#39;Ind&#39;),(2,&#39;Sl&#39;),(3,&#39;Pak&#39;),(4,&#39;Ban&#39;);<br>#Query<br>select concat(a.country,&#39;-&#39;,b.country) from data as a cross join data as b on a.sno&lt;b.sno order by a.sno;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*GUJ3Osbe8kYfa73z-IePsQ.png" /><figcaption>Output</figcaption></figure><p>4.Write a query to get count of employee under each manager from the below employee table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*Uy8oM3e9asQ6hokccey5tA.png" /><figcaption>Input</figcaption></figure><pre>with temp as<br>(select a.employee_id,a.first_name,b.first_name as manager_name from employee as a join employee as b on a.manager_id=b.employee_id)<br>select manager_name,count(&#39;*&#39;) from temp group by manager_name;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*hDCqMq54zgl6QKuI3wQbgw.png" /><figcaption>Output</figcaption></figure><p>5.A<br>id<br>1<br>1<br>1<br>null<br>null</p><p>B<br>id<br>1<br>1<br>null<br>null<br>null</p><p>For above 2 table what is the output when joined left,right,inner</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/125/1*3LWfYkeOtV7RLnM_F9_Gng.png" /><figcaption>left</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/119/1*e2SHWsq0nRdu-n8j5OTI0g.png" /><figcaption>Right</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*CPsILBzlNXNqTsYGKMrTdg.png" /><figcaption>inner</figcaption></figure><p>6.[1, 3, 2, 4, 5, 6] write to code to print highest number</p><pre>a=[1, 3, 2, 4, 5, 6]<br>highestnumber = max(a)<br>print(highestnumber)</pre><p>7.product qtr1 qtr2 qtr3 qtr4<br> A 5000 4000 6000 1000<br> B 8000 4000 6000 2000<br>create the above dataframe</p><pre>data=[(&#39;A&#39;,5000,&#39;4000&#39;,&#39;6000&#39;,&#39;1000&#39;),(&#39;B&#39;,&#39;8000&#39;,&#39;4000&#39;,&#39;6000&#39;,&#39;2000&#39;)]<br>schema = structtype([Structfeild(&#39;prodcut&#39;, StringType(),True),<br>      Structfeild(&#39;qtr1&#39;, IntegerType(),True),<br>      Structfeild(&#39;qtr2&#39;, IntegerType(),True),<br>      Structfeild(&#39;qtr3&#39;, IntegerType(),True),<br>      Structfeild(&#39;qtr4&#39;, IntegerType(),True),<br>      ])<br>df =spark.createdataframe(data,schema=schema)<br>df.show()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5483346c0f5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conquering the Cloud: Lessons Learned from My Azure Data Engineering Interview]]></title>
            <link>https://medium.com/@bysanitribhuvan/conquering-the-cloud-lessons-learned-from-my-azure-data-engineering-interview-a7aba924d3ea?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7aba924d3ea</guid>
            <category><![CDATA[azure-services]]></category>
            <category><![CDATA[azure-data-engineer]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[pysaprk]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Wed, 14 Feb 2024 08:36:11 GMT</pubDate>
            <atom:updated>2024-02-14T08:36:11.044Z</atom:updated>
            <content:encoded><![CDATA[<p>1.Formulate an INNER JOIN query to merge data from tables ‘table1’ and ‘table2’.</p><pre>select * from table1 as a inner join table2 as b on a.id=b.id</pre><p>2.<strong>Develop a SQL query to assign rank to students based on their achieved marks in the student table.</strong></p><pre>select *,dense_rank() over(orderby marks desc) as ranking from student_table ;</pre><p>3.<strong>Identify and display duplicate student records in the database table ‘student’ using an appropriate SQL query.</strong></p><pre>select id,count(*) total from student_table group by(id)  having total&gt;1;</pre><p>4.<strong>Implement a custom logic within a PySpark DataFrame using a User-Defined Function.</strong></p><pre>def dup_drop(df):<br> df =df.dropDuplicates()<br> return df<br>#To apply<br>df=spark.read.csv(&quot;&quot;,header=True,infer_schema=True)<br>df= dup_drop(df)<br>df.show(5)</pre><p>5.<strong>Develop a PySpark code to effectively combine data from three tables: </strong>tabl1<strong>, </strong>tabl2<strong>, and </strong>tabl3<strong>.</strong></p><pre>df1 = table1.join(table2,table1[&#39;ID&#39;]==table2[&#39;ID&#39;],&#39;inner&#39;).select(&#39;*&#39;)<br>df2 = df1.join(table3,df1[&#39;ID&#39;]==table3[&#39;ID&#39;],&#39;inner&#39;).select(&#39;*&#39;)<br><br>df2.show()</pre><p>6.<strong>Implement code to read a Parquet file within the Databricks environment.</strong></p><pre>df=spark.read.parquet(&quot;&lt;Source Path&gt;&quot;)<br>df.show(4)</pre><p>7.Design a reusable UDF that facilitates the summation of corresponding values within specified columns.</p><pre>delimiter $$<br>create function sum_columns()<br>begin<br>select id,sum(col1,col2) from table group by(id);<br>end<br>delimiter;</pre><p>8.<strong>Explain the approach to establish a SparkSession within a Databricks environment through code examples.</strong></p><pre>conf=pyspark.SparkConf().setAppname(&quot;app&quot;).setMaster(&quot;local&quot;)<br>sc = pysaprk.SparkContext(conf=conf)<br>sprak=SparkSession(sc)</pre><p>9.<strong>What strategies can be employed to optimize the performance of a Spark job?</strong></p><p><strong>A)Several techniques can optimize Spark job naming and enhance performance:</strong></p><ol><li><strong>Leverage Spark configuration effectively:</strong> Configure properties like shuffle partitions, serialization, and memory settings to fine-tune job execution.</li><li><strong>Distinguish actions from transformations:</strong> Actions like show() trigger job execution and impact performance. Minimize their use for debugging and rely on transformations for data manipulation.</li><li><strong>Utilize broadcast joins and variables:</strong> Store frequently accessed data in memory (broadcast variables) or broadcast joins for faster access and improved processing speed.</li><li><strong>Employ </strong>groupBy<strong> and </strong>reduceBy<strong> strategically:</strong> Use these aggregation functions effectively for grouped data processing when applicable.</li><li><strong>Optimize partition alignment with </strong>coalesce<strong> and </strong>repartition<strong>:</strong> Adjust data distribution with these functions to improve shuffle performance and potentially parallelization.</li><li><strong>Select RDDs, DataFrames, or Datasets judiciously:</strong> Each data structure offers distinct advantages and performance characteristics. Choose the most suitable based on your specific needs and processing requirements.</li></ol><p>10.write a query to display data where table 1 has movie id and movie name and table2 has movie id and rating display on movies which have ratings</p><pre>SELECT t1.movie_id, t1.movie_name, t2.rating<br>FROM table1 AS t1<br>INNER JOIN table2 AS t2<br>ON t1.movie_id = t2.movie_id<br>WHERE t2.rating IS NOT NULL;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7aba924d3ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crafting Optimized UDFs and Stored Procedures for Average Sales Analysis in Data Engineering…]]></title>
            <link>https://medium.com/@bysanitribhuvan/crafting-optimized-udfs-and-stored-procedures-for-average-sales-analysis-in-data-engineering-e9cee61c6200?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9cee61c6200</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[stored-procedure]]></category>
            <category><![CDATA[udf]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 16:39:45 GMT</pubDate>
            <atom:updated>2024-01-26T16:39:45.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crafting Optimized UDFs and Stored Procedures for Average Sales Analysis in Data Engineering Interview</h3><p>In this article, I’ll share my recent data engineer interview experience, focusing on how I approached the challenge of creating a user-defined function (UDF) and a stored procedure to calculate the average sales within the past six months for active customers in a specified zip code. I’ll delve into the key requirements, my design thought process, and the considerations I made to ensure an efficient and scalable solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*M8KQxbtzShpoafcNBYP6sQ.png" /><figcaption>sample Data</figcaption></figure><h3><strong>SQL Procedure:</strong></h3><pre>#Defining SQL Procedure<br>DELIMITER $$<br>CREATE PROCEDURE get_avg_sales_active(IN in_zipcode INT)<br>BEGIN<br>  SELECT custumer_id,AVG(sales_amount) as AVG_sales<br>  FROM sales_data<br>  WHERE zipcode = in_zipcode<br>    AND date &gt;= DATE_SUB(CURDATE(), INTERVAL 6 MONTH)<br>    AND active_flag = 1 group by custumer_id;<br>END $$<br>DELIMITER ;<br>#calling SQL procedure<br>CALL get_avg_sales_active(500001);</pre><p><strong>Output</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*dNtMWLBHkQWSgp6BjcpbXQ.png" /></figure><h3>Python:</h3><pre>#Defining UDF <br>def getactive_avg_sales(zipcode):<br>    from pyspark.sql.functions import col,avg,date_sub,current_date<br>    return df.filter(<br>        (col(&quot;zipcode&quot;) == zipcode)<br>        &amp; (col(&quot;Active_Flag&quot;) == 1)<br>        &amp; (col(&quot;date&quot;) &gt;= add_months(current_date(), -6))<br>    ).groupBy(&quot;Custumer_ID&quot;).agg(avg(&quot;sales_amount&quot;).alias(&quot;avg_sales&quot;))<br>#calling SQL procedure<br>getactive_avg_sales(500001).show()</pre><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*N7h8KZ-5Iiclbbuw8ZuvZg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9cee61c6200" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UDF and its use in Data engineering]]></title>
            <link>https://medium.com/@bysanitribhuvan/udf-and-its-use-in-data-engineering-8fc532cde4fb?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fc532cde4fb</guid>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pyspark-dataframes]]></category>
            <category><![CDATA[udf]]></category>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 08:22:46 GMT</pubDate>
            <atom:updated>2024-01-16T08:22:46.584Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>A UDF is a function created by a programmer to add custom functionality to existing software applications or languages.</li><li>It extends the built-in capabilities of the application or language, allowing for tailored operations and calculations.</li></ul><h3><strong>Use cases for UDFs in data engineering:</strong></h3><ul><li><strong>Data cleaning and manipulation:</strong> Apply complex transformations, filtering, and calculations to your data.</li><li><strong>Feature engineering:</strong> Create new features from existing data based on your specific needs.</li><li><strong>Data validation and standardization:</strong> Ensure data quality by checking for specific conditions and formats.</li><li><strong>Custom aggregations:</strong> Perform custom calculations on groups of data that exceed native aggregate functions.</li><li><strong>Integration with external services:</strong> Interact with APIs or other external systems within your data pipeline.</li></ul><p>Example:</p><h3>Data Cleaning</h3><pre>DELIMITER //<br><br>CREATE FUNCTION clean_dataframe(df TABLE)<br>RETURNS TABLE<br>BEGIN<br>    -- Calculate missing value percentages<br>    CREATE TEMPORARY TABLE missing_pct AS<br>    SELECT column_name, COUNT(*) / (SELECT COUNT(*) FROM df) * 100 AS missing_pct<br>    FROM df<br>    GROUP BY column_name;<br><br>    -- Drop columns with more than 80% missing values<br>    ALTER TABLE df<br>    DROP COLUMN column_name<br>    WHERE column_name IN (SELECT column_name FROM missing_pct WHERE missing_pct &gt; 80);<br><br>    -- Drop duplicates<br>    DELETE FROM df<br>    WHERE rowid NOT IN (SELECT MIN(rowid) FROM df GROUP BY column1, column2, ...);  -- Replace with actual column names<br><br>    -- Handle missing values based on data types<br>    UPDATE df<br>    SET column1 = COALESCE(column1, 0),  -- Replace with actual numeric column names<br>        column2 = COALESCE(column2, &#39;N/A&#39;),  -- Replace with actual string column names<br>        column3 = COALESCE(column3, NULL);  -- Replace with actual date column names<br><br>    RETURN df;<br>END//<br><br>DELIMITER ;</pre><pre>import pandas as pd<br><br>def clean_dataframe(df):<br>    &quot;&quot;&quot;Cleans a DataFrame by handling missing values, duplicates, and data types.<br><br>    Args:<br>        df (pd.DataFrame): The DataFrame to clean.<br><br>    Returns:<br>        pd.DataFrame: The cleaned DataFrame.<br>    &quot;&quot;&quot;<br><br>    # Calculate missing value percentages<br>    missing_pct = (df.isna().sum() / df.shape[0]) * 100<br><br>    # Drop columns with more than 80% missing values<br>    df = df.drop(missing_pct[missing_pct &gt; 80].index, axis=1)<br><br>    # Drop duplicates<br>    df = df.drop_duplicates()<br><br>    # Handle missing values based on data types<br>    for col in df.columns:<br>        if pd.api.types.is_numeric_dtype(df[col]):<br>            df[col].fillna(0, inplace=True)<br>        elif pd.api.types.is_datetime64_dtype(df[col]):  # Handle date types<br>            df[col].fillna(pd.NaT, inplace=True)  # Replace with NaT for dates<br>        else:<br>            df[col].fillna(&quot;N/A&quot;, inplace=True)<br><br>    return df<br><br>#usage<br>df = pd.read_excel(&quot;E:\ADE\Cust_Data.xlsx&quot;)  # Load your DataFrame<br>df = clean_dataframe(df)  # Apply the UDF<br>print(df)  # View the processed DataFrame</pre><pre>#pyspark<br>import pyspark.sql.functions as F<br>from pyspark.sql.types import *<br><br>def clean_dataframe(df):<br>    &quot;&quot;&quot;Cleans a Spark DataFrame by handling missing values, duplicates, and data types.<br><br>    Args:<br>        df (pyspark.sql.DataFrame): The Spark DataFrame to clean.<br><br>    Returns:<br>        pyspark.sql.DataFrame: The cleaned Spark DataFrame.<br>    &quot;&quot;&quot;<br><br>   # Calculate missing value percentages directly on the DataFrame<br>    missing_pct = (df.select([(F.sum(F.when(col(c).isNull() | F.isnan(col(c).cast(DoubleType())), 1)) / df.count() * 100)<br>                             .alias(c) for c in df.columns]))<br><br>    # Drop duplicates<br>    df = df.dropDuplicates()<br><br>    # Handle remaining missing values based on data types<br>    for column in df.columns:<br>        if df.schema[column].dataType in (DoubleType(), IntegerType()):<br>            df = df.fillna(0, subset=[column])<br>        elif df.schema[column].dataType == DateType():<br>            df = df.fillna(F.lit(None), subset=[column])<br>        else:<br>            df = df.fillna(&quot;N/A&quot;, subset=[column])<br><br>    return df<br>#usage<br>df = spark.read.csv(&quot;E:\ADE\Cust_Data.csv&quot;, header = True , inferSchema= True)  # Load your DataFrame<br>df = clean_dataframe(df)  # Apply the UDF<br>print(df.show())  # View the processed DataFrame</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fc532cde4fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Initiating Pipeline Execution in Azure]]></title>
            <link>https://medium.com/@bysanitribhuvan/initiating-pipeline-execution-in-azure-c3171373a012?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3171373a012</guid>
            <category><![CDATA[azure-data-engineer]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[trigger]]></category>
            <category><![CDATA[azure-data-factory]]></category>
            <category><![CDATA[blob-storage]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 06:12:02 GMT</pubDate>
            <atom:updated>2024-01-16T06:12:02.911Z</atom:updated>
            <content:encoded><![CDATA[<p>Azure Pipelines offer a versatile range of options to initiate pipeline execution, catering to diverse development and deployment workflows. These methods include:</p><h3><strong>Debug Mode:</strong></h3><ul><li>Primarily employed during pipeline development to facilitate error identification and rectification.</li><li>Emulates pipeline execution without actual triggering, providing execution status (successful or failed) and failure reasons to guide developers in making necessary adjustments.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*pPV5yUEIWDDxNUclHEwCug.png" /><figcaption>Debug</figcaption></figure><h3><strong>On-Demand Trigger:</strong></h3><ul><li>Facilitates manual pipeline execution through the “Trigger Now” functionality.</li><li>Executes the pipeline as designed, implementing any intended modifications at the designated destination.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*gR0KLH3jTI27fMb7xFf_lA.png" /><figcaption>Trigger Now</figcaption></figure><p><strong>Configured Triggers:</strong></p><p>Offer automated pipeline execution based on specified events or schedules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*XeTvGNTzE6C4CTdpDxp46g.png" /><figcaption>New/Edit</figcaption></figure><p><strong>Scheduled Trigger:</strong> Executes pipelines according to a predetermined schedule, supporting flexible intervals (minutes, hours, days, weeks, or months).</p><ul><li>Permits configuration of active start and end dates to confine execution within a defined time period.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*hrDB-jDPJ7MDygEb1absaQ.png" /><figcaption>Schedule Trigger</figcaption></figure><p><strong>Tumbling Window Trigger:</strong> Ideal for handling historical data for copying or migration.</p><ul><li>Executes pipelines at specified time slices or periodic intervals.</li><li>Supports a maximum of two dependencies, including self-dependency or dependency on other tumbling window pipelines.</li><li>Self-dependency mandates a negative offset, while offset and window size are optional for other dependencies.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*iVqS4ZU_g4SIPfNUfSY-VQ.png" /></figure><p><strong>Event-Based Trigger:</strong> Initiates pipeline execution in response to designated events, such as new or updated datasets.</p><ul><li>Commonly leveraged for loading incremental data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*dsTe734lflo69xahjEcpVQ.png" /><figcaption>Event Based</figcaption></figure><ul><li>Often implemented using Azure Logic Apps.</li></ul><p>Additional Considerations:</p><ul><li>Azure DevOps CLI also enables command-line control for manual pipeline execution.</li><li>Triggers can be configured to respond to events from external services or tools.</li><li>Ensure appropriate permissions are granted for pipeline execution within the project.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3171373a012" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SCD-Slowly changing dimensions]]></title>
            <link>https://medium.com/@bysanitribhuvan/scd-slowly-changing-dimensions-ba2eb53f52eb?source=rss-09c847523d1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba2eb53f52eb</guid>
            <category><![CDATA[scd-type-2]]></category>
            <category><![CDATA[azure-data-factory]]></category>
            <category><![CDATA[scd]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Bysanitribhuvan]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 18:56:34 GMT</pubDate>
            <atom:updated>2024-01-04T18:56:34.788Z</atom:updated>
            <content:encoded><![CDATA[<p>This article delves into Slowly Changing Dimension (SCD) tables, crucial components of data warehousing that manage both current and historical dimension data over time. As implied by their name, dimension tables typically contain relatively static information describing facts. However, some dimensions occasionally undergo changes, demanding effective techniques for handling these updates.</p><p>SCD implementations fall into three main categories: Type 0, Type 1, and Type 2. Each approach addresses the trade-off between preserving historical data and maintaining efficient queries:</p><ul><li><strong>Type 0</strong>: This simplest method directly replaces outdated values within the table, offering efficient queries but obscuring historical information.</li><li><strong>Type 1</strong>: For enhanced tracking, Type 1 introduces an “active flag” column identifying current and outdated records. New values are inserted as separate rows with active flags set to 1, while older rows become inactive. This balances historical preservation with performance considerations.</li><li><strong>Type 2</strong>: Offering the most comprehensive historical record, Type 2 stores all changes alongside timestamps and user information. While offering rich historical context, this approach can impact query performance for large datasets.</li></ul><p>The subsequent sections will dive deeper into implementing SCD in Azure Data Factory, utilizing a practical example to illustrate the step-by-step process. By leveraging Azure’s powerful data processing capabilities, you can effectively manage your slowly changing dimensions and gain valuable insights from your data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*-ch4po1U9It7kbJLNCPy7Q.png" /><figcaption>Example Dimensional table</figcaption></figure><ul><li>Assuming the input data resides in either Azure Blob Storage or ADLS and the target table is already established in SQL, we can proceed with the data processing operation.</li></ul><p>Develop Azure Data Factory datasets to establish connections with a Blob storage source for input data retrieval and a SQL Server destination for final data storage. Employ linked services to facilitate these connections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7TIdESp4PsZQBEslzFeaQ.png" /><figcaption>input dataset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFt5imk6nKQ6c1lCj-FT1Q.png" /><figcaption>output data set</figcaption></figure><p>Create a dataflow adding two sources input and output as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*TByx5Dl8qmETbsrp4IGyKA.png" /></figure><p>For both source and destination derive a columns for surrogate key naming source hash code and destination hash code<br>with command <strong>md5(column_name)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcK9gCzhPCIEAHcA-jUdng.png" /></figure><p>use exists operation in ADF and check doesn&#39;t exists for source and exists for destination comparing surrogate key(sourcehashcode=destinationhashcode)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*4VPRMzChyt9cDH9671imlg.png" /></figure><p>Source derive columns end date and active flag as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26KWdV5ysMolqnpyJue-NA.png" /></figure><p>Destination dervive as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cu9f_BRfS0RthUrjD4fzXA.png" /></figure><p>Use alter if for insert if not exist and update if exists as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*5TmdUY5GCUykM30n6h3PLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*NEFTiqTss0M-wiMjgg6t8w.png" /></figure><p>Add sink</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8xo12vM4AEQHWnM7KsmFMA.png" /></figure><p>add key columns on which it has to update then create dataflow pipeline and trigger</p><p>Output after triggering pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E8C6qxnCvGJbyqjfK-wapA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba2eb53f52eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>