<?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 Shivam Dutt Sharma on Medium]]></title>
        <description><![CDATA[Stories by Shivam Dutt Sharma on Medium]]></description>
        <link>https://medium.com/@shivamdutt606?source=rss-c8c683a1356c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_rX_aDqiG1m3zbfua4Rj_w.jpeg</url>
            <title>Stories by Shivam Dutt Sharma on Medium</title>
            <link>https://medium.com/@shivamdutt606?source=rss-c8c683a1356c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:45:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shivamdutt606/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[The Festivals Are Over. But What About the Problems They Left Behind?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shivamdutt606.medium.com/the-festivals-are-over-but-what-about-the-problems-they-left-behind-0a08288b89fb?source=rss-c8c683a1356c------2"><img src="https://cdn-images-1.medium.com/max/1672/1*2DBLD9tO1Bw2OoxdwLFWPQ.png" width="1672"></a></p><p class="medium-feed-snippet">There&#x2019;s something rather beautiful about the festive season in India.</p><p class="medium-feed-link"><a href="https://shivamdutt606.medium.com/the-festivals-are-over-but-what-about-the-problems-they-left-behind-0a08288b89fb?source=rss-c8c683a1356c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shivamdutt606.medium.com/the-festivals-are-over-but-what-about-the-problems-they-left-behind-0a08288b89fb?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a08288b89fb</guid>
            <category><![CDATA[claritagent]]></category>
            <category><![CDATA[clarity]]></category>
            <category><![CDATA[legal-ai]]></category>
            <category><![CDATA[diwali]]></category>
            <category><![CDATA[dispute]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 06:50:47 GMT</pubDate>
            <atom:updated>2026-11-13T06:50:47.628Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Introducing Claritagent: Making Legal Information Easier to Understand]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shivamdutt606.medium.com/introducing-claritagent-making-legal-information-easier-to-understand-14b07cdb31c5?source=rss-c8c683a1356c------2"><img src="https://cdn-images-1.medium.com/max/1672/1*AR5jzsgbP-ihpPsWJf39hQ.png" width="1672"></a></p><p class="medium-feed-snippet">An AI-powered platform built to help people understand legal questions, examine documents, and navigate court-related information with&#x2026;</p><p class="medium-feed-link"><a href="https://shivamdutt606.medium.com/introducing-claritagent-making-legal-information-easier-to-understand-14b07cdb31c5?source=rss-c8c683a1356c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shivamdutt606.medium.com/introducing-claritagent-making-legal-information-easier-to-understand-14b07cdb31c5?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/14b07cdb31c5</guid>
            <category><![CDATA[law]]></category>
            <category><![CDATA[claritagent]]></category>
            <category><![CDATA[notice]]></category>
            <category><![CDATA[legal-ai]]></category>
            <category><![CDATA[document-analysis]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Mon, 19 Oct 2026 11:02:43 GMT</pubDate>
            <atom:updated>2026-10-19T11:02:43.921Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[An Excel Visualization Agent]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shivamdutt606.medium.com/an-excel-visualization-agent-32a3b14a98b4?source=rss-c8c683a1356c------2"><img src="https://cdn-images-1.medium.com/max/1857/1*UO2MrVapH0Q7o3pIGpc-SA.png" width="1857"></a></p><p class="medium-feed-snippet">Yes!</p><p class="medium-feed-link"><a href="https://shivamdutt606.medium.com/an-excel-visualization-agent-32a3b14a98b4?source=rss-c8c683a1356c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shivamdutt606.medium.com/an-excel-visualization-agent-32a3b14a98b4?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/32a3b14a98b4</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[excel]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[visualization]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Sun, 10 May 2026 09:51:50 GMT</pubDate>
            <atom:updated>2026-05-10T09:51:50.415Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Why My Agent Got the Right Answer for the Wrong Reasons]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shivamdutt606.medium.com/why-my-agent-got-the-right-answer-for-the-wrong-reasons-69ee7a755b45?source=rss-c8c683a1356c------2"><img src="https://cdn-images-1.medium.com/max/1536/1*73Ju8hSMw5__dkRHO-W3ow.png" width="1536"></a></p><p class="medium-feed-snippet">I recently tried a simple-looking experiment with smolagents from Hugging Face.</p><p class="medium-feed-link"><a href="https://shivamdutt606.medium.com/why-my-agent-got-the-right-answer-for-the-wrong-reasons-69ee7a755b45?source=rss-c8c683a1356c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shivamdutt606.medium.com/why-my-agent-got-the-right-answer-for-the-wrong-reasons-69ee7a755b45?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/69ee7a755b45</guid>
            <category><![CDATA[steps]]></category>
            <category><![CDATA[verification]]></category>
            <category><![CDATA[reasoning]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[agents]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 08:11:04 GMT</pubDate>
            <atom:updated>2026-04-17T08:11:04.718Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Taming the Ticket Jungle: A Guide to Grouping JIRAs]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shivamdutt606.medium.com/taming-the-ticket-jungle-a-guide-to-grouping-jiras-b68629510aea?source=rss-c8c683a1356c------2"><img src="https://cdn-images-1.medium.com/max/1919/1*mapp7hQ2cPmm6SKzrD8AeA.png" width="1919"></a></p><p class="medium-feed-snippet">Been cleaning my room since morning.&#xA0;
