<?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 aravinda desai on Medium]]></title>
        <description><![CDATA[Stories by aravinda desai on Medium]]></description>
        <link>https://medium.com/@aravindadesai?source=rss-8090d013feb8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by aravinda desai on Medium</title>
            <link>https://medium.com/@aravindadesai?source=rss-8090d013feb8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 13:14:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aravindadesai/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[A simple example on Snowflake Steams and Tasks]]></title>
            <link>https://medium.com/@aravindadesai/a-simple-example-on-snowflake-steams-and-tasks-990608d6b99a?source=rss-8090d013feb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/990608d6b99a</guid>
            <category><![CDATA[snowflake-computing]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[aravinda desai]]></dc:creator>
            <pubDate>Fri, 13 Aug 2021 06:30:02 GMT</pubDate>
            <atom:updated>2021-08-13T06:30:02.231Z</atom:updated>
            <content:encoded><![CDATA[<pre><em>This is a step by step guide to create a stream and schedule a task which compacts the data and load into the COMPACT table by querying the RAW table automatically and periodically.</em></pre><pre><em>-- Step 1: Create Test Raw and Compact tables.<br></em><strong>create or </strong>replace <strong>TABLE </strong>RAW_TABLE cluster <strong>by </strong>(<strong>date</strong>)<br>(<br>    column1 <strong>VARCHAR</strong>(16777216),<br>    columnN <strong>VARCHAR</strong>(16777216),<br>    customerID <strong>VARCHAR</strong>(16777216),<br>    <strong>date DATE<br></strong>);</pre><pre><strong>create or </strong>replace <strong>TABLE </strong>COMPACT_TABLE cluster <strong>by </strong>(column1, column2)<em><br></em>(<br>    column1 <strong>VARCHAR</strong>(16777216),<br>    columnN <strong>VARCHAR</strong>(16777216),<br>    customerID <strong>VARCHAR</strong>(16777216),<br>    cnt <strong>INT<br></strong>);</pre><pre><em>--Step 2: Create a Stream against RAW_TABLE.<br></em><strong>create or </strong>replace stream RAW_TABLE_STREAM <strong>on table </strong>RAW_TABLE;<br><br><em>--Step 3: Create a Task to load the data from RAW_TABLE to COMPACT_TABLE table.<br></em><strong>create or </strong>replace task RAW_TABLE_TO_COMPACT_TABLE<br>warehouse = UR_WAREHOUSE<br>schedule = <strong>&#39;1 minute&#39;<br>when<br></strong>system$stream_has_data(<strong>&#39;</strong>RAW_TABLE_STREAM<strong>&#39;</strong>)<br><strong>as<br></strong>merge <strong>into </strong>COMPACT_TABLE cg<br><strong>using </strong>(<br># COMPACT_SQL_LOGIC_GOES_HERE<br>);<br><br><em>--Step 4: Check the tasks got registered or not.<br></em>show tasks <strong>like &#39;RAW%&#39;</strong>;<br><br><em>--Step 5: By default task will be in &quot;SUSPEND&quot;ed state hence we need to &quot;RESUME&quot;<br></em><strong>alter </strong>task RAW_TABLE_TO_COMPACT_TABLE RESUME;<br><br><em>--Step 6: Insert the data into RAW_TABLE and check the stream.<br></em><strong>insert into </strong>RAW_TABLE (...) values (...);<br><strong>select </strong>* <strong>from </strong>RAW_TABLE_STREAM  limit 10; <em>-- Data should be available<br></em><strong>select </strong>* <strong>from </strong>COMPACT_TABLE limit 10; <em>-- Zero records<br></em><strong>select count</strong>(*) <strong>from </strong>RAW_TABLE limit 10; <em>-- Data should be available<br><br>--Step 7: Check the Task status, and column &quot;STATE&quot; will show either of them &quot;SUCCESS/SCHEDULED/FAILED&quot;<br></em><strong>select </strong>* <strong>from table</strong>(information_schema.task_history(   scheduled_time_range_start=&gt;dateadd(<strong>&#39;hour&#39;</strong>,-1,<strong>current_timestamp</strong>()),<br>        result_limit =&gt; 10,<br>        task_name=&gt;<strong>&#39;</strong>RAW_TABLE_TO_COMPACT_TABLE<strong>&#39;</strong>));<br><br><em>--Step 8: Check the Compacted table data.<br></em><strong>select </strong>* <strong>from </strong>COMPACT_TABLE limit 10; <em>-- Data should be available.<br><br>-- Tear Down Steps:<br></em><strong>alter </strong>task RAW_TABLE_TO_COMPACT_TABLE SUSPEND;<br><strong>drop </strong>stream RAW_TABLE_STREAM;<br><strong>drop table </strong>COMPACT_TABLE;<br><strong>drop table </strong>RAW_TABLE;<br><strong>drop </strong>task RAW_TABLE_TO_COMPACT_TABLE;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=990608d6b99a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>