<?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 Kumar Pandey on Medium]]></title>
        <description><![CDATA[Stories by Kumar Pandey on Medium]]></description>
        <link>https://medium.com/@rkmpandey1?source=rss-a1c7c6f74a94------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*UXpPzmf9lAH4vGEC.jpg</url>
            <title>Stories by Kumar Pandey on Medium</title>
            <link>https://medium.com/@rkmpandey1?source=rss-a1c7c6f74a94------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 17:20:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rkmpandey1/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[Snowflake -Merge Overlapping events using CONDITIONAL_CHANGE_EVENT]]></title>
            <link>https://medium.com/@rkmpandey1/snowflake-merge-overlapping-events-using-conditional-change-event-654b63fdd27a?source=rss-a1c7c6f74a94------2</link>
            <guid isPermaLink="false">https://medium.com/p/654b63fdd27a</guid>
            <dc:creator><![CDATA[Kumar Pandey]]></dc:creator>
            <pubDate>Fri, 02 Jun 2023 10:17:21 GMT</pubDate>
            <atom:updated>2023-06-02T10:17:21.955Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently came across snowflake CONDITIONAL_CHANGE_EVENT function while Merging Overlapping events for member attribute over different time windows.<br>we could use recursive CTE for overlapping events over time windows, however, CONDITIONAL_CHANGE_EVENT made it short and interesting.</p><p>The expression CONDITIONAL_CHANGE_EVENT (expr1) OVER (window_frame) is calculated as:</p><p>CONDITIONAL_TRUE_EVENT( &lt;expr1&gt; != LAG(&lt;expr1&gt;) OVER(window_frame)) OVER(window_frame)</p><p>Here is my solution looked like:</p><p>I first created change bucket based on CONDITIONAL_CHANGE_EVENT for those attribute values. I concatenated those values so CONDITIONAL_CHANGE_EVENT can compare those values with previous values for that partition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YJ2dKzFDhx69N_33" /></figure><p>Final Query, where I took min of start_date and Max of End_date for each change bucket .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-zF9sOha44-q5CIe37u-g.png" /></figure><p>References: <a href="https://docs.snowflake.com/en/sql-reference/functions/conditional_change_event">https://docs.snowflake.com/en/sql-reference/functions/conditional_change_event</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=654b63fdd27a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>