<?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 Tim Spann on Medium]]></title>
        <description><![CDATA[Stories by Tim Spann on Medium]]></description>
        <link>https://medium.com/@tim.spann_50517?source=rss-44aa222039a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VIU02iwKbHxL5cw_</url>
            <title>Stories by Tim Spann on Medium</title>
            <link>https://medium.com/@tim.spann_50517?source=rss-44aa222039a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:24:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tim.spann_50517/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[Building RAG Applications with Cortex AI]]></title>
            <link>https://medium.com/@tim.spann_50517/building-rag-applications-with-cortex-ai-bf0a3d2202db?source=rss-44aa222039a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf0a3d2202db</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Tim Spann]]></dc:creator>
            <pubDate>Tue, 06 May 2025 15:13:36 GMT</pubDate>
            <atom:updated>2025-05-06T15:13:36.600Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>RAG Examples</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FyXgFs31MWUw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DyXgFs31MWUw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FyXgFs31MWUw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5dec397afed148e641c4cf36f23ee1ab/href">https://medium.com/media/5dec397afed148e641c4cf36f23ee1ab/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKVPfkZE3WPE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKVPfkZE3WPE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKVPfkZE3WPE%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8704361eba09bcc1f50a16191626d50f/href">https://medium.com/media/8704361eba09bcc1f50a16191626d50f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCWEjp1iadUc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCWEjp1iadUc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCWEjp1iadUc%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/86509fa62a4f64a9c61ee75a79257dfb/href">https://medium.com/media/86509fa62a4f64a9c61ee75a79257dfb/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FRLCJrM8v76o%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DRLCJrM8v76o&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FRLCJrM8v76o%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/53754a82bf6b4924b89de8092af2fde8/href">https://medium.com/media/53754a82bf6b4924b89de8092af2fde8/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FcbKSlYQvpMw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DcbKSlYQvpMw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FcbKSlYQvpMw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/11f897f5ae60d84eb39dcae1527fe1a8/href">https://medium.com/media/11f897f5ae60d84eb39dcae1527fe1a8/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCWEjp1iadUc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCWEjp1iadUc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCWEjp1iadUc%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/86509fa62a4f64a9c61ee75a79257dfb/href">https://medium.com/media/86509fa62a4f64a9c61ee75a79257dfb/href</a></iframe><p><strong>Quickstarts</strong></p><p><a href="https://quickstarts.snowflake.com/guide/ask_questions_to_your_own_documents_with_snowflake_cortex_search/#4">Build a Retrieval Augmented Generation (RAG) based LLM assistant using Streamlit and Snowflake Cortex Search</a></p><p><strong>Documentation</strong></p><ul><li><a href="https://www.snowflake.com/en/fundamentals/rag/">Build RAG Apps</a></li><li><a href="https://www.snowflake.com/en/developers/solutions-center/build-a-rag-based-application-on-sec-filing-data-using-snowflake-cortex/">Build a RAG-Based Application Using Snowflake Cortex</a></li><li><a href="https://www.snowflake.com/en/blog/easy-secure-llm-inference-retrieval-augmented-generation-rag-cortex/">Easy and Secure RAG to LLM Inference with Snowflake Cortex</a></li></ul><p><strong>Tutorials</strong></p><ul><li><a href="https://airbyte.com/tutorials/build-an-ai-chatbot-with-snowflake-cortex">Build an AI chatbot with Snowflake Cortex | Airbyte</a></li><li><a href="https://usharengaraju.medium.com/creating-a-rag-based-chatbot-on-autism-using-snowflake-cortex-ai-a-step-by-step-guide-3573ccf9b77a">Creating a RAG-Based Chatbot for Autism Using Snowflake Cortex and Snowflake Artic: A Step-by-Step…</a></li><li><a href="https://www.aimpointdigital.com/blog/snowflake-cortex-search-rag-systems">Leveraging Snowflake Cortex&#39;s Search to Build RAG Systems</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf0a3d2202db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Australian Public Transit]]></title>
            <link>https://medium.com/@tim.spann_50517/automating-australian-public-transit-f9a98f1422a9?source=rss-44aa222039a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9a98f1422a9</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[gtfs]]></category>
            <category><![CDATA[apache-nifi]]></category>
            <category><![CDATA[transit]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Tim Spann]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 20:34:07 GMT</pubDate>
            <atom:updated>2025-04-16T20:34:07.671Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache NiFi, Snowflake, GTFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HKG2gB6Nb94HWshZ" /></figure><p>First we download some static GTFS tables for lookups and detailed information for our real-time feeds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VaZTUUsodGRJ33C-MdJYnQ.png" /><figcaption>Advanced Feature in UpdateAttribute to set correct field name for generic table processing.</figcaption></figure><p>Once we have static lookup tables loaded in Snowflake, we can then start ingesting real-time data and then join them.</p><p><strong>Real-Time GTFS Processing</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNDEv4MLj0TF1sasUHpbog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*T2tc_8_hCKhWE7N6MbTj4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-33w_2Mx9-0dCGvA2Yi0kw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzR9gvgBhnPfV87VAdhBMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S52EoiA6AgxXRZWJjtuw7w.png" /><figcaption>Service Alerts</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*KP35Or5gtmGoVpgkMwOtJw.png" /><figcaption>Vehicle Positions</figcaption></figure><p><strong>Real-Time Snowflake Tables</strong></p><pre>CREATE OR REPLACE TABLE ADELAIDEVEHICLEPOSITIONS (<br> ROUTEID STRING,<br> BEARING STRING,<br> DIRECTIONID STRING,<br> LATITUDE STRING,<br> TRIPID STRING,<br> VEHICLELABEL STRING,<br> VEHICLEID STRING,<br> STARTDATE STRING,<br> UUID STRING,<br> SPEED STRING,<br> LONGITUDE STRING,<br> TIMESTAMP STRING,<br> TS STRING);</pre><pre>  CREATE OR REPLACE TABLE ADELAIDESERVICEALERTS (<br> ROUTEID4 STRING,<br> ROUTEID5 STRING,<br> DESCRIPTIONLANG STRING,<br> CAUSE STRING,<br> STOPID STRING,<br> ALERTLANG STRING,<br> ALERTTEXT STRING,<br> ROUTEID STRING,<br> EFFECT STRING,<br> STOPID5 STRING,<br> DESCRIPTIONTEXT STRING,<br> STOPID4 STRING,<br> ACTIVEPERIODEND STRING,<br> STOPID3 STRING,<br> STOPID2 STRING,<br> ROUTEID2 STRING,<br> ROUTEID3 STRING,<br> ACTIVEPERIODSTART STRING,<br> TS STRING,<br> UUID STRING);</pre><pre>CREATE OR REPLACE TABLE ADELAIDETRIPUPDATES (<br>  stopsequence  text NULL,<br>  arrivaltime   text NULL,<br>  stopid        text NULL,<br>  tripid        text NULL,<br>  tripstartdate text NULL,<br>  departuretime text NULL,<br>  triprouteid   text NULL,<br>  ts            text NULL,<br>  uuid          text NULL);</pre><ul><li><strong>Real-time GTFS Data:</strong> Vehicle Positions, Service Alerts and Trip Updates</li><li><strong>RSS Feeds of Announcements</strong></li><li><strong>GTFS Static Data:</strong> Lookup tables includes Routes, Stops, Dates and more.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g18cBrYT4dmaHTWki8eLwQ.png" /><figcaption>Vehicle Position (GTFS Realtime)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KrT847KU6ly55_hFzDhOlQ.png" /><figcaption>Trip Updates (GTFS Real-time)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKFN9-N5Gm1_-d7xjxX4Zw.png" /><figcaption>Trips (GTFS Static)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBNs--6iGTtJ_xky1Z6lwQ.png" /><figcaption>Routes (GTFS Static)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yGe6G3NeXBoMUSNPO9lK4g.png" /><figcaption>Service Alerts (GTFS Real-Time)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aAMj7htGYG8VPcnKednZjg.png" /><figcaption>Stops (GTFS Static)</figcaption></figure><h3>News Feed (RSS)</h3><p>Let’s look at ingesting a news feed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zh2QCi3FLi522Ea14kFxdA.png" /></figure><h3>Analytics</h3><pre>SELECT VEHICLELABEL, SPEED, STARTDATE, LATITUDE, LONGITUDE,<br>       HAVERSINE( LATITUDE, LONGITUDE, -34.9206, 138.5981 ) as distancefromdeloitteinkm<br>FROM DEMO.ADELAIDEVEHICLEPOSITIONS i <br>where longitude is not null and latitude is not null<br>and LENGTH(TRIM(longitude)) &gt; 0 and LENGTH(TRIM(latitude)) &gt; 0<br>ORDER BY i.STARTDATE DESC,   i.&quot;TS&quot; DESC;<br><br></pre><p>I did a quick check to see where the buses where in distance from Deloitte’s office where some Snowflake events occur.</p><pre>SELECT i.ALERTTEXT , i.CAUSE , i.DESCRIPTIONTEXT , i.EFFECT ,<br>       r.ROUTEID, i.ROUTEID, r.ROUTELONGNAME, r.ROUTEURL, r.ROUTEDESC<br>FROM DEMO.ADELAIDESERVICEALERTS i  LEFT OUTER JOIN ADELAIDEROUTES r ON i.ROUTEID = r.ROUTEID<br>where i.ROUTEID  IS NOT null<br>ORDER BY  i.&quot;TS&quot; DESC;</pre><p>The above query gets us the route information for our service alerts.</p><pre>SELECT VEHICLELABEL, SPEED, STARTDATE, LATITUDE, LONGITUDE,<br>       HAVERSINE( LATITUDE, LONGITUDE, -34.9206, 138.5981 ) as distancefromdeloitteinkm,<br>       r.ROUTEID, i.ROUTEID, r.ROUTELONGNAME, r.ROUTEURL, r.ROUTEDESC, a.TRIPHEADSIGN, a.TRIPSHORTNAME, a.WHEELCHAIRACCESSIBLE<br>FROM DEMO.ADELAIDEVEHICLEPOSITIONS i  LEFT OUTER JOIN ADELAIDEROUTES r ON i.ROUTEID = r.ROUTEID<br>     LEFT OUTER JOIN ADELAIDETRIPS a ON a.TRIPID = i.TRIPID<br>where longitude is not null and latitude is not NULL<br>and LENGTH(TRIM(longitude)) &gt; 0 and LENGTH(TRIM(latitude)) &gt; 0<br>ORDER BY i.STARTDATE DESC,   i.&quot;TS&quot; DESC;</pre><p>We get trip and route information as well as location.</p><pre>SELECT  s.STOPNAME,  r.ROUTELONGNAME, r.ROUTEDESC, a.TRIPHEADSIGN,<br>       s.STOPDESC, s.STOPLAT, s.STOPLON,<br>       HAVERSINE( s.STOPLAT, s.STOPLON, -34.9206, 138.5981 ) as distancefromdeloitteinkm,<br>       r.ROUTEID, r.ROUTEURL<br>FROM DEMO.ADELAIDETRIPUPDATES i  LEFT OUTER JOIN ADELAIDEROUTES r ON <br>                                        i.TRIPROUTEID = r.ROUTEID<br>     LEFT OUTER JOIN ADELAIDETRIPS a ON a.TRIPID = i.TRIPID<br>     LEFT OUTER JOIN ADELAIDESTOPS s ON i.STOPID = s.STOPID <br>ORDER BY i.TRIPSTARTDATE DESC,   i.&quot;TS&quot; DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UOWA8tRYI-iXuLyUl46p2g.png" /><figcaption>Trip Updates, Routes, Trips, Stops</figcaption></figure><h3>Slack Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufLc-tG1nWDc2RG4xa3GSQ.png" /></figure><h3>Videos</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaPHHgO0_EHs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaPHHgO0_EHs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FaPHHgO0_EHs%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/59f20015158f5ffc1a37da9346c1e4a3/href">https://medium.com/media/59f20015158f5ffc1a37da9346c1e4a3/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FSQtq_tgh5g4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DSQtq_tgh5g4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FSQtq_tgh5g4%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/83ba43824fafb511cfbf89eb5402a4cb/href">https://medium.com/media/83ba43824fafb511cfbf89eb5402a4cb/href</a></iframe><h3>Source Code</h3><p><a href="https://github.com/sfc-gh-tspann/DataAIDemos/blob/main/aumetro.sql">DataAIDemos/aumetro.sql at main · sfc-gh-tspann/DataAIDemos</a></p><h3>Resources</h3><ul><li><a href="https://medium.com/@tspann/yes-apache-nifi-can-do-that-c7fcaca5a177">Yes Apache NiFi Can Do That</a></li><li><a href="https://gtfs.adelaidemetro.com.au/">Adelaide Metro - GTFSR</a></li><li><a href="https://www.adelaidemetro.com.au/">Adelaide Metro</a></li><li><a href="https://github.com/OpenTransitTools/gtfsdb">GitHub - OpenTransitTools/gtfsdb: GTFS ORM using SQLAlchemy</a></li><li><a href="https://data.sa.gov.au/data/dataset/https-gtfs-adelaidemetro-com-au">Adelaide Metro General Transit Feed - data.sa.gov.au</a></li><li><a href="https://www.adelaidemetro.com.au/developer-info">Developer information</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?type=application%2Fxml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=rss&amp;url=https%3A%2F%2Fwww.adelaidemetro.com.au%2Fannouncements%2Frss" width="720" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dddc0b2f676ac9e3d7ad8228339cda15/href">https://medium.com/media/dddc0b2f676ac9e3d7ad8228339cda15/href</a></iframe><ul><li><a href="https://medium.com/cloudera-inc/events-streams-flows-and-maps-22a8d27cd9b4">Events, Streams, Flows and Maps</a></li><li><a href="https://medium.com/cloudera-inc/real-time-in-boston-part-1-0f92d7da3496">Real-Time in Boston: Part 1</a></li><li><a href="https://medium.com/@tspann/real-time-irish-transit-analytics-ea76164c9595">Real-Time Irish Transit Analytics</a></li><li><a href="https://medium.com/cloudera-inc/iteration-1-building-a-system-to-consume-all-the-real-time-transit-data-in-the-world-at-once-4322b160df9d">Iteration 1: Building a System to Consume All the Real-Time Transit Data in the World At Once</a></li><li><a href="https://medium.com/cloudera-inc/iteration-2-building-a-system-to-consume-all-the-unsecured-real-time-transit-data-in-the-world-5f365c0cf240">Iteration 2: Building a System to Consume All the (Unsecured) Real-Time Transit Data in the World</a></li><li><a href="https://medium.com/cloudera-inc/finding-the-best-way-around-7491c76ca4cb">Finding the Best Way Around</a></li><li><a href="https://medium.com/@tspann/building-a-travel-advisory-app-with-apache-nifi-in-k8-969b44c84958">Building a Travel Advisory app with Apache NiFi in K8</a></li><li><a href="https://medium.com/cloudera-inc/subways-and-transit-updates-in-real-time-30c104c359ef">Subways and Transit Updates in Real-Time</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u18lKNFBL3qKKhW5" /></figure><p>Join us in New York City, Princeton or on youtube:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8_W061brwJaKfqOs" /></figure><ul><li><a href="https://www.youtube.com/@Flank-Stack">Data Engineering for AI in Real-Time</a></li><li><a href="https://www.dataengineeringforai.com/">dataengineeringforai</a></li><li><a href="https://lu.ma/PINSAI">Data Engineering for AI · Events Calendar</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9a98f1422a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Populating an Open Lakehouse with Codeless Data Streams]]></title>
            <link>https://medium.com/@tim.spann_50517/populating-an-open-lakehouse-with-codeless-data-streams-9395a30a2d4f?source=rss-44aa222039a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9395a30a2d4f</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[apache-nifi]]></category>
            <category><![CDATA[open-lakehouse]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Tim Spann]]></dc:creator>
            <pubDate>Wed, 09 Apr 2025 20:54:20 GMT</pubDate>
            <atom:updated>2025-04-09T20:54:20.526Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache NiFi, Apache Iceberg, Apache Parquet, CSV, JSON, GTFS, RSS, XML</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qOJF4MfMwRPq-eCxHAkD9A.png" /></figure><p>Let’s show you how easy it is to stream your data into Apache Iceberg.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ZVxfAeXAhXBzLHXTRkCfQ.png" /></figure><p>Let’s ingest data into Apache Iceberg tables with ease.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYJhRcXFNv2M%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYJhRcXFNv2M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYJhRcXFNv2M%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c66215b4dbb8bf88fb48e606e7dcc6f9/href">https://medium.com/media/c66215b4dbb8bf88fb48e606e7dcc6f9/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*v854Los6wDWb-NpW3EhX2Q.png" /></figure><p><strong>Loading Data</strong></p><ul><li><strong>InvokeHTTP</strong> — read from RSS Feed TRANSCOM — Could save now as raw XML in a Snowflake stage. Or save to S3.</li><li><strong>QueryRecord</strong> — -XMLReader to JSONWriter. Could save now as JSON to a stageor insert into a variant table.</li><li><strong>SplitJson</strong> — Break up complex JSON $.*.channel.item.*</li><li><strong>UpdateAttribute</strong> — Set schema, database, table and application type of JSON.</li><li><strong>UpdateRecord</strong> —Add a timestamp field (${now():toNumber()}) and a UUID field (${uuid})</li><li><strong>UpdateRecord</strong> — replaceRegex( /point, ‘\t\t’, ‘,’ ). Parse latitude and longitude.</li><li><strong>UpdateRecord</strong> — with <strong>latitude</strong> = substringBefore( /point, ‘ ‘ ) and <strong>longitude</strong> = substringAfter( /point, ‘ ‘ )</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*W8qTEVxmKUQD7vBO56ZIAw.png" /></figure><p><strong>To Store</strong></p><ul><li><strong>QueryRecord</strong> — SELECT * FROM FLOWFILE WHERE latitude is not null</li><li><strong>RouteOnAttribute</strong> — ${fileSize:gt(128)}. Throw away small files</li><li>MergeRecord — Collect 30 seconds or 5,000 rows</li><li>UpdateDatabaseTable — Prepare SQL for table DEMO.ICYTRANSCOME</li><li>PutDatabaserecord — Read JSON rows (probably 5000 row chunks), do an INSERT into our Iceberg table using the Snowflake engine. Match our JSON fields to our table fields ignoring unmatched fields and unmatched columns, translate field names where appropriate.</li></ul><p>We can easily query Iceberg tables and have it track maximum values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MJmuYixS5kZnQQUFqiCJvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1tvauaAhRudO9xPAaLECEA.png" /></figure><h3><strong>Tables</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*HLum0bXe4hEAY-QhWIeagA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtIYhycN5RYGxMd1pCXlFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtPbZRXJRXr_VNmlOqX2BA.png" /></figure><p><strong>Example Snowflake Stored Procedure Against Apache Iceberg Table</strong></p><pre>CREATE OR REPLACE PROCEDURE DEMO.DEMO.RETURN_MTA_NEARBY(YOURLATITUDE STRING, YOURLONGITUDE STRING)<br>RETURNS TABLE (&quot;BUS&quot; VARCHAR, &quot;destinationname&quot; VARCHAR,  expectedarrivaltime  VARCHAR, EXPECTEDDEPARTURETIME VARCHAR,<br>               stoppointname varchar, bearing varchar, distance float, distanceinmiles float, distancefromstop VARCHAR,<br>               IncidentDescription VARCHAR, recordedattime VARCHAR, ESTIMATEDPASSENGERCOUNT VARCHAR,<br>               ESTIMATEDPASSENGERCAPACITY VARCHAR, arrivalproximitytext VARCHAR, NUMBEROFSTOPSAWAY VARCHAR, TS VARCHAR)<br>LANGUAGE SQL<br>EXECUTE AS OWNER<br>AS <br>DECLARE<br>  res RESULTSET;<br>BEGIN<br>  res := ( SELECT VEHICLEREF as bus, destinationname, <br>         expectedarrivaltime,<br>         EXPECTEDDEPARTURETIME, stoppointname, bearing,HAVERSINE( VEHICLELOCATIONLATITUDE, VEHICLELOCATIONLONGITUDE, :YOURLATITUDE, <br>         :YOURLONGITUDE ) as distance, <br>         (ST_DISTANCE(ST_MAKEPOINT(VEHICLELOCATIONLATITUDE,VEHICLELOCATIONLONGITUDE), ST_MAKEPOINT(:YOURLATITUDE,:YOURLONGITUDE))/1609) as distanceinmiles,<br>         distancefromstop,SITUATIONSIMPLEREF1 as IncidentDescription, <br>      recordedattime, ESTIMATEDPASSENGERCOUNT, <br>      ESTIMATEDPASSENGERCAPACITY, <br>      arrivalproximitytext,<br>      NUMBEROFSTOPSAWAY, <br>      TS <br>  FROM icymta<br>  WHERE DISTANCEFROMSTOP &gt; 0<br>  ORDER BY distance ASC);<br>  RETURN TABLE(res);<br>END;<br><br><br><br>call RETURN_MTA_NEARBY(&#39;40.3209&#39;,&#39;-74.4208&#39;);</pre><p><strong>Geodistance SQL against Apache Iceberg Table</strong></p><pre><br>select latitude, longitude, <br>       HAVERSINE( LATITUDE, LONGITUDE, 40.268198428571424,-74.52865042857142 ) as distancefromtiminkm, <br>         flight, planeid, track, navqnh, gs, navaltitudemcp, navicationintegrityforbarometricaltitude, navigationaccuracyforposition, navheading, altbaro, altgeom,<br>         seen, track, barorate, ts <br>from planes<br>where longitude is not null and latitude is not null<br>and LENGTH(TRIM(longitude)) &gt; 0 and LENGTH(TRIM(latitude)) &gt; 0<br>order by ts desc;</pre><p>Let’s query our Transcom Table</p><pre>SELECT TITLE, DESCRipTION, PUBDATE, LATITUDE, LONGITUDE,<br>       HAVERSINE( LATITUDE, LONGITUDE, 40.268198428571424,-74.52865042857142 ) as distancefromtiminkm,<br>       (ST_DISTANCE(ST_MAKEPOINT(LATITUDE,LONGITUDE), ST_MAKEPOINT(40.268198428571424,-74.52865042857142))/1609) as distanceinmiles<br>FROM DEMO.ICYTRANSCOME i <br>where longitude is not null and latitude is not null<br>and LENGTH(TRIM(longitude)) &gt; 0 and LENGTH(TRIM(latitude)) &gt; 0<br>ORDER BY i.PUBDATE DESC,   i.&quot;TS&quot; DESC;</pre><p><strong>Storing Apache Iceberg Tables in S3</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uj5sBnBFEijoYZqI3VzsYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNpYDpuG2AYIPRYXbC3NoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6PcBNDoQY9yku8Otm8T1Eg.jpeg" /></figure><h3>Distributing Data via Kafka API</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2mCiV4puHCyW56hXVIaNpA.png" /></figure><p><strong>Unstructured Document Source</strong></p><p><a href="https://github.com/tspannhw/documents">GitHub - tspannhw/documents: Documents</a></p><p><strong>Source Code</strong></p><p><a href="https://github.com/sfc-gh-tspann/DataAIDemos">GitHub - sfc-gh-tspann/DataAIDemos: Data and AI Demos</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-M2F_LBTdTP7wYZJWRCVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*3BmSamOzNO-bbycnMSEkjA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9395a30a2d4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real-Time Enrichment of Air Quality Data]]></title>
            <link>https://medium.com/@tim.spann_50517/real-time-enrichment-of-air-quality-data-26564464b2a5?source=rss-44aa222039a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/26564464b2a5</guid>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[apache-nifi]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Tim Spann]]></dc:creator>
            <pubDate>Mon, 07 Apr 2025 21:30:21 GMT</pubDate>
            <atom:updated>2025-04-07T21:30:21.355Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache NiFi, Apache Iceberg, AI, S3, LLM, Python, REST</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M3mRAZoUm0xaBIa6uYblvA.png" /></figure><p>I am building up some complete systems now that I have access to a full Open Lakehouse platform. One of the first things I wanted to manage is all the things and their data the surround me in real-time. This is the data of the real, things like air quality, temperature, subway cars, buses, trains, planes, groceries, robots, fires, chaos and news. Let’s dive into capturing the data that is happening now. We will start with air quality readings.</p><p>The first tool in our toolbox is Apache NiFi, it let’s us explore, examine, ingest, enrich, transform, route and deliver almost anything. This is a good first try, usually it is the answer though sometimes we need to write code in Python, Java, Go or perhaps pick another tool for specialty deliver. What NiFi excels at is ingesting data regardless of the size, type, flavor and origin. So I can grab an XML file from an sFTP server, a PDF from Dropbox, an image from S3, CSV from a REST server, JSON from a websocket provider and records from databases. All of this without knowing the size, amount or fields of the data. If you have a schema, things are simpler and can be verified against known formats, data types and known data parameters. If you don’t know that, or don’t know that yet, we can still ingest, enrich and transform automatically as if we knew. NiFi is great at determining what it is. If the data doesn’t change or isn’t that sparse we can take a sample and make a version of schema and store that in any schema registry. If we don’t have one, we can use the basic one embeded in NiFi. If a new version comes we will automatically work with that one.</p><p>For this use case we have a REST feed from AirNow the U.S. Air Quality Index, if you are reading this in the future this agency and it’s feed may no longer exist. We can adapt this to private feeds or open air quality readings from other countries. Please lead a comment if you are from the future and that has already happened. In our design, past Tim has already contemplated this. In NiFi we can use parameters to swap out values of URLs, secret values and other variable entries independent of the code. As you will see, it’s also really easy to change your NiFi flows. They are all drag and drop from a pallets of so many great sources, sinks and enrichment processors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ozuYruSKZYgm23uHGPH-GQ.png" /><figcaption>Download CSV of US Zip Codes, Insert into Snowflake</figcaption></figure><p>In the first bit of flow, we need a list of Zip Codes to pass in to the REST end point to retrieve Air Quality readings for those areas. For basic testing, I have a hard coded list of popular large zip codes. For the above code I download an open source of US Zip codes as a CSV file and load it into a Snowflake Native table in one step.</p><h3>Flow Analysis</h3><p><strong>InvokeHTTP</strong> — Call an HTTP endpoint, especially REST.</p><p><strong>PutDatabaseRecord</strong> — Use existing Database Connection Pool and send our structured records to the database. I picked <strong>INSERT</strong>, if you are using a database that likes <strong>UPSERT</strong> you can pick that.</p><p><strong>— — (side flow) — —</strong></p><p><strong>SplitRecord — </strong>parse our records into individual records</p><p><strong>EvaluateJsonPath — -</strong>extract the Zip code value (there’s others in the file)</p><h3>Two Steps to Load Zip Codes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQcQ5l1I4w0Qg2fkO47R5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BqqldnV0WLfmlgSv9CbFkQ.png" /></figure><p>We created a quick SQL table in Snowflake to receive our zip code data and had it inserted in a second from my NiFi instance running on my laptop. NiFi can scale from laptop to 1,000 server cluster in a data center.</p><p>So Tim, what can’t NiFi do? Well I don’t know, haven’t found something it couldn’t do it. But here is a list of things you can do with code, videos, cats and articles:</p><p><a href="https://medium.com/@tspann/yes-apache-nifi-can-do-that-c7fcaca5a177">Yes Apache NiFi Can Do That</a></p><p>So why did I load all the zip codes? Now I can feed my process with a list of all the current US zip codes with a simple query.</p><h3>Use Snowflake Native Table to Populate Zipcode List</h3><pre>select zipcode from zipcodes order by state asc;</pre><p><strong>Enhancement thought:</strong> Some zip codes may not have air quality readings or could be quiet isolated. We can either add a flag to disable them or delete them from the dataset. What do you think? Choose your own data adventure.</p><h3>NiFi To Iceberg Tables</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VdiU3DHO-wCnKGYVoRFVGg.png" /></figure><h3>Load Apache Iceberg Tables</h3><p>So there are two options for data from AirNow, we can grab air quality as it is now or get a forecast. So we grab both and store them in separate tables. They have a lot of data in common, we could have made one wider table and decided how to combine them. This combination could have happened during the flow in NiFi, in SQL or later.</p><p><strong>Enhancement thought: </strong>Let me know what you think, should we just have one table or a different design.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*32MGvzys8QTHj1oI1puklw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpWLx-fdruJnWEJdrMzUgw.png" /></figure><p>We have two flows as input. First is from a fixed list of Zip Codes.</p><pre>[{&quot;zipcode&quot;:&quot;08520&quot;},<br>{&quot;zipcode&quot;:&quot;08701&quot;},<br>{&quot;zipcode&quot;:&quot;07002&quot;},<br>{&quot;zipcode&quot;:&quot;79936&quot;},<br>{&quot;zipcode&quot;:&quot;60629&quot;},<br>{&quot;zipcode&quot;:&quot;11368&quot;},<br>{&quot;zipcode&quot;:&quot;77449&quot;},<br>{&quot;zipcode&quot;:&quot;94123&quot;},<br>{&quot;zipcode&quot;:&quot;10007&quot;},<br>{&quot;zipcode&quot;:&quot;10013&quot;},<br>{&quot;zipcode&quot;:&quot;90272&quot;},<br>{&quot;zipcode&quot;:&quot;90265&quot;},<br>{&quot;zipcode&quot;:&quot;07070&quot;},<br>{&quot;zipcode&quot;:&quot;94301&quot;},<br>{&quot;zipcode&quot;:&quot;90402&quot;},<br>{&quot;zipcode&quot;:&quot;94957&quot;},<br>{&quot;zipcode&quot;:&quot;11962&quot;},<br>{&quot;zipcode&quot;:&quot;02199&quot;},<br>{&quot;zipcode&quot;:&quot;94027&quot;},<br>{&quot;zipcode&quot;:&quot;75034&quot;}]</pre><ul><li><strong>GenerateFlowFile</strong> — above list</li><li><strong>SplitJson</strong> — $.*</li></ul><p><strong>Second option:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*UYh0U4hAjTv0B6UC5X0CUA.png" /></figure><ul><li><strong>ExecuteSQLRecord</strong> — <em>select zipcode from zipcodes order by state asc;</em></li><li><strong>SplitRecord</strong> — split into individual records</li></ul><p>Regardless of which source, we send either one into the next section.</p><ul><li>EvaluateJsonPath — Extract <strong>$.zipcode</strong></li></ul><p>We then have to output paths, one for AirNow API Forecast and Air Now API Observations.</p><ul><li><strong>UpdateAttribute</strong> — <strong>dateToDo</strong> — ${now():format(‘yyyy-MM-dd’)}</li><li><strong>InvokeHTTP</strong> — <a href="https://www.airnowapi.org/aq/forecast/zipCode/?format=application/xml&amp;zipCode=${ZIPCODE}&amp;date=${dateToDo}&amp;distance=25&amp;API_KEY=#{api_key">https://www.airnowapi.org/aq/forecast/zipCode/?format=application/xml&amp;zipCode=${ZIPCODE}&amp;date=${dateToDo}&amp;distance=25&amp;API_KEY=#{api_key</a>}</li><li><strong>UpdateAttribute</strong> — we set <strong>TABLE_NAME</strong>=AQFORECAST, <strong>SCHEMA_NAME</strong>=DEMO, <strong>DATABASE_NAME</strong>=DEMO</li><li><strong>RouteOnContent</strong> — skip empty data via <strong>&lt;DataList&gt;No data&lt;/DataList&gt;</strong></li><li><strong>UpdateRecord</strong> — XMLReader, JsonRecordSetWriter. /<strong>ts</strong> = ${now():toNumber()}; /<strong>uuid</strong>=${uuid}</li><li><strong>MergeRecord</strong> — Merge 1,000+ records in a 30 second batch</li></ul><p>The main current airnow flow is:</p><ul><li><strong>InvokeHTTP</strong> — <a href="https://www.airnowapi.org/aq/observation/zipCode/current/?format=text/csv&amp;distance=250&amp;zipCode=${ZIPCODE}&amp;API_KEY=#{api_key">https://www.airnowapi.org/aq/observation/zipCode/current/?format=text/csv&amp;distance=250&amp;zipCode=${ZIPCODE}&amp;API_KEY=#{api_key</a>}</li><li><strong>RouteOnAttribute</strong> — throw away small files. ${fileSize:lt(25)}</li><li><strong>UpdateAttribute</strong> — we set <strong>TABLE_NAME</strong>=AQ, <strong>SCHEMA_NAME</strong>=DEMO, <strong>DATABASE_NAME</strong>=DEMO</li><li><strong>UpdateRecord</strong> — CSVReader, JsonRecordSetWriter. /<strong>ts</strong> = ${now():toNumber()}; /<strong>uuid</strong>=${uuid}</li><li><strong>RouteOnAttribute</strong> — throw away small files. ${fileSize:gt(8)}</li><li><strong>MergeRecord</strong> — Merge 1,000+ records in a 30 second batch</li></ul><p>Then we have one single flow:</p><ul><li><strong>PutDatabaseRecord</strong> — JsonTreeReader, INSERT, Iceberg Connection Pool, ${SCHEMA_NAME}, ${TABLE_NAME}, 5000 Maximum Batch Size.</li><li><strong>RetryFlowFile</strong> — if we fail, retry three times.</li><li><strong>PublishSlack</strong> — Send text to #general channel with FlowFile Content as Attachment.</li></ul><h3><strong>AQFORECAST</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vq4-_59Df19hmTEnlyJfgw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VX-RwV21_wx42UOdzqXEBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kLp5V1vCa-cLvqYV0Uu9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5fRY9FG155b6-vsfcU0wSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*28SRgUuNBlmEhx7aCQegWA.png" /></figure><h3>AQ (Air Quality) Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*209JiDa3LXdGg9N2qe3EGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-fKWIXS5Y49Wu5UnuZ-Ng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*j9XHHvKKdEHkHAvG91olZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*tC1-mGNmL-fcA4m51_FqfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3jhQEcPR8N27tAtIfH-Ww.png" /><figcaption>Recent Data</figcaption></figure><h3>Apache Iceberg as Apache Parquet Files under Cloud Storage (AWS S3)</h3><p>For our Air Quality and Air Quality Forecast table we created and stored them in Cloud Storage. For queries and inserts, it looked no difference to NiFi or to our code. But we can look under the covers and see Icebergs data late out, metadata files and data files as Apache Parquet. This physical storage of files can highlight the small file problem we were thinking of when we merged those files into bigger chunks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_4s9pvhImnuIrS8bWbg7fw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7UNfDpLADC8qPU01zTi3g.png" /></figure><h3>Output to Slack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kf10qanfEaYri_4OPDfaTg.png" /></figure><h3>RESOURCES</h3><p><a href="https://github.com/sfc-gh-tspann/DataAIDemos/blob/main/airquality.sql">DataAIDemos/airquality.sql at main · sfc-gh-tspann/DataAIDemos</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gfg3zQS3sPllb7f4lWgdzQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26564464b2a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>