<?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 Mubashir Masood on Medium]]></title>
        <description><![CDATA[Stories by Mubashir Masood on Medium]]></description>
        <link>https://medium.com/@mubashir.masood?source=rss-c5060c3bd806------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jBlNeqEcvxhr3iy_uznbmQ.jpeg</url>
            <title>Stories by Mubashir Masood on Medium</title>
            <link>https://medium.com/@mubashir.masood?source=rss-c5060c3bd806------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:27:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mubashir.masood/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[From 1.1 Million Filings to Real-Time Investment Intelligence: Building a 100M-Chunk Document…]]></title>
            <link>https://medium.com/snowflake/from-1-1-million-filings-to-real-time-investment-intelligence-building-a-100m-chunk-document-f1f4bd23d0a1?source=rss-c5060c3bd806------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1f4bd23d0a1</guid>
            <category><![CDATA[cortex-analyst]]></category>
            <category><![CDATA[cortex-search]]></category>
            <category><![CDATA[cortex-agent]]></category>
            <category><![CDATA[snowflake-ai]]></category>
            <dc:creator><![CDATA[Mubashir Masood]]></dc:creator>
            <pubDate>Thu, 07 May 2026 19:01:02 GMT</pubDate>
            <atom:updated>2026-05-07T19:01:02.122Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>From 1.1 Million Filings to Real-Time Investment Intelligence: Building a 100M-Chunk Document Pipeline on Snowflake</strong></h3><p><em>How can a leading investment firm build a fully managed, Python/SQL-native AI pipeline over the entire SEC EDGAR corpus</em></p><h4><strong>The Problem: Unstructured Documents Are an Untapped Alpha Source</strong></h4><p>Every publicly traded company in the United States files detailed reports with the SEC. Annual reports (10-K), quarterly updates (10-Q), material event disclosures (8-K) — the EDGAR database contains over a million filings stretching back decades. These documents are dense with signal: risk factor disclosures, management commentary on revenue trends, supply chain warnings buried in footnotes, and liquidity concerns hidden inside MD&amp;A prose.</p><p>The problem is getting to that signal at scale. Traditional keyword search falls flat on financial language. Vector search systems require standing up and maintaining a separate infrastructure stack. And LLM APIs hit context limits long before you can feed them a 10-K cover-to-cover.</p><p>Any quantitative investment manager firm can tackle this by building an end-to-end document intelligence pipeline entirely within Snowflake — ingesting the full EDGAR catalog, extracting structured investment signals, embedding 106 million text chunks into a vector+BM25 hybrid search service, and deploying an autonomous research agent accessible via REST API. All without leaving SQL or spinning up a single external service.</p><p>This article walks through every layer of that pipeline: the architecture, the code, the AI capabilities, and the tradeoffs.</p><h4><strong>Architecture: Six Layers, Zero External Infrastructure</strong></h4><p>The pipeline flows through six distinct layers, each built on native Snowflake primitives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sRBXUemDtsdxNybllf6cww.png" /></figure><p>Each layer hands off to the next via standard Snowflake objects — tables, UDFs, views, Cortex Search services, and Cortex Agents. The entire system is defined in DDL you can version-control and recreate from scratch.</p><h3><strong>Step 1: Ingesting the EDGAR Corpus at Scale</strong></h3><h4><strong>Building the Filing Index</strong></h4><p>The pipeline starts with a metadata catalog. Rather than downloading raw filings blindly, the first step populates `FILING_INDEX` from the EDGAR full-text search API — capturing accession number, CIK, company name, ticker, form type, and filing date for every available filing.</p><pre>-- sql FILING_INDEX schema (core fields)<br>CREATE OR REPLACE TABLE POC.UDI.FILING_INDEX (<br>ACCESSION_NO VARCHAR NOT NULL,<br>CIK VARCHAR,<br>COMPANY_NAME VARCHAR,<br>TICKER VARCHAR,<br>FORM_TYPE VARCHAR,<br>FILED_AT TIMESTAMP_NTZ,<br>DOWNLOADED_AT TIMESTAMP_NTZ,<br>PERIOD_OF_REPORT DATE<br>);</pre><p>The result: <strong>1,118,447 rows</strong> covering 10-K, 10-Q, and 8-K filings from 2015 to 2023, spanning thousands of unique companies. The `FILED_AT` column comes directly from EDGAR’s authoritative index; it is never LLM-inferred, which matters when signals need to be tied to a provable timestamp.</p><h4><strong>Downloading and Chunking at 100M Scale</strong></h4><p>Downloading actual filing text happens through a stored procedure, DOWNLOAD_FILING_BATCH(), which fetches HTML/SGML documents from <a href="https://www.sec.gov/Archives/edgar/full-index/">https://www.sec.gov/Archives/edgar/full-index/</a> and stores cleaned text in FILING_CONTENT.</p><p>The more interesting engineering is in CHUNK_FILING() a UDF that splits each filing into <strong>section-aware chunks</strong>:</p><pre>python <br>def chunk_filing(text: str, target_size: int = 3600) -&gt; list[dict]:<br>&quot;&quot;&quot;<br>Split an EDGAR filing into chunks that respect Item boundaries.<br>Preserves which SEC Item each chunk belongs to:<br>- Item 1A (Risk Factors)<br>- Item 7 (MD&amp;A)<br>- Item 7A (Quantitative/Qualitative Disclosures About Market Risk)<br>- Item 8 (Financial Statements)<br>… etc.<br>&quot;&quot;&quot;</pre><p>Why section-awareness matters: a chunk from “Item 1A — Risk Factors” is fundamentally different from a chunk from “Item 7 — MD&amp;A,” even if they discuss the same topic. Preserving `SECTION_NAME` in every chunk means search results can be filtered by SEC Item, and the agent always knows the structural context of a retrieved passage.</p><p>The final FILING_CHUNKS table holds <strong>106,494,839 rows</strong> at a target chunk size of 3,600 characters. Each row carries:</p><pre>| Column | Description |<br>| `ACCESSION_NO` | Parent filing identifier |<br>| `COMPANY_NAME` | Issuer name |<br>| `TICKER` | Exchange ticker |<br>| `FORM_TYPE` | 10-K / 10-Q / 8-K |<br>| `FILED_AT` | Authoritative EDGAR filing date |<br>| `SECTION_NAME` | SEC Item (e.g. &quot;Risk Factors&quot;) |<br>| `CHUNK_TEXT` | Up to 3,600 chars of clean prose |<br>| `CHUNK_INDEX` | Position within the filing |</pre><h3><strong>Step 2: AI Signal Extraction with AI_EXTRACT</strong></h3><p>Before embedding 106 million chunks for search, the pipeline runs a structured extraction pass over the downloaded filings using Snowflake’s AI_EXTRACT function (powered by the `arctic-extract` model). The goal: turn unstructured 10-K prose into queryable investment signals.</p><pre>INSERT INTO FILING_SIGNALS<br>SELECT<br>s.ACCESSION_NO,<br>fi.COMPANY_NAME,<br>fi.TICKER,<br>fi.FORM_TYPE,<br>fi.FILED_AT AS SIGNAL_DATE,<br>fi.PERIOD_OF_REPORT,<br>ext.SENTIMENT,<br>ext.EVENT_TYPE,<br>ext.INDUSTRY,<br>ext.RISK_FLAGS,<br>ext.KEY_METRICS,<br>ext.SUMMARY AS SUMMARY,<br>ext.MATERIAL_ITEMS,<br>&#39;arctic-extract&#39; AS EXTRACTION_MODEL<br>FROM FILING_CONTENT s<br>JOIN FILING_INDEX fi ON s.ACCESSION_NO = fi.ACCESSION_NO<br>CROSS JOIN LATERAL (<br>SELECT AI_EXTRACT(<br>s.CONTENT_TEXT,<br>{<br>&#39;SENTIMENT&#39;: &#39;Overall sentiment: POSITIVE, NEGATIVE, NEUTRAL, or MIXED&#39;,<br>&#39;EVENT_TYPE&#39;: &#39;Primary event type (earnings, M&amp;A, regulatory, litigation, etc.)&#39;,<br>&#39;INDUSTRY&#39;: &#39;GICS industry sector&#39;,<br>&#39;RISK_FLAGS&#39;: &#39;Array of material risk themes explicitly mentioned&#39;,<br>&#39;KEY_METRICS&#39;: &#39;Object with key financial metrics if mentioned&#39;,<br>&#39;MATERIAL_ITEMS&#39;: &#39;Array of SEC Item numbers with material disclosures&#39;<br>}<br>) AS ext<br>);</pre><p>The output is <strong>64,045 signals</strong> stored in FILING_SIGNALS, each tagged with a structured schema that lets analysts run aggregated queries that would be impossible against raw text:</p><p><em>Which industries had the most negative sentiment in 2022 10-Ks?</em></p><pre><br>SELECT INDUSTRY, COUNT(*) AS negative_signals<br>FROM FILING_SIGNALS<br>WHERE SENTIMENT = &#39;NEGATIVE&#39;<br>AND FORM_TYPE = &#39;10-K&#39;<br>AND YEAR(SIGNAL_DATE) = 2022<br>GROUP BY INDUSTRY<br>ORDER BY negative_signals DESC;</pre><p><em>What risk flags appeared most often across all filings?</em></p><pre>SELECT f.VALUE::VARCHAR AS risk_flag, COUNT(*) AS occurrences<br>FROM FILING_SIGNALS,<br>LATERAL FLATTEN(INPUT =&gt; RISK_FLAGS) f<br>WHERE f.VALUE IS NOT NULL<br>GROUP BY 1<br>ORDER BY 2 DESC<br>LIMIT 15;</pre><p>The SIGNAL_DATE column is always FILED_AT from FILING_INDEX the date the company submitted the disclosure to the SEC. This prevents any look-ahead bias when signals are used in time-series analysis.</p><h3><strong>Step 3: Cortex Search — Vector + BM25 + Reranking at 100M Scale</strong></h3><h4><strong>Creating the Search Service</strong></h4><p>With 106M chunks in FILING_CHUNKS, creating the Cortex Search service is a single DDL statement:</p><pre>CREATE OR REPLACE CORTEX SEARCH SERVICE POC.UDI.EDGAR_SEARCH<br>ON CHUNK_TEXT<br>ATTRIBUTES COMPANY_NAME, TICKER, FORM_TYPE, SECTION_NAME, FILED_AT<br>WAREHOUSE = UDI_WH<br>TARGET_LAG = &#39;1 day&#39;<br>AS<br>SELECT<br>CHUNK_TEXT,<br>COMPANY_NAME,<br>TICKER,<br>FORM_TYPE,<br>SECTION_NAME,<br>FILED_AT<br>FROM POC.UDI.FILING_CHUNKS;</pre><p>Snowflake handles everything from this point: embedding each chunk with `snowflake-arctic-embed-m-v1.5` (768-dimensional dense vectors), building the BM25 sparse index, constructing the HNSW graph for approximate nearest-neighbor search, and incrementally refreshing the index as new chunks arrive. The service moves to ACTIVE state once the initial build completes.</p><p>At 106 million rows, the initial embedding pass consumed approximately <strong>3,994 credits</strong> a one-time cost for the full index build.</p><h4><strong>Querying the Service from Python</strong></h4><p>The Python SDK exposes a clean interface:</p><pre>from snowflake.core import Root<br>import time<br>root = Root(session)<br>search = root.databases[&#39;POC&#39;].schemas[&#39;UDI&#39;].cortex_search_services[&#39;EDGAR_SEARCH&#39;]<br>def edgar_search(<br>query: str,<br>limit: int = 5,<br>form_type: str = None,<br>ticker: str = None,<br>rerank: bool = True<br>) -&gt; list[dict]:<br>&quot;&quot;&quot;<br>Query EDGAR_SEARCH. Returns chunks ranked by hybrid<br>vector + BM25 score, with optional cross-encoder reranking.<br>&quot;&quot;&quot;<br>kwargs = dict(<br>query=query,<br>columns=[&#39;COMPANY_NAME&#39;, &#39;TICKER&#39;, &#39;FORM_TYPE&#39;,<br>&#39;SECTION_NAME&#39;, &#39;FILED_AT&#39;, &#39;CHUNK_TEXT&#39;],<br>limit=limit<br>)<br>if form_type:<br>kwargs[&#39;filter&#39;] = {&#39;@eq&#39;: {&#39;FORM_TYPE&#39;: form_type}}<br>if ticker:<br>kwargs[&#39;filter&#39;] = {&#39;@eq&#39;: {&#39;TICKER&#39;: ticker}}<br>if not rerank:<br>kwargs[&#39;scoring_config&#39;] = {&#39;reranker&#39;: &#39;none&#39;}<br>return search.search(**kwargs).results</pre><p>Usage examples:</p><pre># Find 10-K risk disclosures about supply chain concentration<br>results = edgar_search(<br>&#39;supply chain disruptions tariffs China concentration risk&#39;,<br>limit=5,<br>form_type=&#39;10-K&#39;<br>)</pre><pre># Search within a specific company<br>results = edgar_search(<br>&#39;liquidity credit facility covenant compliance&#39;,<br>limit=3,<br>ticker=&#39;PM&#39;<br>)</pre><h4><strong>The Reranking Trade-off</strong></h4><p>Cortex Search applies a three-stage scoring pipeline by default:</p><ol><li><strong>Vector retrieval </strong>approximate nearest-neighbor search using the HNSW index over 768-dim embeddings</li><li><strong>BM25 re-scoring </strong>keyword frequency scoring to catch exact term matches</li><li><strong>Cross-encoder reranking </strong>a neural model that re-reads query + candidate pair jointly for highest precision</li></ol><p>The cross-encoder is the most expensive step. For latency-sensitive workloads, you can disable it:</p><pre># Skip cross-encoder reranking - lower latency, ordering may differ<br>results = edgar_search(query, rerank=False)<br># Equivalent to:<br># kwargs[&#39;scoring_config&#39;] = {&#39;reranker&#39;: &#39;none&#39;}</pre><pre>Mode | Scoring pipeline | When to use |<br>| `rerank=True` (default) | vector + BM25 + cross-encoder | Highest result quality; research workflows ~ 480 ms|<br>| `rerank=False` | vector + BM25 only | Real-time applications; latency budget &lt; 200ms |</pre><p>The right choice depends on your workload. Evaluate side-by-side on representative queries before disabling reranking in production and result <em>*ordering*</em> can shift even when the underlying candidate set is similar.</p><h3><strong>Step 4: Agentic Q&amp;A with Cortex Agents</strong></h3><h4><strong>Defining the Agent</strong></h4><p>The `EDGAR_ANALYST` Cortex Agent sits at the top of the stack, combining semantic search with structured signal analytics. It has two tools:</p><pre>CREATE OR REPLACE CORTEX AGENT POC.UDI.EDGAR_ANALYST<br>COMMENT = &#39;Investment research agent over 106M EDGAR filing chunks and 64K signals&#39;<br>TOOLS = (<br>TOOL_TYPE = CORTEX_SEARCH<br>SERVICE = POC.UDI.EDGAR_SEARCH<br>NAME = &#39;edgar_search&#39;<br>DESCRIPTION = &#39;Semantic search over 106M SEC filing chunks. Use for qualitative<br>research, risk factor analysis, MD&amp;A text, earnings commentary.&#39;,<br>TOOL_TYPE = CORTEX_ANALYST<br>SEMANTIC_MODEL = &#39;@POC.UDI.MODELS/edgar_view.yaml&#39;<br>NAME = &#39;edgar_analytics&#39;<br>DESCRIPTION = &#39;Structured analytics over FILING_SIGNALS (64K signals).<br>Use for aggregations, sentiment counts, industry breakdowns,<br>ticker-level historical signal queries.&#39;<br>);</pre><p>The agent selects which tool to invoke — or whether to invoke both — based on the nature of each question. A question about “supply chain risk trends across industrials companies in 2022” might trigger the structured analytics tool first, then use semantic search to pull supporting verbatim passages.</p><h4><strong>Calling the Agent via REST API</strong></h4><p>The Cortex Agent REST API streams responses as Server-Sent Events. Here is the complete Python client:</p><pre>import requests<br>import json<br>def ask_edgar_agent(question: str, instruction: str = None) -&gt; str:<br>&quot;&quot;&quot;Call EDGAR_ANALYST via the Cortex Agent REST API (SSE stream).&quot;&quot;&quot;<br>conn = session.connection<br>token = conn.rest.token<br>host = f&#39;https://{conn.host}&#39;<br>url = f&#39;{host}/api/v2/databases/POC/schemas/UDI/agents/EDGAR_ANALYST/runs&#39;<br>body = {<br>&#39;response_instruction&#39;: (<br>instruction or<br>&#39;Be concise. Always cite company name, ticker, form type, and filing date.&#39;<br>),<br>&#39;messages&#39;: [<br>{&#39;role&#39;: &#39;user&#39;, &#39;content&#39;: [{&#39;type&#39;: &#39;text&#39;, &#39;text&#39;: question}]}<br>]<br>}<br>headers = {<br>&#39;Authorization&#39;: f&#39;Snowflake Token=&quot;{token}&quot;&#39;,<br>&#39;Content-Type&#39;: &#39;application/json&#39;,<br>&#39;Accept&#39;: &#39;application/json&#39;,<br>&#39;X-Snowflake-Authorization-Token-Type&#39;: &#39;KEYPAIR_JWT&#39;<br>}<br>resp = requests.post(url, headers=headers, json=body, stream=True, timeout=180)<br>resp.raise_for_status()<br>parts = []<br>for line in resp.iter_lines():<br>raw = line.decode(&#39;utf-8&#39;) if isinstance(line, bytes) else line<br>if not raw.startswith(&#39;data:&#39;):<br>continue<br>payload = raw[5:].strip()<br>if payload in (&#39;[DONE]&#39;, &#39;&#39;):<br>continue<br>try:<br>for evt in json.loads(payload).get(&#39;events&#39;, []):<br>if evt.get(&#39;event_type&#39;) == &#39;message.delta&#39;:<br>for part in evt[&#39;data&#39;][&#39;delta&#39;][&#39;content&#39;]:<br>if part.get(&#39;type&#39;) == &#39;text&#39;:<br>parts.append(part.get(&#39;text&#39;, &#39;&#39;))<br>except json.JSONDecodeError:<br>pass<br>return &#39;&#39;.join(parts).strip()</pre><h3><strong>Example</strong></h3><h4>Example 1:</h4><pre>q = &#39;What supply chain and geopolitical risks were most frequently cited in 2022–2023 10-K filings?&#39;<br>print(ask_edgar_agent(q))</pre><p>Results:</p><pre>&gt; *Based on 2022–2023 10-K filings: the most frequent supply chain risks cited were (1) China<br>&gt; manufacturing concentration and export control exposure - mentioned by 847 companies including<br>&gt; Apple (AAPL, 10-K, 2023–11–03) and Qualcomm (QCOM, 10-K, 2022–11–02); (2) semiconductor<br>&gt; component shortages and extended lead times - especially in automotive and industrial sectors;<br>&gt; (3) Russia/Ukraine conflict logistics disruptions, most prominent in energy and materials<br>&gt; companies including Exxon (XOM, 10-K, 2023–02–22).*</pre><h4>Example 2:</h4><pre>q = &#39;Which companies had the most negative sentiment signals and what were their primary risks?&#39;<br>print(ask_edgar_agent(q))</pre><p>Results:</p><pre>&gt; *Top negative-sentiment companies by signal count: (1) SVB Financial Group (SIVB) - 8 negative<br>&gt; signals, primarily interest rate risk and deposit concentration; (2) First Republic Bank (FRC)<br>&gt; - 6 negative signals, liquidity and held-to-maturity securities; (3) Bed Bath &amp; Beyond (BBBY)<br>&gt; - 5 negative signals, going concern and supply chain. All signals sourced from FILING_SIGNALS<br>&gt; with SIGNAL_DATE between 2022–01–01 and 2023–03–31.*</pre><p>The agent handles both styles of question, open-ended qualitative research and structured aggregation, by selecting the appropriate tool at inference time.</p><h4><strong>Access Control: Least-Privilege RBAC</strong></h4><p>The pipeline ships with a dedicated role granting scoped access to all POC.UDI objects:</p><pre>CREATE ROLE IF NOT EXISTS EDGAR_ANALYST_RL;<br>GRANT USAGE ON WAREHOUSE UDI_WH TO ROLE EDGAR_ANALYST_RL;<br>GRANT USAGE ON DATABASE POC TO ROLE EDGAR_ANALYST_RL;<br>GRANT USAGE ON SCHEMA POC.UDI TO ROLE EDGAR_ANALYST_RL;<br> - Tables<br>GRANT SELECT ON TABLE POC.UDI.FILING_INDEX TO ROLE EDGAR_ANALYST_RL;<br>GRANT SELECT ON TABLE POC.UDI.FILING_CHUNKS TO ROLE EDGAR_ANALYST_RL;<br>GRANT SELECT ON TABLE POC.UDI.FILING_SIGNALS TO ROLE EDGAR_ANALYST_RL;<br>GRANT SELECT ON TABLE POC.UDI.FILING_CONTENT TO ROLE EDGAR_ANALYST_RL;<br> - Views<br>GRANT SELECT ON VIEW POC.UDI.V_PIPELINE_STATUS TO ROLE EDGAR_ANALYST_RL;<br>GRANT SELECT ON VIEW POC.UDI.V_INGESTION_STATUS TO ROLE EDGAR_ANALYST_RL;<br> - AI services<br>GRANT USAGE ON CORTEX SEARCH SERVICE POC.UDI.EDGAR_SEARCH TO ROLE EDGAR_ANALYST_RL;<br>GRANT USAGE ON CORTEX AGENT POC.UDI.EDGAR_ANALYST TO ROLE EDGAR_ANALYST_RL;<br>GRANT ROLE EDGAR_ANALYST_RL TO ROLE SYSADMIN;</pre><p>Analysts get full read access to every pipeline artifact tables, views, the Cortex Search service, and the Cortex Agent without needing ACCOUNTADMIN or direct warehouse grants beyond UDI_WH.</p><h4><strong>What This Generalizes To</strong></h4><p>SEC EDGAR is one corpus. The pattern works for any large collection of unstructured documents where you need:</p><ul><li><strong>Fast iterative text search</strong> over hundreds of millions of passages</li><li><strong>Structured signal extraction</strong> from prose into queryable fields</li><li><strong>Agentic research</strong> that combines semantic retrieval with analytical aggregation</li></ul><p>The same architecture applies to:</p><ul><li><strong>Legal:</strong> contract repositories, regulatory filings, litigation records</li><li><strong>Healthcare:</strong> clinical notes, patient records, insurance claims</li><li><strong>Enterprise:</strong> internal knowledge bases, support ticket corpora, engineering incident post-mortems</li><li><strong>News/Research:</strong> financial news archives, analyst reports, central bank communications</li></ul><p>The core Snowflake primitives `AI_EXTRACT`, `CORTEX SEARCH SERVICE`, `CORTEX AGENT` are corpus-agnostic. Swap `CHUNK_FILING()` for a domain-appropriate splitter, change the extraction schema in `AI_EXTRACT`, and the rest of the pipeline transfers directly.</p><h3><strong>Conclusion</strong></h3><p>Building document intelligence at this scale used to mean assembling a stack of specialized systems: a document loader, a vector database, an embedding service, a reranking API, an LLM gateway, and glue code to hold it all together. Each seam is a failure mode, a latency budget, and an ops burden.</p><p>The pipeline described here runs entirely within Snowflake. Data lives where it always lived — in tables, with full SQL access, governed by existing RBAC. AI capabilities are native services, not external APIs to integrate and monitor. The agent is a DDL object, not a Python application to deploy and scale.</p><p>At 106 million chunks, the pipeline delivers sub-second hybrid search with optional neural reranking, structured signal extraction accurate enough to power aggregated cross-corpus queries, and an autonomous research agent that synthesizes both.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1f4bd23d0a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/from-1-1-million-filings-to-real-time-investment-intelligence-building-a-100m-chunk-document-f1f4bd23d0a1">From 1.1 Million Filings to Real-Time Investment Intelligence: Building a 100M-Chunk Document…</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Power of Data with Snowpark and Snowflake]]></title>
            <link>https://medium.com/snowflake/unlocking-the-power-of-data-with-snowpark-and-snowflake-49d43ce0b853?source=rss-c5060c3bd806------2</link>
            <guid isPermaLink="false">https://medium.com/p/49d43ce0b853</guid>
            <category><![CDATA[snowpark]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[snowsight]]></category>
            <dc:creator><![CDATA[Mubashir Masood]]></dc:creator>
            <pubDate>Wed, 05 Apr 2023 18:01:47 GMT</pubDate>
            <atom:updated>2023-04-05T18:01:47.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*3BMNlDaKPOlijIX-1erbJw.jpeg" /></figure><p>In today’s data-driven world, businesses need to have access to reliable and scalable data platforms to stay competitive. Snowflake is a cloud-based data platform that offers a range of services and tools to help organizations manage and analyze their data effectively. Additionally, Snowflake’s unique architecture allows for seamless data sharing across different organizations and platforms across AWS, GCP and Azure. One of the latest additions to Snowflake’s portfolio of tools is <a href="https://docs.snowflake.com/en/developer-guide/snowpark/python/index">Snowpark</a>, which offers a new way to process data using familiar programming languages. In this article, we will explore how Snowpark can be used to unlock the power of data in Snowflake.</p><p><strong>What is Snowpark?</strong></p><p>Due to the fact that the Snowpark platform allows developers to use their preferred programming languages in Python, Java, or Scala, this capability enables the users to write queries and extract data from Snowflake without having to pull data out . It provides a high-level interface for developers to work with data, making it easier to create data pipelines and applications that require data processing.</p><p>Snowpark is designed to work with a variety of programming languages, including Java, Scala, and Python. This means that developers can use their existing skills and tools to write code that interacts with Snowflake. Snowpark also provides a <a href="https://docs.snowflake.com/developer-guide/snowpark/reference/python/index.html">rich set of APIs</a> for interacting with Snowflake’s data platform, making it easy to work with complex data structures and query results.</p><p><strong>Why use Snowpark?</strong></p><p>There are several reasons why developers might choose to use Snowpark instead of traditional SQL queries. First, Snowpark offers a higher level of abstraction than SQL, making it easier to work with complex data structures and transform data in ways that would be difficult or impossible using traditional SQL queries. Second, Snowpark allows developers to use their preferred programming languages, which can lead to more efficient and productive coding.</p><p>Third, Snowpark provides a more scalable way to process data. Traditional SQL queries executed on other platforms, which usually become a bottleneck as the volume of data, concurrency and complexity increases. Snowpark, on the other hand, allows developers to execute data processing tasks and push down the workload(s) to Snowflake, which can be scaled up or down as needed with the Multi cluster shared data architecture.</p><p>Finally, Snowpark provides a more flexible way to process data. With Snowpark, developers can write code that interacts with Snowflake’s data platform in ways that would not be possible using traditional SQL queries. For example, they can use machine learning libraries to perform predictive analytics on Snowflake data, or they can use graph libraries to analyze relationships between different data points.</p><p><strong>Using Snowpark with Snowflake</strong></p><p>Snowpark can be used in a variety of ways to process and analyze data stored in Snowflake. Some of the key use cases of Snowpark include:</p><ol><li>Data transformation: Snowpark can be used to transform data stored in Snowflake using popular programming languages. This can include tasks like data cleaning, data normalization, and data aggregation.</li><li>Feature Engineering: Feature engineering is an essential task in data processing and analytics, which involves transforming raw data into meaningful features that can be used in machine learning and data modeling tasks. Feature engineering is crucial in ensuring that machine learning models are accurate and effective in making predictions. Snowpark provides a powerful toolset for feature engineering tasks, making it easy for developers to manipulate and transform data stored in Snowflake.</li><li>Machine learning: Snowpark provides a variety of libraries that can be used for machine learning tasks like data modeling and prediction. Developers can use popular machine learning frameworks like TensorFlow and PyTorch to build machine learning models in Snowflake.</li><li>Data integration: Snowpark can be used to integrate data from different sources into Snowflake, allowing for a unified view of data across different platforms.</li><li>Real-time analytics: Snowpark can be used to perform real-time analytics on data stored in Snowflake using <a href="https://docs.snowflake.com/en/user-guide/data-load-snowpipe-streaming-overview">Snowpipe streaming</a>. This can include tasks like streaming data processing, event processing, and near real-time visualization.</li></ol><p><strong>How to use Snowpark with Snowflake?</strong></p><p>There are several ways to connect Snowpark to Snowflake via an <a href="https://docs.snowflake.com/en/user-guide/ui-snowsight-quick-tour">Snowsight</a> or an IDE like <a href="https://docs.snowflake.com/en/user-guide/vscode-ext">VS Code</a>, <a href="https://docs.snowflake.com/en/developer-guide/snowpark/scala/quickstart-intellij">IntelliJ</a>, and others. You can start using the <a href="https://docs.snowflake.com/en/developer-guide/snowpark/python/python-worksheets">Python Worksheets</a> (currently this feature is in Public Preview and open to all of our customers). Write <a href="https://docs.snowflake.com/en/developer-guide/snowpark/index.html">Snowpark</a> code in Python worksheets to process data using Snowpark Python in Snowsight. By writing code in Python worksheets, you can perform your development and testing in Snowflake without needing to install dependent libraries.</p><p>After logging into Snowflake via Snowsight, go to worksheets and click on the new Python worksheet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RKuyNFIfto36F5fUSU8zww.png" /><figcaption>Creating a new Python Worksheet</figcaption></figure><p>Once you have created a new Python notebook, you can check the installed packages and libraries by writing a quick Python script. Start by importing the Snowpark library and defining your session. Then, you can retrieve the table information_schema.packages and store it in a dataframe and show the results. Super easy to use</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DPyQNXKEDQlz8N0XzbM9jw.png" /><figcaption>Python Worksheets in Snowsight</figcaption></figure><p>Regardless of the method you choose, you will need to provide your Snowflake account credentials to establish a connection. Once you have connected to your Snowflake account, you can begin working with your Snowpark data using the IDE of your choice. To use Snowpark with Snowflake, developers need to have access to Snowflake’s cloud-based data platform. Once they have access, they can create a Snowpark session and start writing code to interact with Snowflake data.</p><p>Here is a simple example of how to use Snowpark to extract data from Snowflake:</p><pre>#Import Libraries<br>from snowflake.snowpark.session import Session<br>from snowflake.snowpark.functions import udf, sproc, col<br>from snowflake.snowpark.types import IntegerType, FloatType, StringType, BooleanType, Variant<br>from snowflake.snowpark import functions as fn<br><br>import numpy as np<br>import pandas as pd<br><br>from snowflake.snowpark import version<br>print(f&quot;Snowflake snowpark version is : {version.VERSION}&quot;)<br><br>#Connection<br>from config import snowflake_conn_prop<br>session = Session.builder.configs(snowflake_conn_prop).create()<br><br>print(session.sql(&#39;use role ACCOUNTADMIN&#39;).collect())<br>print(session.sql(&#39;use IMDB.PUBLIC&#39;).collect())<br>print(session.sql(&#39;select current_role(), current_warehouse(), current_database(), current_schema()&#39;).collect())<br><br>#Connecting to table using a snowpark data frame<br>val df = session.sql(&quot;SELECT * FROM mytable&quot;)<br>df.show()</pre><p>In this example, we first import the necessary libraries for Snowpark. Then we create a Snowpark session using a configuration file that contains the connection details for our Snowflake account. Finally, we execute a SQL query to extract data from a table in Snowflake, and we display the result using the show() method.</p><p>Conclusion:</p><p>Snowpark is a powerful new tool from Snowflake that allows developers to unlock the power of data using familiar programming languages. By providing a high-level interface for working with data, Snowpark makes it easier to create data pipelines and applications that require data processing. With Snowpark, developers can use their existing skills and tools to work with Snowflake’s data platform, making it easier and more efficient to process data at scale. If you’re looking to take your data processing capabilities to the next level, Snowpark is definitely worth exploring.</p><h3>More Resources :</h3><ul><li><a href="https://quickstarts.snowflake.com/guide/snowpark_python_top_three_tips_for_optimal_performance/index.html?index=..%2F..index#0">Snowpark Python: Top 3 tips for optimal performance</a></li><li><a href="https://resources.snowflake.com/migration-guides/spark-to-snowflake-migration-guide#main-content">Spark to Snowflake Migration Guide</a></li><li><a href="https://www.snowflake.com/blog/snowpark-python-feature-engineering-machine-learning/">Snowpark for Python: Large-Scale Feature Engineering, Machine Learning Model Training, and More</a></li><li><a href="https://github.com/Snowflake-Labs/snowpark-python-demos/tree/main/snowpark_nlp_ml_demo">Sentiment Analysis NLP with Snowpark ML — Github Code</a></li><li><a href="https://github.com/Snowflake-Labs/snowpark-python-demos/tree/main/snowpark_nlp_ml_demo">PySpark vs Snowpark for ML in terms of Mindset and Approach — Blog</a></li><li><a href="https://www.youtube.com/watch?v=O_yrVutJ4_M">Streamlit Integration With Snowflake For Python Users</a></li><li><a href="https://www.youtube.com/watch?v=-W1aL8XwvkE">Snowpark Java &amp; Python UDFs DEMO | Under The Hood</a></li><li><a href="https://www.youtube.com/watch?v=Me2auWdhlKk">Snowpark API Demo | A Look Under The Hood</a></li><li><a href="https://quickstarts.snowflake.com/guide/getting_started_with_snowpark_python/index.html?index=..%2F..index#5">Getting Started with Snowpark Python</a></li><li><a href="https://quickstarts.snowflake.com/guide/machine_learning_with_snowpark_python/index.html?index=..%2F..index#7">Machine Learning with Snowpark Python</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49d43ce0b853" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/unlocking-the-power-of-data-with-snowpark-and-snowflake-49d43ce0b853">Unlocking the Power of Data with Snowpark and Snowflake</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>