<?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 Sonali on Medium]]></title>
        <description><![CDATA[Stories by Sonali on Medium]]></description>
        <link>https://medium.com/@489sonali?source=rss-b30032b02340------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9AqjJ_Rk1TdQLxM9aF5qig.jpeg</url>
            <title>Stories by Sonali on Medium</title>
            <link>https://medium.com/@489sonali?source=rss-b30032b02340------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 03:29:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@489sonali/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[Failed to access Cloud Storage (Azure Databricks Unity Catalog External Storage Integration Error)!!]]></title>
            <link>https://medium.com/@489sonali/failed-to-access-cloud-storage-azure-databricks-unity-catalog-external-storage-integration-error-7bdd7141fa71?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bdd7141fa71</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 09:45:48 GMT</pubDate>
            <atom:updated>2025-06-10T09:46:08.968Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*kkk0cVa5i01KOxiP9ArQrA.png" /><figcaption>External Location in unity catalog</figcaption></figure><p>So, I was working with databricks unity catalog metastore and create managed and unmanaged containers in my Storage account.I provided all the required credential while setting up connections for creating external locations in the unity catalog still facing the above issue of connection .</p><p>Also , while performing <em>dbutils.fs.rm(“path”)</em> python code I am getting the access issue even though I have already granted “Storage Blob Data Contributer” role on ADLS.</p><h3>Conclusion</h3><p>On digging deep, I resolved it by providing the more granular access(ACL) to the databricks connector and providing myself “Storage Blob Data Owner” IAM role at the container level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Z3zMYobLbiBU2clVcko4Q.png" /><figcaption>ACL Access at container level</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajHGgKw5_h40XObbja8OZw.png" /><figcaption>Connection is working fine</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bdd7141fa71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating mini Kafka DE pipeline!]]></title>
            <link>https://medium.com/@489sonali/creating-mini-kafka-de-pipeline-f1af267536cb?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1af267536cb</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 10:59:53 GMT</pubDate>
            <atom:updated>2025-06-03T10:59:53.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*73-rro8Jy-HunCN1WdNfow.png" /></figure><p>So, in order to deepen my understanding of kafka basic flow I decided to built a pipeline using Kafka ,Confluent ,Databricks and Pycharm.To better understand the kafka producer ,topic and consumer concepts. Also, applying my python knowledge for better understanding.I use the invoices data and treat it like a streaming data.</p><p>First we need to create <strong>producer</strong> using python code in Pycharm which sends the data to the topic in confluent kafka .</p><p>Below is the python code I use to implement to create <strong>producer</strong>:-</p><p><em>from confluent_kafka import Producer<br>import json<br>import time</em></p><p><em>class InvoiceProducer:<br> def __init__(self):<br> self.topic = “invoices”<br> #Add the mandatory config<br> self.conf = {‘bootstrap.servers’: ‘pkc-56d1g.eastus.azure.confluent.cloud:9092’,<br> ‘security.protocol’: ‘SASL_SSL’,<br> ‘sasl.mechanism’: ‘PLAIN’,<br> ‘sasl.username’: ‘Z6NWCOMEHE37NY3V’,#confluent key and secret<br> ‘sasl.password’: ‘yW710hqop3ReOsXT8ALOjw5j+IpQ1M931jmLEIygd9ypeXCSKr67ch8Y+tcz4BjR’,<br> ‘client.id’: “sonali-laptop”}</em></p><p><em>def delivery_callback(self, err, msg):<br> if err:<br> print(‘ERROR: Message failed delivery: {}’.format(err))<br> else:<br> #if message is delivered successfully convert to string decode(‘utf-8’)<br> key = msg.key().decode(‘utf-8’)<br> invoice_id = json.loads(msg.value().decode(‘utf-8’))[“InvoiceNumber”]<br> print(f”Produced event to : key = {key} value = {invoice_id}”)</em></p><p><em>def produce_invoices(self, producer,cnt):<br> c=0<br> with open(“data/invoices.json”) as lines:<br> #Reading the lines of my invoice file<br> for line in lines:<br> invoice = json.loads(line)<br> store_id = invoice[“StoreID”]<br> #send the store_id as key and invoice as a message<br> producer.produce(self.topic, key=store_id, value=json.dumps(invoice), callback=self.delivery_callback)<br> #Produce the message to kafka cluster and<br> #receive the acknowledge from broker which we pass to func delivery_callback<br> time.sleep(0.5)<br> producer.poll(1)#poll the ack<br> c+=1<br> if cnt==c:<br> break</em></p><p><em>def start(self):<br> #start the production<br> kafka_producer = Producer(self.conf)<br> self.produce_invoices(kafka_producer,10)<br> kafka_producer.flush(10)# is some ack not receive wait</em></p><p><em>if __name__ == “__main__”:<br> invoice_producer = InvoiceProducer()<br> invoice_producer.start()</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yEE-C5DCMkB5XE9JAnEEgA.png" /><figcaption>Pycharm Output after run</figcaption></figure><p>Then we create a <strong>cluster</strong> in confluent with “invoice” topic to receive the messages from producer. The messages are received from producer and store in confluent <strong>topic</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PN3iHIdygW2jVSTLCs4q6w.png" /><figcaption>Confluent screenshot of Topic</figcaption></figure><p>Now , we will create <strong>consumer</strong> in databricks .</p><p>Install “spark-kafka-connector” in my Databricks cluster.</p><p>Below is the code implemented in Databricks for kafka <strong>consumer</strong>:-</p><p>%python</p><p><em>from pyspark.sql import SparkSession</em></p><p><em>spark = SparkSession.builder \.config(“spark.jars.packages”, “org.apache.spark:spark-sql-kafka-0–10_2.12:3.5.0”) \.getOrCreate()</em></p><p><em>BOOTSTRAP_SERVER = “pkc-56d1g.eastus.azure.confluent.cloud:9092”</em></p><p><em>JAAS_MODULE =“org.apache.kafka.common.security.plain.PlainLoginModule”</em></p><p><em>CLUSTER_API_KEY = “Z6NWCOMEHE37NY3V”</em></p><p><em>CLUSTER_API_SECRET=“yW710hqop3ReOsXT8ALOjw5j+IpQ1M931jmLEIygd9ypeXCSKr67ch8Y+tcz4BjR”</em></p><p><em>#connecting to kafka and reading the data</em></p><p><em>df = ( spark.read</em></p><p><em>.format(“kafka”)</em></p><p><em>.option(“kafka.bootstrap.servers”, BOOTSTRAP_SERVER)</em></p><p><em>.option(“kafka.security.protocol”, “SASL_SSL”)</em></p><p><em>.option(“kafka.sasl.mechanism”, “PLAIN”)</em></p><p><em>.option(“kafka.sasl.jaas.config”, f”{JAAS_MODULE} required username=’{CLUSTER_API_KEY}’ password=’{CLUSTER_API_SECRET}’;”)</em></p><p><em>.option(“subscribe”, “invoices”)# subscribe from topic name</em></p><p><em>.load()</em></p><p><em>)</em></p><p><em>%python</em></p><p><em># Set Kafka configurations</em></p><p><em>kafka_bootstrap_servers = “pkc-56d1g.eastus.aazure.confluent.cloud:9092”</em></p><p><em>kafka_security_protocol = “SASL_SSL”</em></p><p><em>kafka_sasl_mechanism = “PLAIN”</em></p><p><em>kafka_sasl_jaas_config=“org.apache.kafka.common.security.plain.PlainLoginModule</em></p><p><em>required username=’Z6NWCOMEHE37NY3V’ password=’yW710hqop3ReOsXT8ALOjw5j+IpQ1M931jmLEIygd9ypeXCSKr67ch8Y+tcz4BjR’;”</em></p><p><em>spark.conf.set(“spark.kafka.bootstrap.servers”, kafka_bootstrap_servers)</em></p><p><em>spark.conf.set(“spark.kafka.security.protocol”, kafka_security_protocol)</em></p><p><em>spark.conf.set(“spark.kafka.sasl.mechanism”, kafka_sasl_mechanism)</em></p><p><em>spark.conf.set(“spark.kafka.sasl.jaas.config”, kafka_sasl_jaas_config)</em></p><p><em># Now display the DataFrame</em></p><p><em>display(df)</em></p><p>The following values are available in confluent to set the configurations like <em>BOOTSTRAP_SERVER,CLUSTER_API_KEY and CLUSTER_API_SECRET.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1af267536cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Typecast error in Databricks SQL!]]></title>
            <link>https://medium.com/@489sonali/typecast-error-in-databricks-sql-c5bd1019e165?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5bd1019e165</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-engineer]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Mon, 19 May 2025 19:06:15 GMT</pubDate>
            <atom:updated>2025-05-19T19:06:15.463Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>So, I was performing a normal type conversion from string to integer type for a person_id column in the Databricks .To my surprise I was getting the values as NULL output for all the rows it was quite confusing to understand what could be the reason behind it.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j0cnMVmn581aUirYiXcZxw.png" /></figure><p><strong>I got the solution why i got this error?</strong></p><p><strong>INT / </strong><strong>INTEGER</strong> in Spark is a <strong>32-bit signed integer</strong>, and it supports values only in the range:</p><ul><li>2,147,483,648 to 2,147,483,647</li></ul><p>So ,if your string contains numbers larger than that:</p><p><em>CAST(‘9876543210’ AS INT) → NULL</em></p><p>You should cast the column to BIGINT instead of INT</p><p>Which should be enough for most use cases.:</p><p>BIGINT supports <strong>64-bit signed integers</strong>:</p><ul><li>9,223,372,036,854,775,808 to 9,223,372,036,854,775,807</li></ul><p><em>CAST(‘9876543210’ AS BIGINT) →9876543210</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5bd1019e165" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My experience from 20+interviews in big tech as a Data Engineer!]]></title>
            <link>https://medium.com/@489sonali/my-learning-from-20-interviews-in-big-tech-as-a-data-engineer-464c6e78d08a?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/464c6e78d08a</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Sun, 11 May 2025 09:26:33 GMT</pubDate>
            <atom:updated>2025-05-11T09:28:59.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P_M5lMxWLYofGsHfgKTu6g.png" /></figure><p><strong><em>After appearing for more than 20+ interviews in past year which include some big tech companies like google, apple, salesforce and microsoft. I would like to share what is the main focus of major big tech giants in the Data Engineering domain.</em></strong></p><p><strong>SQL-</strong>You should be very good while working with SQL from medium to hard that should be top notch for every data engineer profile .Solve SQL from every site like leetcode, stratascratch, datalemur. Dig more into logic while learning it helps while solving questions in limited time frame during interview.</p><p><strong>Python- </strong>Easy to medium question which includes string, array, two pointers, hashmap ,linked list and in some cases DP and tree could be ask .The leetcode famous problems work best for this try to solve any famous dsa sheet and do make notes.You can’t escape DSA if your target is big tech.</p><p><strong>Data Engineer concepts-</strong>Some basic concepts of Spark it’s architecture, internals working and Pyspark for coding it’s syntax are the basic expectation for every company.</p><p><strong>Cloud -</strong>The cloud is vast the good knowledge of some famous services works best there use case how they work some mini projects using same add to more advantage .Azure,AWS,GCP all are good adopt the one you are most comfortable and have work experience , try to master it rather than learning all three.Adding a certification is advantage for selection in any service based firm for product it doesn’t matter that much.</p><p><strong>Know your project</strong>- Yes, you should be able to explain your project with every minute details as they ask many cross questions on the same not just some basics they want to dig how comfortable you are while working independently and your real world knowledge .It will also be helpful in system design round .</p><p>While it comes to resume shortlisting showcasing your work through some public platforms like Medium, Github, Tableau public and also pasting the profile link of leetcode in resume showcase your enthusiasm of consistent learning . At the end it’s the patience which matters and also luck don’t be disheartened by any interview it’s the marathon of continuous learning one day luck will be yours when time came.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=464c6e78d08a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks doesn’t support Recursive CTE]]></title>
            <link>https://medium.com/@489sonali/databricks-not-support-recursive-cte-e76ff8293e67?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/e76ff8293e67</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 09:15:43 GMT</pubDate>
            <atom:updated>2025-04-12T14:57:14.633Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*dmE3WfWYeA2i5BSG820lag.png" /><figcaption>Hierarchical diagram</figcaption></figure><p><strong><em>So, for the input of data in the columns like:-</em></strong></p><p>INSERT INTO emp (id, parent_id)<br>VALUES<br>(1, NULL),<br>(2, 1),<br>(3, 2),<br>(4, 3);</p><p><strong><em>I wanted the output to be like to display my hierarchical path of different levels:-</em></strong></p><ul><li>1 has no parent, so its path is just 1.</li><li>2 is a child of 1, so its path is 1 &lt; 2.</li><li>3 is a child of 2, so its path is 1 &lt; 2 &lt; 3.</li><li>4 is a child of 3, so its path is 1 &lt; 2 &lt; 3 &lt; 4.</li></ul><p>So, I was working with some sql query and in order to produce hierarchy for the tables i wanted to use recursive cte in my databricks notebook as it supports cte operation for sql.But, to my suprise the below code fails at Databricks doesn’t support recursive cte operations. So, I try to find some alternative way to achieve this in the databricks and came out with two different solutions .</p><h3><strong>Using Recursive CTE approach:-</strong></h3><p>WITH RECURSIVE HierarchyPath AS (<br><strong><em> — Anchor member or Base Case:</em></strong></p><p><strong><em>Select the root item (id = 1)</em></strong><br> SELECT id, parent_id, CAST(id AS VARCHAR(100)) AS path<br> FROM hierarchy<br> WHERE parent_id IS NULL <strong><em>— Start from the root (id = 1)</em></strong></p><p>UNION ALL</p><p><strong><em>— Recursive member:</em></strong></p><p><strong><em>Select the child item and concatenate the path</em></strong><br> SELECT h.id, h.parent_id, CONCAT(hp.path, ‘ &lt; ‘, CAST(h.id AS VARCHAR(100))) AS path<br> FROM hierarchy h<br> INNER JOIN HierarchyPath hp ON h.parent_id = hp.id <strong><em>— Join to find the children</em></strong><br><strong><em>)<br> — Final query: Select the full hierarchy path for each item</em></strong><br>SELECT id, parent_id, path<br>FROM HierarchyPath<br>ORDER BY path;</p><h3>Here is the alternative way to achieve this in Databricks using Iterative Approach with JOINS:</h3><p>WITH Level1 AS (<br> <strong><em>— Start from the top-level (root)</em></strong><br> SELECT id, parent_id, CAST(id AS STRING) AS path<br> FROM hierarchy<br> WHERE parent_id IS NULL<br>),<br>Level2 AS (<br> — Join Level1 with Level2 (children of Level1)<br> SELECT h.id, h.parent_id, CONCAT(l1.path, ‘ &lt; ‘, CAST(h.id AS STRING)) AS path<br> FROM hierarchy h<br> JOIN Level1 l1 ON h.parent_id = l1.id<br>),<br>Level3 AS (<br> — Join Level2 with Level3 (children of Level2)<br> SELECT h.id, h.parent_id, CONCAT(l2.path, ‘ &lt; ‘, CAST(h.id AS STRING)) AS path<br> FROM hierarchy h<br> JOIN Level2 l2 ON h.parent_id = l2.id<br>),<br>Level4 AS (<br> — Join Level3 with Level4 (children of Level3)<br> SELECT h.id, h.parent_id, CONCAT(l3.path, ‘ &lt; ‘, CAST(h.id AS STRING)) AS path<br> FROM hierarchy h<br> JOIN Level3 l3 ON h.parent_id = l3.id<br>)<br><strong><em> — Final result with all levels</em></strong><br>SELECT id, parent_id, path FROM Level1<br>UNION ALL<br>SELECT id, parent_id, path FROM Level2<br>UNION ALL<br>SELECT id, parent_id, path FROM Level3<br>UNION ALL<br>SELECT id, parent_id, path FROM Level4<br>ORDER BY path;</p><h3>Explanation:</h3><ol><li><strong><em>Level1</em></strong><em>: Selects the root element (</em><em>id = 1) and starts building the hierarchy path.</em></li><li><strong><em>Level2</em></strong><em>: Joins the </em><em>Level1 results (root) to find its children (id = 2) and appends them to the path.</em></li><li><strong><em>Level3</em></strong><em>: Joins </em><em>Level2 to find children of the second level (id = 3), and so on.</em></li><li><em>The </em><em>UNION ALL operation combines all levels together and sorts them by the </em><em>path.</em></li></ol><h3>Using the Pyspark in Databricks</h3><p><strong><em>There is one more way I thought of by using Pyspark capability to work with hierarchical structure .</em></strong></p><p><strong><em>Step 1: Create the DataFrame</em></strong></p><p><strong><em>Let’s first create the sample DataFrame that represents the hierarchy.</em></strong></p><p>from pyspark.sql import SparkSession<br>from pyspark.sql.functions import col, concat_ws</p><p><em># Initialize Spark session<br></em>spark = SparkSession.builder.master(“local”).appName(“Hierarchy”).getOrCreate()</p><p><em># Sample data representing the hierarchy (id, parent_id)</em><br>data = [(1, None), (2, 1), (3, 2), (4, 3)]<br>columns = [“id”, “parent_id”]</p><p><em># Create a DataFrame<br></em>df = spark.createDataFrame(data, columns)</p><p>df.show()</p><p><strong>Step 2: Iteratively Build the Hierarchy</strong></p><p><strong><em>In PySpark, we can use iterative joins to build the hierarchy, just like we would in SQL. However, here we do this programmatically by iterating over the levels.</em></strong></p><p><strong><em># Initialize the hierarchy with the root node</em></strong><br>level_df = df.filter(col(“parent_id”).isNull()).withColumn(“path”, col(“id”).cast(“string”))</p><p><strong><em># Set the max depth of the hierarchy (or use a condition to stop once no more rows are added)</em></strong><br>max_depth = 10<br>current_depth = 0<br>while current_depth &lt; max_depth:<br><strong> <em># Perform the join for the next level</em></strong><br> new_level_df = level_df.alias(‘l’) \<br> .join(df.alias(‘d’), col(‘l.id’) == col(‘d.parent_id’), ‘inner’) \<br> .withColumn(‘path’, concat_ws(‘ &lt; ‘, col(‘l.path’), col(‘d.id’).cast(“string”))) \<br> .select(‘d.id’, ‘d.parent_id’, ‘path’)<br> <br><em> </em><strong><em># If no new rows are added, break the loop</em></strong><em><br></em> if new_level_df.count() == level_df.count():<br> break</p><p>level_df = new_level_df<br> current_depth += 1</p><p><strong><em># Show the final result</em><br></strong>level_df.orderBy(“path”).show(truncate=False)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e76ff8293e67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks Utilities Package!]]></title>
            <link>https://medium.com/@489sonali/databricks-utilities-package-296021f83788?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/296021f83788</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Thu, 26 Dec 2024 11:35:02 GMT</pubDate>
            <atom:updated>2024-12-26T11:35:44.874Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFx6nVbdeLohML7XSm_g4A.png" /></figure><p>Databricks provides several utility packages that help with managing and interacting with the Databricks environment. These utilities offer convenient methods for working with the Databricks File System (DBFS), handling secrets, managing workflows, and interacting with notebooks. Here are some of the most commonly used utility packages in Databricks:</p><h3>1. <strong>dbutils.fs</strong> – File System Operations:</h3><p>This module allows you to interact with the Databricks File System (DBFS), which is the distributed file system in Databricks. It provides functionality to read, write, move, and delete files.</p><p><strong>dbutils.fs.ls(path)</strong>: List files in a directory.</p><p><strong>dbutils.fs.cp(source, destination)</strong>: Copy a file or directory.</p><p><strong>dbutils.fs.mv(source, destination)</strong>: Move a file or directory.</p><p><strong>dbutils.fs.head(path, maxBytes=1024)</strong>: Read the first few bytes of a file.</p><p><strong>dbutils.fs.mkdirs(path)</strong>: Create directories.</p><h3>2. <strong>dbutils.secrets</strong> – Secrets Management</h3><p>The <strong>dbutils.secrets</strong> module helps you retrieve sensitive information from Databricks <strong>Secret Scopes</strong>. This is useful for managing API keys, credentials, and other secrets securely.</p><p><strong>dbutils.secrets.get(scope, key)</strong>: Get a secret value from a secret scope.</p><p><strong>dbutils.secrets.list(scope)</strong>: List all secrets in a given scope.</p><p><strong>dbutils.secrets.listScopes()</strong>: List all available secret scopes.</p><h3>3. <strong>dbutils.widgets</strong> – Widgets for Notebooks</h3><p>Widgets allow you to pass parameters to notebooks. You can create text boxes, dropdowns, and other UI components for interactive notebooks.</p><p><strong>dbutils.widgets.text(name, defaultValue, label)</strong>: Create a text input widget.</p><p><strong>dbutils.widgets.dropdown(name, defaultValue, choices, label)</strong>: Create a dropdown widget.</p><p><strong>dbutils.widgets.remove(name)</strong>: Remove a widget.</p><p><strong>dbutils.widgets.get(name)</strong>: Get the value of a widget.</p><h3>4. <strong>dbutils.notebook</strong> – Notebook Operations</h3><p>This module allows you to interact with other notebooks, execute them, and pass parameters or receive output.</p><p><strong>dbutils.notebook.run(path, timeout_seconds, arguments)</strong>: Run another notebook.</p><p><strong>dbutils.notebook.exit(value)</strong>: Exit a notebook and return a value.</p><h3>5. <strong>dbutils.library</strong> – Library Management</h3><p>The <strong>dbutils.library</strong> module helps you manage libraries, like installing PyPI or Maven libraries.</p><p><strong>dbutils.library.installPyPI(package, version)</strong>: Install a Python package from PyPI.</p><p><strong>dbutils.library.installMaven(coordinate)</strong>: Install a Maven artifact.</p><h3>6. <strong>dbutils.cluster</strong> – Cluster Information (for Databricks Runtime)</h3><p>The <strong>dbutils.cluster</strong> module provides functions to retrieve information about the current cluster.</p><p><strong>dbutils.cluster.getClusterId()</strong>: Get the ID of the current cluster.</p><p><strong>dbutils.cluster.getClusterName()</strong>: Get the name of the current cluster.</p><p>The utility package is a central part of many Databricks workflows and is heavily utilized for automation, parameterization, and integration across notebooks, jobs, and other Databricks services.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=296021f83788" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Fledged Data Project on “Customer Purchase Behaviour Analysis”!]]></title>
            <link>https://medium.com/@489sonali/dive-into-a-full-fledged-data-project-on-retail-purchase-behavior-analysis-df562ebe9b17?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/df562ebe9b17</guid>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[visualization]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 07:54:27 GMT</pubDate>
            <atom:updated>2024-11-17T10:26:55.043Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6b_Zp2FowDQ5xjqb4LsZ3g.png" /></figure><h3>Problem Statement</h3><p>A large retail company wants to improve its understanding of customer purchase behaviour to enhance its marketing strategies and increase sales. They have accumulated a large volume of transaction data from various sources, including online stores, physical stores, and loyalty programs. The company seeks to leverage this data to identify patterns and trends in customer purchases, predict future purchasing behaviour, and tailor marketing efforts accordingly.</p><h3>Generate the data</h3><p>I generate the fake data by adding 5% anomolies using the python code stored in my github .The data generated is stored in S3 to further perform the ETL .Consider the data stored from 3 systems as:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*znDIFE9l2lryEBviI9ZKnw.png" /></figure><h3>Performing the ETL</h3><p>I use the databricks to perform ETL by mounting the S3 bucket to access the data and also clean the data also use secret and access key provided externally by using widgets .The transformed data is again stored in the processed bucket of S3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRq4i-MhZm6Tc_FR5RR_9A.png" /></figure><h3><strong>Data Modelling</strong></h3><p>Performed the data modelling on stored data using google bigquery to extract data and using the “Star Schema” modelling for the data gathered.Performing the appropriate joins using primary and foreign keys considering Transactions as the “Fact table” and Items, Date, Customers as “Dimension table”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ut32MMZH_r_HZF_SgNFBJA.png" /></figure><h3><strong>Customer Segmentation:</strong></h3><p>Performing the K-means clustering by grouping the segments into 3 groups according to their age and further gain some insights from the same using basic ML algorithms . I use the elbow method to determine optimal no of clusters .After clustering the data the following are results obtained .As the data is quite random there is not more significant insights gained from the same.</p><p>github link:-<a href="https://github.com/sonali489/Customer-Purchase-Behavior-Analysis-for-a-Retail-Company">https://github.com/sonali489/Customer-Purchase-Behavior-Analysis-for-a-Retail-Company</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFd_50xWDAgWup-sNoy5nw.png" /></figure><h3>Visualization</h3><p>The cleaned data is stored in S3 again and used to gather insight using the interactive Tableau dashboard which can be further drill down by applying various filters to gain insight.</p><p>The link for the tableau public :-<a href="https://public.tableau.com/app/profile/sonali1935/viz/CustomerPurchaseBehaviourAnalysis/Dashboard1">https://public.tableau.com/app/profile/sonali1935/viz/CustomerPurchaseBehaviourAnalysis/Dashboard1</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7809fp8Gq_vJXGCfMBaSw.png" /><figcaption>Purchase Behaviour Analysis</figcaption></figure><h3><strong>Conclusion</strong></h3><p>The below is the conclusion drawn from both the dashboard and ML model about the Purchase behaviour analysis for the same.</p><blockquote>From the data we can see that even the top customers are not the frequent buyers yearly.</blockquote><blockquote>The Female contribution is less in sales while they should be the major contributor.</blockquote><blockquote>The Rating by customers is quite satisfactory for all the 4 areas of items which implies customer satisfaction.</blockquote><blockquote>Customers like to buy more from the Physical stores than through other modes.</blockquote><blockquote>Customers spend is not increasing in same proportion as discount while there is some increase maybe due to festive season.</blockquote><blockquote>The people of age around 42 years spend most and purchase more quantity while they benefit less from discount they receive less than half compare to other age groups.</blockquote><blockquote>Special offers should be introduce for this high spender group in the month of June-July especially on Electronics item which will benefit company .</blockquote><blockquote>More Physical stores should be open and discounts should be given compare to online .</blockquote><h3>Recommendations</h3><blockquote>Special membership cards can be introduced for premium buyers for frequent visits .</blockquote><blockquote>Special offers for female and more products related to female should be introduced in store.</blockquote><blockquote>More physical stores should be open as customer buy more from these stores.</blockquote><blockquote>The general discount on item is not giving significant enhance in sales .So, providing discount coupon and special programs will be more beneficial for the company .</blockquote><blockquote>We are getting least revenue from the Accessories section .So, new kind of women Accessories could be introduced to attract customers.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df562ebe9b17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analytics using Pyspark in Databricks.]]></title>
            <link>https://medium.com/@489sonali/analytics-using-pyspark-in-databricks-74dee4267264?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/74dee4267264</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[women]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Tue, 02 Apr 2024 07:23:01 GMT</pubDate>
            <atom:updated>2024-04-02T07:24:51.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-Q3bzfX9wXrDKSb8E2Uog.png" /><figcaption>Databricks Dashboard</figcaption></figure><p>Profile -<a href="https://databricks-prod-cloudfront.cloud.databricks.com/public/4027ec902e239c93eaaa8714f173bcfc/7303802642265084/2833644774587999/3189841922741429/latest.html">https://databricks-prod-cloudfront.cloud.databricks.com/public/4027ec902e239c93eaaa8714f173bcfc/7303802642265084/2833644774587999/3189841922741429/latest.html</a></p><h3>Mount with S3</h3><p>Inside S3 bucket “buckinew” the csv file is uploaded .Hence, first I will fetch the data from S3 by mounting databricks to S3 by using secret key and access key as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v2TvPM5zdBTUbVV7nlvvaw.png" /></figure><h3>Analyzation using Pyspark Code</h3><p>1-To show the churn based on gender.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8KnztVad73i3gpigPJrCdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQBV3Wqmd_BRG7-mIPzT2w.png" /></figure><p>2-Churn based on Country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHcICz_dCNoJ-UQcnuR2Lg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*EKbuJKK9cUucyQbbTYbLyg.png" /></figure><p>3-Churn based on Age.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4rKIQRoiffuIrOJWRDiy0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*mhp8jdkzGIQyd_sGiL326Q.png" /></figure><p>4-No of empty bank account churn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k1WkWn6fFYAG6537v1mg-w.png" /></figure><p>5-Churn percentage based on each product number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VX9t9OFpqEZ35guJz4Ukwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G_ee_reSbYdXJPzKiqdPqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*7h-gJnPyf5UeOlOadeI3Qw.png" /></figure><h3>Conclusion</h3><p>Here, is the conclusion drawn from the churn data by the analyzation performed in the databricks notebook.</p><p>1-People between the age group of 40 to 45 shows maximum churn.</p><p>2-Countries like France and Germany shows maximum churn of 40% while for Spain it’s almost half.</p><p>3-There is more churn by female compare to male even though the difference is not great.</p><p>4-The 500 accounts which were empty shows the customer churn.</p><p>5-People with product_number 4 shows the 100% churn .</p><p>Github-<a href="https://github.com/sonali489/Data-Engineering/blob/main/Customer%20Churn%20Analysis.py">https://github.com/sonali489/Data-Engineering/blob/main/Customer%20Churn%20Analysis.py</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74dee4267264" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating reports in Databricks.]]></title>
            <link>https://medium.com/@489sonali/generating-reports-in-databricks-c8a81b779b48?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8a81b779b48</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Sun, 24 Mar 2024 12:09:25 GMT</pubDate>
            <atom:updated>2024-03-24T12:09:25.338Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Business use case</strong></h3><p>Create notebook and generate an output report to get the sum of sales on daily, monthly and weekly basis using databricks.</p><h4>Steps</h4><p>1-Upload the sales.csv data from the local in the databricks and select on create table with UI.Select the cluster and name the table as sales.The new table is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7a2Uf3PKFhW5CHmuL_Ga9Q.png" /></figure><p>2- A dropdown will be created at the top-left of selecting the time_period by executing the below python code in a databricks notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZjtkQ9_2E4oVCStNSw_FmA.png" /></figure><p>3-In the below code , we will import python datetime functions and write python code to select the weekly, monthly and daily report .The below sql query will select sum of sales according to time_period given and display the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdLvA9ZMEZ6E1IeuEXWoTg.png" /></figure><p><strong>Conclusion</strong></p><p>The above mini code of python in databricks is beneficial in generating reports on the basis of daily, monthly and yearly using a simple dropdown menu.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8a81b779b48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bye ChatGPT, hello to RTX!]]></title>
            <link>https://medium.com/@489sonali/bye-chatgpt-hello-to-rtx-77fa29dfb62f?source=rss-b30032b02340------2</link>
            <guid isPermaLink="false">https://medium.com/p/77fa29dfb62f</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sonali]]></dc:creator>
            <pubDate>Fri, 22 Mar 2024 16:22:55 GMT</pubDate>
            <atom:updated>2024-03-22T16:22:55.466Z</atom:updated>
            <content:encoded><![CDATA[<p>Yes, the NVIDIA launched chat with RTX.Chat with RTX is a demo app that lets you personalize a GPT large language model (LLM) connected to your own content — docs, notes, or other data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fpov1i87H70I4Fq-JpOEOQ.png" /></figure><p>Let me highlight some of the <em>main features</em> of chat with RTX:-</p><p><strong>1-Chatbot on your Computer</strong></p><p>Chat with RTX is a free chatbot you can use on your computer.It learns from stuff you have, like documents and videos ,to chat with you.It’s personal and private.</p><p><strong>2-Super Fast</strong></p><p>Because it works on personal computer it’s really quick.</p><p><strong>3-Learn from youtube videos.</strong></p><p>It can understand content from youtube videos .So,if you ask it something, it answers based on what it learnt.</p><p><strong>4-Universal file compatibility.</strong></p><p>It has a great capability to support .txt,.pdf,.doc,.docx and .xml files renders ‘Chat with RTX’ not only powerful but also versatile ,meeting a broad spectrum of your document handling requirements.</p><p><strong>5-Gets more smarter as you chat.</strong></p><p>You can update it to help it to get to know you better over time.The more you talk to it, the more it understands you.</p><p><strong>6-Keep your stuff safe.</strong></p><p>It’s like having a secret chat buddy who knows a lot but doesn’t tell anyone. Since, everything is on your computer , all your information stays just with you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77fa29dfb62f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>