It&#x2019;s a Saturday, today. And, I just wondered to myself, can I accept this fate?</p><p class="medium-feed-link"><a href="https://shivamdutt606.medium.com/taming-the-ticket-jungle-a-guide-to-grouping-jiras-b68629510aea?source=rss-c8c683a1356c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shivamdutt606.medium.com/taming-the-ticket-jungle-a-guide-to-grouping-jiras-b68629510aea?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b68629510aea</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[kmeans-clustering]]></category>
            <category><![CDATA[jira]]></category>
            <category><![CDATA[jira-software]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Sun, 18 May 2025 17:51:35 GMT</pubDate>
            <atom:updated>2025-05-18T17:51:35.995Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[My two cents on API Wrappers, in ‘25]]></title>
            <link>https://shivamdutt606.medium.com/my-two-cents-on-api-wrappers-in-25-13f957c3c518?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/13f957c3c518</guid>
            <category><![CDATA[requests-library]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[gpt-4]]></category>
            <category><![CDATA[api-wrapper]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 18:31:37 GMT</pubDate>
            <atom:updated>2025-04-18T18:31:37.300Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O-5TqL2j_XupExFi7cwWvg.png" /><figcaption><strong>API Wrappers in 2025</strong></figcaption></figure><p>I think it was the beginning of 2025, when I was casually experimenting with OpenAI’s GPT-4 model’s API (basically joining the bandwagon of utilizing the open source LLMs to generate content / text / media etc.)</p><p><strong>The business behind Perplexity :p</strong></p><p><strong>So, what did I do?<br></strong>I went to OpenAI’s website. Sourced an API key for myself.<br>Opened my Colab NB. Wrote a simple script.<br>What I want you to see is the function — <strong>generate_tech_words(n=5):</strong></p><p>The following code is apparently a <strong>lightweight API wrapper</strong>, or more precisely, it’s <strong>a custom abstraction over the OpenAI API</strong>.</p><p><strong>Why will the following code qualify as an API wrapper?</strong></p><ul><li>The function <strong>generate_tech_words()<br></strong>hides the details of how the OpenAI API is called (openai.ChatCompletion.create)</li></ul><p>Just making it easier for the rookies to grasp :-<br> — openai is the library<br> — ChatCompletion is the class<br> — create is a method</p><ul><li>Accepts a simple parameter (n=5)</li><li>Returns clean, processed output — a list of words</li></ul><p><strong><em>So, if you use the function generate_tech_words(); you do not have to worry about the following things :-</em></strong></p><ul><li>Crafting the prompt</li><li>Setting up the message structure</li><li>Handling the raw JSON response</li></ul><pre>!pip install openai==0.28<br>import openai<br>openai.api_key = &quot;PUT-YOUR-OWN-API-KEY-I-AM-NOT-GIVING-YOU&quot;<br>def generate_tech_words(n=5):<br>    &quot;&quot;&quot;Use LLM to generate a list of technology-related words.&quot;&quot;&quot;<br>    prompt = f&quot;Generate {n} commonly known technology-related words. Provide only the words, separated by commas.&quot;<br>    response = openai.ChatCompletion.create(<br>        model=&quot;gpt-4&quot;,<br>        messages=[{&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;You are a helpful AI that provides lists of words.&quot;},<br>                  {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: prompt}]<br>    )<br>    words = response[&#39;choices&#39;][0][&#39;message&#39;][&#39;content&#39;].split(&#39;,&#39;)<br>    return [word.strip() for word in words]<br># Example usage<br>tech_words = generate_tech_words(5)<br>print(&quot;Generated Tech Words:&quot;, tech_words)</pre><h4><strong>Output from the above code :-</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Utl8XX5OgBY1_W3D1WleQ.png" /></figure><ul><li><strong>openai.ChatCompletion.create(…)</strong> is a method from the official <strong>OpenAI Python SDK</strong>, which itself is a<strong> full API wrapper</strong> around the <strong>HTTP API</strong> (you don’t have to write requests.post(…), set headers, etc.)</li><li>The <strong>generate_tech_words()</strong> is a custom wrapper function on top of that SDK, making it even more specialized for your use-case.</li></ul><h4><strong>I, then, wondered how it would be like working with the same OpenAI API, but in a Non API Wrapper — way.</strong></h4><p>So basically what I am trying to get to, is a study / comparison where I try to juxtapose both API Wrapper and Non API Wrapper methods of establishing API connections and seeing if there are remarkable differences in the response times, or the overall code execution times.<br>See — I understand the difference becomes apparent when the API requests are too many in number, or the code that has been abstracted had some intrinsic long / complex / recursive code components or functionalities.</p><p>But — I am a frigging stubborn explorer, and <strong><em>I want to quench my thirst.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*MT_tXY_diwhF4ZVVodplww.gif" /></figure><p>If you <strong>don’t use the OpenAI Python SDK</strong> (<strong>openai </strong>package), you have to make a <strong>raw HTTP request</strong> using something like the <strong>requests</strong> library.</p><pre>import requests<br>import time<br>API_KEY = &quot;GET-YOUR-OWN-API-KEY-MATE&quot;  # Replace with your key, Mate! I ain&#39;t giving mine. I can, though, if you book my trip to Switzerland<br>API_URL = &quot;https://api.openai.com/v1/chat/completions&quot;<br>def generate_tech_words_raw(n=5):<br>    headers = {<br>        &quot;Authorization&quot;: f&quot;Bearer {API_KEY}&quot;,<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>    }<br>    data = {<br>        &quot;model&quot;: &quot;gpt-4&quot;,<br>        &quot;messages&quot;: [<br>            {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;You are a helpful AI that provides lists of words.&quot;},<br>            {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: f&quot;Generate {n} commonly known technology-related words. Provide only the words, separated by commas.&quot;}<br>        ]<br>    }<br>    response = requests.post(API_URL, headers=headers, json=data)<br>    if response.status_code == 200:<br>        result = response.json()<br>        content = result[&#39;choices&#39;][0][&#39;message&#39;][&#39;content&#39;]<br>        return [word.strip() for word in content.split(&#39;,&#39;)]<br>    else:<br>        raise Exception(f&quot;Request failed: {response.status_code}, {response.text}&quot;)</pre><p>So, when I called the function — <strong>generate_tech_words_raw(), </strong>I got the <strong>similar </strong>results (which is a list of 5 technology-related words). You are seeing that, below. :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uVpyP_aGlGru_Wjxh4C7UQ.png" /></figure><p>Now, what actually got me momentarily speechless (or may be flummoxed for the lack of a better word; speechless is an overstatement may be :p ), is actually when I tried to compare the performance of both the API Wrapper and Non — API Wrapper methods, when trying to generate 5 tech words using OpenAI’s GPT-4 model’s RESTful API.</p><p>You can see what am I trying to do below. <br><strong><em>I have imported the time library and trying to compare the performance of the Wrapper and Raw versions.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJcTV61QkrqPrMuxMbobpA.png" /></figure><p>Now, to my surprise, and I reckon you’d be surprised to see too, that the Wrapper version’s time taken was ~0.79 seconds and the Non-API Wrapper version’s time taken was ~0.72 seconds.</p><h4><strong>Question of the hour is, though :</strong></h4><p>Why the raw HTTP version appears faster (0.72 secs), even though you’d expect the official SDK (openai package) — 0.79 secs, to be more optimized?</p><p>I have a few reasons in my head. But, I’d love to know your inputs too.<br>Comment on the blog, what / why you feel that may explain the abberation.</p><h3><strong>See you around :)</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13f957c3c518" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Some LLM Humor]]></title>
            <link>https://medium.com/i-am-prajna/some-llm-humor-7d4ade0cd223?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d4ade0cd223</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[prajna]]></category>
            <category><![CDATA[testament]]></category>
            <category><![CDATA[hallucinations]]></category>
            <category><![CDATA[humor]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 06:07:35 GMT</pubDate>
            <atom:updated>2025-03-21T06:07:35.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i5SJZBV0xsPtzk0KLffSaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5oFqMSioezfmkEkejW1SKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IznhLc2RU08deqDtw9cc1w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcDzdxaJBcpuawBDX7kT0g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d4ade0cd223" width="1" height="1" alt=""><hr><p><a href="https://medium.com/i-am-prajna/some-llm-humor-7d4ade0cd223">Some LLM Humor</a> was originally published in <a href="https://medium.com/i-am-prajna">I am Prajna</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Importance of Capstone Projects]]></title>
            <link>https://medium.com/i-am-prajna/the-importance-of-capstone-projects-3690f4702e04?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3690f4702e04</guid>
            <category><![CDATA[user-interface]]></category>
            <category><![CDATA[prajna]]></category>
            <category><![CDATA[capstone-project]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 05:36:25 GMT</pubDate>
            <atom:updated>2025-03-21T05:36:25.118Z</atom:updated>
            <content:encoded><![CDATA[<p>It is the 5th year running, since having completed a capstone project during my PG back in ’20, and have always wondered why did it have the maximum credits assigned.<br>Only, as of yesterday does it all make sense now.<br>Why are companies / educational institutions so much focused around it when setting the curriculum. <br>Yesterday, when I gave Prajna its face, I realised how important is it to give a face to any project since an innovation may entice you on your command line, but the world is accustomed to web.</p><p>The term “capstone” in the context of capstone projects originates from the concept of a “capstone” as the crowning achievement or final touch on a structure. It draws an analogy to the architectural feature of a capstone, which is the topmost stone in a structure or wall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgX_j4PvBcBvrCYfN-H3QQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2qADJpDukhYCPbWleVCtiA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3690f4702e04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/i-am-prajna/the-importance-of-capstone-projects-3690f4702e04">The Importance of Capstone Projects</a> was originally published in <a href="https://medium.com/i-am-prajna">I am Prajna</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Give me an explanation (Alibi)]]></title>
            <link>https://shivamdutt606.medium.com/give-me-an-explanation-alibi-fc4db5a627c8?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc4db5a627c8</guid>
            <category><![CDATA[explanation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[alibi]]></category>
            <category><![CDATA[random-forest-classifiers]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Tue, 04 Mar 2025 18:24:24 GMT</pubDate>
            <atom:updated>2025-03-04T18:24:24.654Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_bJla0wrISxpnlpD9sUQA.png" /></figure><p>Nothing to fret.<br>No ‘body’ owes me an explanation.</p><p>My Colab notebook does, though.</p><p>I was just working on a Random Forest Classifier today.<br>You know about it, I bet.<br>Ummm — no….<br>The pockets aren’t much heavy these days. So, no betting. If you aren’t aware — this small piece might help you with a revisit. So this one’s a breather on Decision Tree Classifiers — <a href="https://shivamdutt606.medium.com/decision-tree-classifiers-lets-talk-about-them-3df1ddeb1255">https://shivamdutt606.medium.com/decision-tree-classifiers-lets-talk-about-them-3df1ddeb1255</a></p><p>While RFC’s are an ensemble of multiple Decision Tree Classifiers, so for a very microscopic perusal of RFC per se, please go for this one — <a href="https://towardsdatascience.com/random-forest-explained-a-visual-guide-with-code-examples-9f736a6e1b3c/">https://towardsdatascience.com/random-forest-explained-a-visual-guide-with-code-examples-9f736a6e1b3c/</a></p><p>My Data Science safari started in 2020, and ever since I have been working on it, I often feel if there was ever a tool that could give a fair explanation of what is going on with the model, YKWIM.</p><p>For a very long time, I did not know about Alibi and its capabilities.</p><p>The <strong>Alibi</strong> library is used for <strong>Machine Learning (ML) model explain-ability and interpretability</strong>. It helps understand why a model makes certain predictions, which is crucial for trust, debugging, and fairness in AI systems.</p><p>Below is the code where I am trying to create a basic RandomForestClassifier model.<br>I have used the <strong>iris</strong> dataset.</p><p>KernelShap (that you’d see below in the code) is a model-agnostic explainer from the <strong>Alibi Explainability library</strong> that estimates SHAP (SHapley Additive exPlanations) values using <strong>Kernel SHAP</strong>, a variant of the SHAP framework.</p><p>What model-agnostic essentially means here is that it is designed to work with <strong>black-box models</strong> by approximating feature attributions using a kernel-based approach. And by black-box, I’d mean that these are those ML models, where understanding what is happening behind the scenes — like the internal logic, computation processes, decision making process, etc. is too complex and is not easily interpretable by humans.</p><pre>import pandas as pd<br>from alibi.explainers import KernelShap<br>import numpy as np<br>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.datasets import load_iris<br>from sklearn.model_selection import train_test_split<br># Load dataset<br>iris = load_iris()<br>X, y = iris.data, iris.target<br># Split dataset into training and test sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br># Train a Random Forest classifier<br>model = RandomForestClassifier(n_estimators=100, random_state=42)<br>model.fit(X_train, y_train)</pre><p>I then thought of using an explainer from the family of Alibi’s explainers, as you’d see in the code below —<strong> AnchorTabular.</strong></p><p><strong>AnchorTabular</strong> is an explain-ability method from the <strong>ALIBI</strong> library, designed to provide <strong>high-precision, human-interpretable explanations</strong> for tabular data models. It is based on <strong>“Anchors: High-Precision Model-Agnostic Explanations”</strong> by Ribeiro et al. (2018).<strong> </strong><br>I remember that during my early days of Machine Learning — when I was pursuing PGP in AI/ML at NIT Warangal, all those heavy, cryptic, overwhelming, extra-terrestrial lines of output, once you execute a block of ML Python code, used to get me all bonkers.</p><p>Had I known about Alibi already, life might have been simpler, back then.</p><p>For instance, today when working on a Random Forest Classifier, when I trained the model as seen in the code above — model = RandomForestClassifier(n_estimators = 100, random_state = 42)</p><p>I, like always, wondered what is happening behind that model I trained and then further when I fit it with X_train (the independent features) and y_train (the dependent feature); how is the computation happening abstractly, explained?</p><p>I just told you the problem.<br>And now, the solution — — — —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*xfBdMGqJWCR-QChvbnJRlA.gif" /></figure><p><strong><em>6 lines of code</em></strong> and it tells you everything about what’s happening inside your ML model or rather I’d say precisely, about the predictions coming out of your model.</p><pre>from alibi.explainers import AnchorTabular<br># Initialize the explainer<br>explainer = AnchorTabular(predictor=model.predict, feature_names=iris.feature_names)<br>explainer.fit(X_train)<br># Select an instance to explain<br>instance = X_test[0].reshape(1, -1)<br># Generate the explanation<br>explanation = explainer.explain(instance)<br>print(explanation)</pre><p>First and foremost — import the god-sent library.<br><strong><em>from alibi.explainers import AnchorTabular</em></strong></p><p>To recall once again — AnchorTabular is a <strong>local model explanation method</strong> that generates &quot;anchors&quot;—rules. These rules provide information on why a particular model made a specific prediction for a given <strong>instance</strong> (a single row of data).</p><p>And while I mention that, it rings a bell. A question from my PCAP exam about the ideal ways of importing a class/method from a package.<br>Anyway, moving ahead now.</p><p>We create an explainer object next, or, what you may say — initializing the explainer.= :- <br><strong><em>explainer = AnchorTabular(predictor=model.predict, feature_names=iris.feature_names)</em></strong></p><p>— — <br>Then we fit the training dataset in the explainer :-<br><strong><em>explainer.fit(X_train)</em></strong></p><p>— — <br>Then we select an instance to explain :-<br><strong><em>instance = X_test[0].reshape(1, -1)</em></strong></p><p>Here — we have selected the 0th record in the test dataset and reshaped it (1, -1).<br> — —</p><p>Next, we generate the explanation and print it :-<br><strong><em>explanation = explainer.explain(instance)<br>print(explanation)</em></strong></p><p>— —</p><p><strong>How does the raw explanation (results) look like? </strong>Like, when you do <strong>print(explanation) :-</strong></p><pre>Explanation(meta={<br>  &#39;name&#39;: &#39;AnchorTabular&#39;,<br>  &#39;type&#39;: [&#39;blackbox&#39;],<br>  &#39;explanations&#39;: [&#39;local&#39;],<br>  &#39;params&#39;: {<br>              &#39;seed&#39;: None,<br>              &#39;disc_perc&#39;: (25, 50, 75),<br>              &#39;threshold&#39;: 0.95,<br>              &#39;delta&#39;: 0.1,<br>              &#39;tau&#39;: 0.15,<br>              &#39;batch_size&#39;: 100,<br>              &#39;coverage_samples&#39;: 10000,<br>              &#39;beam_size&#39;: 1,<br>              &#39;stop_on_first&#39;: False,<br>              &#39;max_anchor_size&#39;: None,<br>              &#39;min_samples_start&#39;: 100,<br>              &#39;n_covered_ex&#39;: 10,<br>              &#39;binary_cache_size&#39;: 10000,<br>              &#39;cache_margin&#39;: 1000,<br>              &#39;verbose&#39;: False,<br>              &#39;verbose_every&#39;: 1,<br>              &#39;kwargs&#39;: {}}<br>            ,<br>  &#39;version&#39;: &#39;0.9.6&#39;}<br>, data={<br>  &#39;anchor&#39;: [&#39;sepal width (cm) &lt;= 3.40&#39;, &#39;0.30 &lt; petal width (cm) &lt;= 1.30&#39;, &#39;sepal length (cm) &gt; 5.75&#39;],<br>  &#39;precision&#39;: 1.0,<br>  &#39;coverage&#39;: 0.0678,<br>  &#39;raw&#39;: {<br>           &#39;feature&#39;: [1, 3, 0],<br>           &#39;mean&#39;: [0.37223823246878, 0.5032467532467533, 0.818018018018018, 1.0],<br>           &#39;precision&#39;: [0.37223823246878, 0.5032467532467533, 0.818018018018018, 1.0],<br>           &#39;coverage&#39;: [0.8282, 0.6605, 0.2025, 0.0678],<br>           &#39;examples&#39;: [{&#39;covered_true&#39;: array([[6.4, 2.4, 4.5, 1.5],<br>       [5.6, 2.8, 4.1, 1.3],<br>       [6.3, 2.7, 4.4, 1.3],<br>       [6.4, 2.3, 4.3, 1.3],<br>       [5.8, 2.3, 4.1, 1. ],<br>       [6.9, 2.7, 4.9, 1.5],<br>       [5.5, 2.4, 4.4, 1.2],<br>       [5.5, 2.8, 4. , 1.3],<br>       [5.7, 2.7, 4.2, 1.2],<br>       [7. , 2.2, 4.7, 1.4]]), &#39;covered_false&#39;: array([[7.4, 2.5, 6.1, 1.9],<br>       [4.9, 2.7, 1.5, 0.2],<br>       [5.8, 2.8, 1.2, 0.2],<br>       [5. , 2.7, 1.3, 0.3],<br>       [6.1, 2. , 5.6, 1.4],<br>       [7.2, 2.7, 6. , 1.8],<br>       [4.6, 2.7, 1.4, 0.2],<br>       [6.3, 2.5, 6. , 2.5],<br>       [5.7, 2.2, 1.5, 0.4],<br>       [7.2, 2.5, 5.8, 1.6]]), &#39;uncovered_true&#39;: array([], dtype=float64), &#39;uncovered_false&#39;: array([], dtype=float64)}, {&#39;covered_true&#39;: array([[5.6, 3.4, 4.5, 1.6],<br>       [5.8, 2.8, 4.1, 1.5],<br>       [6.7, 3. , 4.7, 1.5],<br>       [5.6, 2.7, 4.2, 1. ],<br>       [6.5, 3. , 4.6, 1.2],<br>       [5.8, 2.9, 1.2, 1.3],<br>       [5.6, 3. , 4.2, 1.5],<br>       [6.7, 2.4, 4.4, 1.1],<br>       [7. , 3.2, 4.7, 1.8],<br>       [5.5, 2.6, 4. , 1.4]]), &#39;covered_false&#39;: array([[4.4, 3.1, 1.3, 1.4],<br>       [5.7, 2.5, 4.1, 1.9],<br>       [5. , 3.2, 1.2, 1.5],<br>       [5.8, 2.7, 4. , 1.9],<br>       [5. , 3.1, 1.6, 1.5],<br>       [6.8, 2.4, 5.5, 1. ],<br>       [5.1, 3.1, 1.7, 1.8],<br>       [4.5, 3. , 1.3, 1.4],<br>       [6.2, 2.9, 5.4, 1.3],<br>       [6.3, 3. , 5.6, 2.1]]), &#39;uncovered_true&#39;: array([], dtype=float64), &#39;uncovered_false&#39;: array([], dtype=float64)}, {&#39;covered_true&#39;: array([[5.4, 2.4, 4.5, 1. ],<br>       [5.8, 2.7, 4.1, 1. ],<br>       [6.2, 3.3, 4.3, 0.5],<br>       [7. , 2.7, 4.7, 1.3],<br>       [6.1, 2.9, 4. , 1.3],<br>       [6.2, 2.5, 4.3, 1.3],<br>       [5.4, 3. , 4.5, 1.3],<br>       [5.7, 2.4, 3.5, 1. ],<br>       [5.7, 2.8, 1.5, 1.3],<br>       [6.2, 2.6, 4.8, 1.2]]), &#39;covered_false&#39;: array([[5.1, 2.9, 1.9, 1.3],<br>       [4.4, 2. , 1.4, 1. ],<br>       [6.9, 3. , 5.7, 1.2],<br>       [4.6, 2.2, 1.4, 1. ],<br>       [7.7, 2.3, 6.7, 1.3],<br>       [7.3, 2.3, 6.3, 1. ],<br>       [5.2, 2.4, 1.5, 1.1],<br>       [5.9, 2.5, 5.1, 1.1],<br>       [5.8, 2.6, 5.1, 1. ],<br>       [5.8, 2.9, 5.1, 1.3]]), &#39;uncovered_true&#39;: array([], dtype=float64), &#39;uncovered_false&#39;: array([], dtype=float64)}, {&#39;covered_true&#39;: array([[6.2, 2.9, 1.1, 1.3],<br>       [6. , 2.2, 4.9, 1. ],<br>       [6.6, 2.9, 4.4, 1.3],<br>       [6.3, 2.3, 4.5, 1.3],<br>       [6.4, 2.9, 3.3, 1.3],<br>       [6.7, 3.1, 4.9, 1.3],<br>       [6. , 3.4, 1.4, 1.1],<br>       [6.7, 3.1, 4.8, 1.1],<br>       [6.3, 2.8, 4.2, 1.3],<br>       [7.6, 3. , 5. , 1.3]]), &#39;covered_false&#39;: array([[5.8, 2.7, 5.7, 1. ],<br>       [6.1, 2.8, 5.6, 1.3],<br>       [5.8, 2.6, 6.1, 1.2],<br>       [6.3, 2.5, 1.5, 0.4],<br>       [6.4, 3.2, 5.3, 1.3],<br>       [5.8, 2.7, 1.5, 0.5],<br>       [6.4, 3.1, 5.1, 1.3],<br>       [6.6, 3. , 5.7, 1.3],<br>       [5.8, 2.7, 6. , 0.4],<br>       [5.8, 2.7, 1.6, 0.4]]), &#39;uncovered_true&#39;: array([], dtype=float64), &#39;uncovered_false&#39;: array([], dtype=float64)}],<br>           &#39;all_precision&#39;: 0,<br>           &#39;num_preds&#39;: 1000000,<br>           &#39;success&#39;: True,<br>           &#39;names&#39;: [&#39;sepal width (cm) &lt;= 3.40&#39;, &#39;0.30 &lt; petal width (cm) &lt;= 1.30&#39;, &#39;sepal length (cm) &gt; 5.75&#39;],<br>           &#39;prediction&#39;: array([1]),<br>           &#39;instance&#39;: array([[6.1, 2.8, 4.7, 1.2]]),<br>           &#39;instances&#39;: array([[6.1, 2.8, 4.7, 1.2]])}<br>         }<br>)</pre><p><strong>What is happening in the results, here?</strong></p><p>First, we have the explanation meta data :-</p><blockquote>Explanation(meta={<br> ‘name’: ‘AnchorTabular’,<br> ‘type’: [‘blackbox’],<br> ‘explanations’: [‘local’],<br> ‘params’: {…}<br>})</blockquote><p>I am going to dive a little deeper into the ‘meta’ node (can be called an object too, since its a dict) under the ‘Explanation’ root node :-</p><ul><li>The ‘blackbox’ that you see against the key ‘type’, here, implies that the explainer sees / treats the model as a black-box (and doesn’t need to know the internals of the model).</li><li>The ‘local’ that you see against the key ‘explanations’ implies that explanation applies to a specific instance, and not the entire model.</li><li>Now coming to the big chunk — ‘params’ object :-</li></ul><blockquote><strong>seed : </strong>Random seed for reproducibility (None means no fixed seed).<br><strong>disc_perc : </strong>Percentiles used for discretizing numerical features (default: 25th, 50th, 75th percentile).<br><strong>threshold : </strong>Minimum precision (confidence) required for an anchor to be accepted (default: 0.95).<br><strong>delta : </strong>Precision threshold tolerance used for sampling. Controls the stopping condition for anchor search.<br><strong>tau : </strong>Trade-off parameter between coverage and precision.<br><strong>batch_size : </strong>Number of samples per iteration used when computing anchor coverage and precision.<br><strong>coverage_samples : </strong>Number of samples used to estimate coverage of an anchor rule.<br><strong>beam_size : </strong>Number of candidate anchors considered at each step. Larger values explore more rules but slow down the process.<br><strong>stop_on_first : </strong>If True, stops searching as soon as a valid anchor is found (default: False, meaning it explores more candidates).<br><strong>Max_anchor_size : </strong>Maximum number of features allowed in an anchor. None, shall mean no limit.<br><strong>min_samples_start : </strong>Minimum number of initial samples generated to begin the search for an anchor.<br><strong>n_covered_ex : </strong>Minimum number of examples that must be covered by an anchor to be considered valid.<br><strong>binary_cache_size : </strong>Size of the cache for binary decisions when testing anchors. Larger cache improves efficiency.<br><strong>cache_margin : </strong>Extra cache space to avoid frequent reallocation.<br><strong>verbose : </strong>If True, prints detailed progress messages.<br><strong>verbose_every : </strong>Frequency of printing updates (e.g., every n iterations).<br><strong>kwargs : </strong>Additional arguments that can be passed to the explainer.</blockquote><p>Next in the <strong>‘Explanation’</strong> node is the ‘<strong>version</strong>’ key against which, we have the value ‘<strong>0.9.6</strong>’.<br>The ‘<strong>version</strong>’ key basically talks about the version of <strong>Alibi</strong> being used, ensuring compatibility and reproducibility.</p><p>Next, I am gonna talk about the data object’s ‘<strong>anchor</strong>’ key.</p><p><strong>For instance, let us look at this sample anchor key value :-</strong><br>‘<strong>anchor</strong>’: [‘sepal width (cm) &lt;= 3.40’, ‘0.30 &lt; petal width (cm) &lt;= 1.30’, ‘sepal length (cm) &gt; 5.75’]</p><p><strong><em>What does this tell?</em></strong><br>So, this is actually the most important and noticeably intuitive part of the overall explanation. <br>So, for the <strong>instance</strong> that you had passed into the explainer (for example in our case, it is the first row of the tabular data), we got the anchor rule that suggests that as long as the :-</p><ul><li>sepal width is less than equal to 3.40</li><li>petal width is greater than 0.30 and less than equal to 1.30</li><li>sepal length is greater than 5.75</li></ul><p><strong><em>then the model is likely to predict the same class for the instance.</em></strong></p><p>And while again re-explaining instance for a bit — An important thing to note here is that when I say the<strong> ‘same class for the instance’; </strong>it just means the class predicted by the model.<br>The <strong>instance</strong> refers to a <strong>single row of data</strong> from the tabular dataset we are referring to — the specific input example for which you want to generate an explanation.</p><p>For example, if your dataset contains customer information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pI-715-CeyeKQwcvpkmFJQ.png" /></figure><p>If you want to explain why the model predicted <strong>“Yes”</strong> for Customer ID 101, then this specific row (<strong>Age = 25, Gender = Male, Purchase Amount = $50, etc.</strong>) is the <strong>instance</strong> being explained.</p><p>Even if <strong>other features</strong> (not included in the anchor conditions) change slightly, as long as the <strong>anchor conditions</strong> (Sepal width, Petal width, and Sepal length in this case) hold true, the model will still predict the <strong>same class</strong>.</p><p>So, if the dataset has features like <strong>petal length (</strong>just mentioning this to exemplify any<strong> other </strong>feature<strong>, </strong>and it may or may not exist in real dataset<strong>)</strong>, even if petal length changes, the model will still predict the same class, provided the anchor conditions are met.</p><p><strong>Next (and possibly the last of the stars :p ), </strong><br><strong>Precision = 1.0</strong> would mean that every instance satisfying the anchor conditions gets the same prediction.</p><p>And, <strong>Coverage = 0.0678</strong> means that about <strong>6.78%</strong> of the dataset falls within this rule.</p><p><strong><em>The covered_true and covered_false arrays show:-</em></strong></p><ul><li><strong>covered_true : Instances where the anchor rule held</strong> and the model predicted correctly.</li><li><strong>covered_false : Instances where the anchor rule held</strong> but the model predicted differently.</li><li><strong>Uncovered instances</strong> where the rule was not applicable.</li></ul><p>I parsed this far. More in WIP.<br>If you have to share more sense that you are able to make out from the raw explanation, please shoot a comment.<br>And if you liked this write-up, please drop a like and leave a comment.</p><p>Cheers :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc4db5a627c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Wizardry — From Hiatus to Mastery | The Snowflake Way]]></title>
            <link>https://medium.com/analytics-vidhya/sql-wizardry-from-hiatus-to-mastery-the-snowflake-way-aeb08f8a3fb3?source=rss-c8c683a1356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeb08f8a3fb3</guid>
            <category><![CDATA[cte]]></category>
            <category><![CDATA[advanced-sql]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[joins-in-sql]]></category>
            <dc:creator><![CDATA[Shivam Dutt Sharma]]></dc:creator>
            <pubDate>Thu, 30 Jan 2025 02:18:09 GMT</pubDate>
            <atom:updated>2025-04-10T20:34:21.847Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL Wizardry — From Hiatus to Mastery | The Snowflake Way</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMVTiSiKarwnzmxWFzWP2A.png" /><figcaption><strong>SQL WIZARDRY</strong></figcaption></figure><p>I bet this has happened with most of us.<br>We learnt something back in school, college, or even later in some or the other educational setting, and then completely lost touch with it (there can be several factors why that happens though — that knowledge wasn’t applied or revisited frequently and hence it faded away, or, if the information was memorized without a deep understanding of its concepts or relevance, it is less likely to be retained, and more such reasons).</p><p>One such skill for me has been SQL.<br>I picked it up really quick back in college (so much so, that my RDBMS Professor was quite impressed and suggested taking it up full-time post my graduation. Data Analyst jobs were a trending sensation back then).</p><p>Well, I must say my Professor was quite a prophecy-er 👀 😜<br>While I didn’t take up SQL immediately after my graduation, however, it was very recent where I did a project for an Ex-employer of mine (seeking trends and to query some meaningful insights out of the raw/crude order (transactional) data), and we used SQL for the same. The platform we worked on, was <strong>Snowflake.</strong></p><p>The way you will approach SQL can change significantly depending upon the database you are using or the platform, you are running your SQL on.</p><p>In our case, as I said, we used Snowflake.<br>For those of you who may not know (just in case) — Snowflake is a <strong>cloud-based data platform</strong> designed for data warehousing, analytics, and sharing. It is built on a cloud infrastructure (e.g., AWS, Azure, or GCP) and allows businesses to store, manage, and analyze large amounts of data efficiently.</p><p>Right at this moment, a really important question to ask is :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*akK74aXAaFGD1j3z4gYiKA.gif" /></figure><h4><strong>What SQL does Snowflake use?</strong></h4><p>Snowflake actually uses a version of <strong>ANSI SQL</strong> (American National Standards Institute SQL). It supports most standard SQL commands and provides additional extensions tailored for cloud-based analytics and data warehousing.</p><p>Some unique features include:-</p><ul><li>Support for semi-structured data types like <strong>JSON</strong>, <strong>Parquet</strong>, and <strong>Avro</strong>.</li><li>SQL functions for handling <strong>variant</strong> and <strong>array</strong> data types.</li><li>Time Travel for querying historical data — This one’s quite a gig, boy. I will write in length around this later. Hang in there, if you will. I shall also tell why I find this as a really important feature of Snowflake. 🙏</li></ul><p>Alright, now — let’s get to business.</p><p>Today, I wanted to share some of my favorite functions / topics / concepts in ANSI SQL (Snowflake), that I was hands-on with, in the project that I mentioned above.<br>However, before I get to that, I really want to mention that there was a long hiatus before I actually resumed SQL, when asked to lead this project, and sort of felt really content seeing how good things can be turned around, when done with focus and perseverance.</p><p>And, also before I explain each of those concepts and the right syntactical / logical approach towards using each, it is important that we create some dummy data first so as to be able to demonstrate how each of those concepts / functions are applied to any data.</p><h4><strong>Creating some dummy data [table = </strong>DUMMY_ORDERITEM_DATA]</h4><p>Step 01 : Create a dummy table using CREATE TABLE statement to define the table’s schema. (I may want to create a very transactional data (like they have in e-commerce companies and keep the orders’ data at an order-item level so as to have some decent granularity, to be able to use some of the window functions in their quintessential capacity and strength, as and when I come to demonstrating them)).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBR2NclKW4HQdBqRuaQPgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W78XnPuJLYgDnuRVdJJwMQ.png" /></figure><p>Here — I have just created a table (a schema for now though) called DUMMY_ORDERITEM_DATA. <br>We are yet to insert dummy data, if you will. Let’s get to that.</p><h4>Inserting some dummy data [table = DUMMY_ORDERITEM_DATA]</h4><pre>-- Creating a sequence table with numbers from 1 to 10 (assuming max 10 items per order)<br>WITH seq AS (<br>    SELECT ROW_NUMBER() OVER (ORDER BY SEQ4()) AS num FROM TABLE(GENERATOR(ROWCOUNT =&gt; 10))<br>),<br>orders AS (<br>    SELECT<br>        &#39;ORD_&#39; || (10000 + SEQ4()) AS order_id,<br>        UNIFORM(1, 6, RANDOM()) AS num_items,<br>        &#39;Customer_&#39; || SEQ4() AS customer_name,<br>        UNIFORM(18, 65, RANDOM()) AS customer_age,<br>        &#39;CUST_&#39; || (10000 + SEQ4()) AS customer_id,<br>        CURRENT_DATE - UNIFORM(0, 365, RANDOM()) AS order_date,<br>        CASE UNIFORM(0, 2, RANDOM()) <br>            WHEN 0 THEN &#39;Male&#39;<br>            WHEN 1 THEN &#39;Female&#39;<br>            ELSE &#39;Non-Binary&#39;<br>        END AS customer_gender<br>    FROM TABLE(GENERATOR(ROWCOUNT =&gt; 1000))<br>),<br>items AS (<br>    SELECT<br>        o.order_id,<br>        &#39;ORD_&#39; || o.order_id || &#39;_ITEM_&#39; || ROW_NUMBER() OVER (PARTITION BY o.order_id ORDER BY RANDOM()) AS item_id,<br>        UNIFORM(1, 10, RANDOM()) AS order_item_qty,<br>        o.customer_name,<br>        o.customer_age,<br>        o.customer_id,<br>        o.order_date,<br>        o.customer_gender,<br>        ARRAY_CONSTRUCT(&#39;Electronics&#39;, &#39;Clothing&#39;, &#39;Books&#39;, &#39;Home&#39;, &#39;Toys&#39;)[UNIFORM(0, 5, RANDOM())] AS order_product_type,<br>        ARRAY_CONSTRUCT(&#39;Red&#39;, &#39;Blue&#39;, &#39;Green&#39;, &#39;Black&#39;, &#39;White&#39;)[UNIFORM(0, 5, RANDOM())] AS order_product_colour,<br>        CASE UNIFORM(0, 3, RANDOM())<br>            WHEN 0 THEN &#39;Male&#39;<br>            WHEN 1 THEN &#39;Female&#39;<br>            WHEN 2 THEN &#39;Unisex&#39;<br>            ELSE &#39;Kids&#39;<br>        END AS order_product_gender,<br>        UNIFORM(100, 5000, RANDOM()) AS order_item_net_total_inr,<br>        ARRAY_CONSTRUCT(&#39;Online&#39;, &#39;In-Store&#39;, &#39;Mobile&#39;)[UNIFORM(0, 3, RANDOM())] AS order_sales_channel<br>    FROM orders o<br>    CROSS JOIN seq<br>    WHERE seq.num &lt;= o.num_items  -- Ensuring only `num_items` rows are created per order<br>)</pre><p>And — let’s look at how the data looks like. <br>Let’s do a<strong> select * from …. (the most famous jazz) :p</strong></p><p>Actually, in the above screenshot I ended up creating two CTEs for orders and items dummy data. However, I did not really insert the data inside the DUMMY_ORDERITEM_DATA table.</p><p>Let me just do that here, again!</p><pre>INSERT INTO dummy_orderitem_data<br>WITH seq AS (<br>    SELECT ROW_NUMBER() OVER (ORDER BY SEQ4()) AS num FROM TABLE(GENERATOR(ROWCOUNT =&gt; 10))<br>),<br>orders AS (<br>    SELECT<br>        &#39;ORD_&#39; || (10000 + SEQ4()) AS order_id,<br>        UNIFORM(1, 6, RANDOM()) AS num_items,  -- Random number of items per order<br>        &#39;Customer_&#39; || UNIFORM(1, 300, RANDOM()) AS customer_name, -- Allow repeat customers<br>        UNIFORM(18, 65, RANDOM()) AS customer_age,<br>        &#39;CUST_&#39; || (10000 + UNIFORM(1, 300, RANDOM())) AS customer_id, -- Repeat customer IDs<br>        CURRENT_DATE - UNIFORM(0, 365, RANDOM()) AS order_date,<br>        CASE UNIFORM(0, 2, RANDOM()) <br>            WHEN 0 THEN &#39;Male&#39;<br>            WHEN 1 THEN &#39;Female&#39;<br>            ELSE &#39;Non-Binary&#39;<br>        END AS customer_gender<br>    FROM TABLE(GENERATOR(ROWCOUNT =&gt; 2000)) -- Increased row count to allow duplicate customers<br>),<br>items AS (<br>    SELECT<br>        o.order_id,<br>        &#39;ORD_&#39; || o.order_id || &#39;_ITEM_&#39; || ROW_NUMBER() OVER (PARTITION BY o.order_id ORDER BY RANDOM()) AS item_id,<br>        UNIFORM(1, 10, RANDOM()) AS order_item_qty,<br>        o.customer_name,<br>        o.customer_age,<br>        o.customer_id,<br>        o.order_date,<br>        o.customer_gender,<br>        ARRAY_CONSTRUCT(&#39;Electronics&#39;, &#39;Clothing&#39;, &#39;Books&#39;, &#39;Home&#39;, &#39;Toys&#39;)[UNIFORM(0, 5, RANDOM())] AS order_product_type,<br>        ARRAY_CONSTRUCT(&#39;Red&#39;, &#39;Blue&#39;, &#39;Green&#39;, &#39;Black&#39;, &#39;White&#39;)[UNIFORM(0, 5, RANDOM())] AS order_product_colour,<br>        CASE UNIFORM(0, 3, RANDOM())<br>            WHEN 0 THEN &#39;Male&#39;<br>            WHEN 1 THEN &#39;Female&#39;<br>            WHEN 2 THEN &#39;Unisex&#39;<br>            ELSE &#39;Kids&#39;<br>        END AS order_product_gender,<br>        UNIFORM(100, 5000, RANDOM()) AS order_item_net_total_inr,<br>        ARRAY_CONSTRUCT(&#39;Online&#39;, &#39;In-Store&#39;, &#39;Mobile&#39;)[UNIFORM(0, 3, RANDOM())] AS order_sales_channel<br>    FROM orders o<br>    CROSS JOIN seq<br>    WHERE seq.num &lt;= o.num_items  -- Ensuring only `num_items` rows are created per order<br>)<br>SELECT * FROM items;</pre><p>One thing that I want to highlight above is that when I did ‘Customer_’ || UNIFORM(1, 300, RANDOM()) AS customer_name, I ensured that for a customer there are multiple orders.</p><p>This is because, earlier I had kept it as ‘Customer_’ || SEQ4() AS customer_name, which was leading to a very peculiar problem. The problem being that when I tried to perform some order sequencing on the data via a ROW_NUMBER() function, it gave me a messed up data in the end.<br> <br>For instance, I got something in a way where I could see a customer showing the same order ID with different order sequences (numbers).</p><p>The following is what the select * from items will give!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*339mcUb_je3u0L6t6X3FPw.png" /></figure><p>Now let us get down to the concepts I was talking about :-</p><p>The very first concept I’d like to talk about is a CTE or a Common Table Expression.</p><h4><strong>CTE — Common Table Expression</strong></h4><p>If you have been a regular SQL’er, I can imagine that you must be playing around with a lot of joins considering most of the organizations who use SQL databases, use a Relational one (RDBMS) with data being queried from across a myriad tables. Haven’t you often felt that in your pursuit of applying joins, you rather end up creating a mess up in your head and lose the train of where the joins started from and where they led to.</p><p>I think, be it any analysis — retaining the chronology of all the steps that go in your analysis, is the key. CTEs is the way, you actually can draw a chronology in your overall data analysis where you are using SQL to fetch insights out of your raw / crude data.</p><p><strong>Also one should know that — </strong>CTEs (Common Table Expressions) are temporary. They only exist for the duration of the query in which they are used. Once the query execution is complete, the CTE is discarded and does not store data permanently.</p><p>Syntactically speaking,</p><p>You define a CTE through the following method :-</p><p>WITH CTE_NAME AS ( …………)</p><p>And how can you create multiple CTEs in a single session are :-<br>CTE1<br>CTE2<br>CTE3<br>and then here — — — -at this level — — — -you go ahead marry the CTEs together, joining all of them.<br>Now you know how would you use CTEs.</p><p><strong>Some advantages of CTEs?</strong></p><ul><li>CTEs <strong>make complex queries more readable and manageable</strong>.</li><li>They <strong>help avoid duplicate subqueries</strong>.</li><li>Recursive CTEs <strong>are great for hierarchical data </strong>(ok, this one might be a little obscure to explain in one go, but i will try).</li><li>Some databases (like <strong>Snowflake, PostgreSQL, SQL Server</strong>) optimize CTEs for <strong>better performance</strong>.</li></ul><p>&lt; — — — — — — — — — — Demonstration for CTEs — — - — — — — — — — →</p><p><strong><em>So, today is Jan 31, 2025; and am back demonstrating CTEs as promised. How is it going?</em></strong></p><p>As you will see in the code below, am trying to create an analytical use-case, wherein am trying to come up with all those customers who placed their first order in the first half of 2024 and came back for an incremental order in the second half of 2024.</p><p>Here, I have used the concept of CTEs as such :-</p><ul><li><strong>unique_orders</strong> is a CTE which helps me create a distinct set of Order Id, Customer Id, Order Date; thus eliminating the dimension of items. <br>Why I actually created this CTE is purely because the orders sequencing done in the subsequent CTE cte_orders_sequencing shall then not spoil the sequencing (in view of the issue I shared above where I mentioned that there was the same order id repeating with different order sequence number).</li><li><strong>cte_orders_sequencing </strong>is a CTE which helps me create the order sequencing for a customer looking at all his/her orders. <br>Here, I have used a ROW_NUMBER() function in addition to an OVER function which encloses a statement where the entire unique_orders CTE is being partitioned by customer_id ORDERING it by order_date. This spits an order sequence.</li><li>Next, I create a <strong>first_orderers_first_half_2024</strong> CTE which gives me an Order ID, Customer ID and Order Date for all the consumers who made their first order in the first half of 2024.</li><li>Next, I create an <strong>incremental_orderers_second_half_2024 </strong>CTE which gives me an Order ID, Customer ID and Order Date for all the consumers who made their first order in the first half of 2024 and later came back for an incremental order in the second half of 2024.</li><li>At the end, I do a <strong>SELECT distinct customer_id from incremental_orderers_second_half_2024; </strong>which gives me the list of customers who came for an incremental order in the later half of 2024, after having placed their first order in the first half of 2024.</li><li>We are looking at a roughly 275 such customers.</li></ul><pre>-- Demonstrating CTEs for insights discovery<br>--- Taking a usecase wherein I want to see that of all the customers who placed their first order in the first half of 2024, how many also came back to place any incremental order within the next 6 months from the first order date.<br><br>WITH unique_orders AS (<br>    SELECT DISTINCT order_id, customer_id, order_date<br>    FROM dummy_orderitem_data<br>),<br>cte_orders_sequencing AS (<br>    SELECT <br>        order_id,<br>        customer_id,<br>        order_date,<br>        ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date) AS order_sequence<br>    FROM unique_orders<br>),<br>-- SELECT * FROM cte_orders_sequencing LIMIT 10; --&gt; This was to check the sample records that got created in cte_orders_sequencing CTE<br><br><br>first_orderers_first_half_2024 AS (<br>SELECT order_id, customer_id, order_date from cte_orders_sequencing where order_sequence = 1 AND ORDER_DATE BETWEEN &#39;2024-01-01&#39; AND &#39;2024-06-30&#39;<br>),<br><br>incremental_orderers_second_half_2024 AS (<br>SELECT order_id, customer_id, order_date from cte_orders_sequencing where order_sequence &gt; 1 AND ORDER_DATE BETWEEN &#39;2024-07-01&#39; AND &#39;2024-12-31&#39; AND customer_id IN (select customer_id from first_orderers_first_half_2024)<br>)<br><br>SELECT distinct customer_id from incremental_orderers_second_half_2024;</pre><ul><li>There is also one another way of zeroing-on to these 275 customers — which is when I try to left join the first_orderers_first_half_2024 with cte_orders_sequencing inside incremental_orderers_second_half_2024. This is just me attempting another way of getting to the same thing. Nothing very special about it tho :)</li></ul><pre>WITH unique_orders AS (<br>    SELECT DISTINCT order_id, customer_id, order_date<br>    FROM dummy_orderitem_data<br>),<br>cte_orders_sequencing AS (<br>    SELECT <br>        order_id,<br>        customer_id,<br>        order_date,<br>        ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date) AS order_sequence<br>    FROM unique_orders<br>),<br>-- SELECT * FROM cte_orders_sequencing LIMIT 10; --&gt; This was to check the sample records that got created in cte_orders_sequencing CTE<br><br><br>first_orderers_first_half_2024 AS (<br>SELECT order_id, customer_id, order_date from cte_orders_sequencing where order_sequence = 1 AND ORDER_DATE BETWEEN &#39;2024-01-01&#39; AND &#39;2024-06-30&#39;<br>),<br><br>incremental_orderers_second_half_2024 AS (<br>SELECT order_id, customer_id, order_date from cte_orders_sequencing where order_sequence &gt; 1 AND ORDER_DATE BETWEEN &#39;2024-07-01&#39; AND &#39;2024-12-31&#39; AND customer_id IN (select customer_id from first_orderers_first_half_2024)<br>),<br><br>incremental_orderers_second_half_2024_ver2 AS (<br>SELECT fofh2.order_id, fofh2.customer_id as customer_id_fofh2, fofh2.order_date, cos.order_id, cos.customer_id as customer_id_cos, cos.order_date, cos.order_sequence from first_orderers_first_half_2024 fofh2 left join cte_orders_sequencing cos ON fofh2.customer_id = cos.customer_id where cos.order_sequence &gt; 1 AND cos.ORDER_DATE BETWEEN &#39;2024-07-01&#39; AND &#39;2024-12-31&#39;<br>)<br><br>SELECT COUNT(distinct customer_id_fofh2) from incremental_orderers_second_half_2024_ver2; #275</pre><p><strong><em>Guess what — the above query is giving me 275 too. <br>I did nothing but a left join between first_orderers_first_half_2024 and incremental_orderers_second_half_2024_ver2.</em></strong></p><p><strong>This was just a way for me to state that one particular thing can be achieved through various means.</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>I shall be back tomorrow (Feb 01, 2025) to take up COALESCE and EXISTS</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><p>The other topics I would like to cover about, are : <strong>COALESCE</strong>, <strong>EXISTS</strong>, <strong>ROW NUMBER (WINDOWS FUNCTIONS, PARTITION), DENSE RANK</strong>, <strong>RANK</strong>, <strong>PIVOT.</strong></p><p>Then I would also like to talk about <strong>CREATING A TEMPORARY TABLE <br></strong>AND THEN THE MOST CONVENTIONAL JAZZ —<br><strong> JOINS.</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p><strong>Today is April 03, 2025</strong>; and I think I am too late in getting back. I promised Feb 01, 2025 I think.<br>I think I am too late, almost ~62 days. Geez!<br>These days were nothing less than a tragic seesaw. Good Lord, I know how I balanced it all.</p><p><strong>Never mind, that’s for some other day.</strong></p><p>Alright then let me cut to the chase.<br>COALESCE() right?<br>Yea- so Coalesce() is a function in SQL that you use to replace null values with some fixed value, in your data.<br>It is generally and traditionally expected to return the first non-null value from a list of values.</p><p>One may ask, why did I say “generally and traditionally” — it is because there’s more to COALESCE() than what the rookies generally believe. For example, I did not know for a very long time that it is a special choice over the ISNULL() and IFNULL() of the world because it is a standard SQL and works across most databases. And to tell, ISNULL() I think is specific to SQL Server and IFNULL() is specific to MySQL.</p><p>COALESCE() can also take two arguments.<br>I will just share the code for it in a while. But, verbally, let’s say if I were to tell that I have a data of customers and I am trying to help a company if they would be able to contact a particular customer through a pool of data available (considering let’s say the company has their mobile number and email address); I might end up suggesting something like :-</p><p><strong>SELECT COALESCE(email_id, mobile_phone_no, ‘No contact info’) AS preferred_contact<br>FROM contacts;</strong></p><p>Here — contact is the table name. And I am asking Snowflake (or whatever platform you are using) to first check if the email_id exists and then move to mobile_phone_no and if the latter doesn’t exist too, then just mention that there is ‘No contact info’ in the results against that customer.</p><p><strong><em>This is also what the Data Analysts / SQL’ers may call as a multiple fallback.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*G5P_G8pGq30W7lNVvu07kw.gif" /><figcaption>So, that’s COALLESCE() walking with attitude. You know why, now!</figcaption></figure><p>This crazy function can also take care of the aggregations usecase.<br>For example, in the same case of customers data, I am helping a company find the total spend done by the customer in the entire CLTV.<br>So generally one would simply do a SUM() on the spend column which would be let’s say at an order level.</p><pre>SELECT COALESCE(SUM(order_spend_value), 0) AS customer_spend FROM customers_spend_table where customer_id = 2704;</pre><p>So, here just in case if in the customers’ spend data the customer with ID = 2704 would not have made any purchases, then by the nature of SUM() aggregation it is expected to spit NULL, but COALESCE will replace it with 0 and we will get 0 in the results.</p><p>Now, coming to the part where I would like to demonstrate COALESCE() with an example of the synthetic data I have created for our use-case.</p><p><strong>dummy_orderitem_data — </strong>rings a bell, aye?</p><p><strong>So what have I actually done?</strong></p><ul><li>I realized that I won’t have null values in my data considering that when I synthetically generated the data, I had consciously inserted the data with a focus that I create random values bit with no room for null. For instance, let’s take the case of ORDER_PRODUCT_COLOUR.<br>When I had created the data, I had used something like :-</li></ul><pre>ARRAY_CONSTRUCT(&#39;Red&#39;, &#39;Blue&#39;, &#39;Green&#39;, &#39;Black&#39;, &#39;White&#39;)[UNIFORM(0, 5, RANDOM())] AS order_product_colour</pre><p>What the above statement did was that it randomly distributed the values (colors) from the list defined covering all the rows, which means, there was no room for any null values. I defined UNIFORM(0, 5) which generated a sequence of 0,1,2,3,4 (5 values) and we also have 5 color values in the array construct. So you get it right? No room for null values.</p><p>But, now to demonstrate the COALESCE() function, I decided to go back to my drawing book and blatantly insert some null values at the time of data entry (as in the INSERT step).</p><pre>CASE UNIFORM(0, 4, RANDOM())<br> WHEN 0 THEN NULL<br> ELSE ARRAY_CONSTRUCT(&#39;Red&#39;, &#39;Blue&#39;, &#39;Green&#39;, &#39;Black&#39;, &#39;White&#39;)[UNIFORM(0, 5, RANDOM())]</pre><p>So - I will explain what have I done here! <br>I introduced a CASE construct in this, which enables a probability of a 25% of the ORDER_PRODUCT_COLOUR coming as NULL. So, the UNIFORM function in this case generates a sequence as 0,1,2,3 (4 values) and I am saying in CASE if 0 (zero) comes mark the ORDER_PRODUCT_COLOUR as null ELSE pick one of the 5 colors randomly. So that is 1/4 probability.</p><p><strong>And — following is how the data then looks :-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4nEZoGb6SyJU2_a8zfNNhA.png" /><figcaption>Order Item Data with ORDER_PRODUCT_COLOUR as null in some tuples.</figcaption></figure><p><strong>And if I do a COUNT, I get :-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CyoQtaWx8iej6MtxIINk0Q.png" /><figcaption>Count of order product colour NULL values in the order items</figcaption></figure><p>So, then I employed COALESCE at the time of the CTE — <strong>coalesce_demonstration</strong> creation.</p><pre>coalesce_demonstration AS <br>(SELECT<br>    order_id,<br>    item_id,<br>    COALESCE(order_product_colour, &#39;Unknown&#39;) AS safe_order_product_colour FROM dummy_orderitem_data)</pre><p>So, what this does is that it replaces all the NULL values in ORDER_PRODUCT_COLOUR with ‘Unknown’. <br>The same is what you can see below, in the screenshot. <br>Bad screenshot, though.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQPS05nresB5rzS9zmRWug.png" /></figure><p><strong>So — now when I ran</strong></p><pre>select COUNT(*) from coalesce_demonstration WHERE safe_order_product_colour IS NULL;</pre><p>I got a zero (0) in the results (as you can also see).<br>That is what I expected.<br>That is what YOU expected.<br>That is what THEY will expect too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dxKz_S720yCuScojlvQVSA.png" /></figure><h3><strong>Got to go. See you soon, for the next set of functions.</strong><br>Bye!</h3><p>— — — — — — — Alright, so today is April 10, 2025, and am back to take up one or two functions as I had said last time, before I go on a small break again. I am getting engaged :p — — — — — — —</p><p><strong>I have three use-cases I can think of, through which I can demonstrate EXISTS() function. Let me begin with the first use-case.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*4pbwLBlMHsT3ozw0y2E8eg.gif" /><figcaption><strong>No, not SAW-ing anyone. Relax!</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lhkVd4r0zTYAYarQ4RHQaQ.png" /><figcaption><strong>Demonstrating EXISTS</strong></figcaption></figure><p>Here’s the <strong>1st use case</strong>, where I am trying to find all the customers who ordered at least one ‘Electronics’ product.<br>So, the query is structured in a way where I am using the EXISTS function to check all the customers who have even one (or more) order that consisted of an electronic item.</p><p>So the outer query — SELECT DISTINCT customer_id, customer_name FROM dummy_orderitem_data d1 is simply selecting the two columns customer_id and customer_name from the data, and then it looks for only those records (read as rows) which follow a criteria.</p><p>The criteria is that there should be some order (one or more) for that customer, that exists, which had an (one or more) electronic item/s. How it is accomplished is by checking if whatever condition that is bound within the round brackets after EXISTS condition, evaluates to <strong>True.</strong></p><p><strong>What is happening in the condition inside the brackets after the EXISTS clause?<br></strong>We are trying to ask the system (Snowflake here) to return one (1) if even one record (order) exists for a customer that has an order item of type (column name is <strong><em>order_product_type</em></strong>). The same table dummy_order_type is referenced twice. One, as a master (primary) table in the outside query, which is matched with itself (as a secondary table inside the sub-query) on a common column — <strong>customer_id.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nPrbjS2N-fqq5wuHnB7hkA.png" /><figcaption><strong>Results of Use-case 01</strong></figcaption></figure><p><strong>Now, coming to the other two use-cases :-</strong></p><p><strong>2nd Use-case<br></strong>I am trying to find all the customers who did not place any order that had an item belonging to the‘Toys’ category (order_product_type). <br>Here, what I am doing is not very different from what I did in the 1st use-case, but, just that am trying to disqualify the sub-query by stating that no such record exists for a particular customer. So, I want those customers as the results of the query, who do not have even one single such order which has an item belonging to ‘Toys’ category.</p><p><strong>So, it is essentially ‘Toys’ replacing ‘Electronics’ and ‘EXISTS’ getting replaced by ‘NOT EXISTS’.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wepfsr97EKeKwcCbQMeIkw.png" /><figcaption><strong>Results of Use-case 02</strong></figcaption></figure><p><strong>As you can see it gives me 12 such distinct customers.</strong></p><p>Now, what if I had to find such unique orders instead of consumers. <br>The query is a simple upgrade (just replace customers with orders) :-</p><pre>SELECT DISTINCT order_id<br>FROM dummy_orderitem_data d1<br>WHERE NOT EXISTS (<br>    SELECT 1<br>    FROM dummy_orderitem_data d2<br>    WHERE d2.order_id = d1.order_id<br>      AND d2.order_product_type = &#39;Toys&#39;<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AEIBM7Yx8BezQq0XSLLUJA.png" /><figcaption><strong>Replace customers with orders</strong></figcaption></figure><p><strong>Alright now, time for the 3rd and last Use-case :-</strong></p><p>What the holy cow, am I doing here?<br>I am trying to find a list of customers who came in 2024 (time range : Jan 01, 2024 to Dec 31, 2024) and placed one or more orders, and then also came later than Dec 31, 2024 to place another order.</p><p>Idea is simple — Create a CTE that establishes a cohort of customers who placed any order in the year 2024.<br>And then using that CTE, aided with EXISTS function, see all those customers in the main (primary) table, who belong to the CTE which means who placed any order in year 2024 and then who also have any order that is dated &gt; Dec 31, 2024. Simple, yes? No? Leave a comment, and I shall reply :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RzI98CBWLflfdkNY9UBxFw.png" /><figcaption><strong>Query for Use-case 3</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pQSH_SCR60hlw0uqWvzoCw.png" /><figcaption><strong>Results for Use-case 3</strong></figcaption></figure><p>So I think I have shared my best for EXISTS(), today.<br>I will take a leave and come back soon for other functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*XC_Ldj3UinOzlyGIeiRItg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeb08f8a3fb3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/sql-wizardry-from-hiatus-to-mastery-the-snowflake-way-aeb08f8a3fb3">SQL Wizardry — From Hiatus to Mastery | The Snowflake Way</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>