<?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 Maciej Tarsa on Medium]]></title>
        <description><![CDATA[Stories by Maciej Tarsa on Medium]]></description>
        <link>https://medium.com/@maciejtarsa?source=rss-b8b8507219c1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_7s9-IyDMB-W9EMK</url>
            <title>Stories by Maciej Tarsa on Medium</title>
            <link>https://medium.com/@maciejtarsa?source=rss-b8b8507219c1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:59:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maciejtarsa/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 a Knowledge Agent on Databricks: The Evaluation Set Was the Real Product]]></title>
            <link>https://maciejtarsa.medium.com/building-a-knowledge-agent-on-databricks-the-evaluation-set-was-the-real-product-a16bbb255c51?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a16bbb255c51</guid>
            <category><![CDATA[databricks-genie]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Wed, 25 Nov 2026 02:39:15 GMT</pubDate>
            <atom:updated>2026-11-25T02:39:15.875Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was first published on <a href="https://www.mechanicalrock.io/blog/building-a-knowledge-agent-on-databricks">the Mechanical Rock website</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EtQXaNLDjYmODoeepdFgzw.png" /></figure><p>This season I’ve been umpiring my son’s teeball games. Under-9s, playing for <a href="https://www.woodlandsteeball.com.au/">Woodlands</a>, a team <a href="https://www.mechanicalrock.io/">Mechanical Rock</a> sponsors. Runners go on every hit, a fielder stands on second without the ball, a coach asks if that run counts, and you’ve got about four seconds to decide.</p><p>The rules are spread across a few documents — the TBAWA (Teeball Association of Western Australia) Rule Book, Edition 8, an older Annotated Rule Book &amp; Umpire Manual, and our local club’s by-laws. They don’t always agree. After each game I’d take the tricky calls to a local Claude session with them loaded, and keep a log of the answers I’d checked.</p><p>Then I wanted it on my phone, so I built it on Databricks. The surprise was what turned out to matter: <strong>the most valuable thing I built wasn’t the agent — it was the set of trusted answers I could measure it against.</strong></p><p><strong>Key takeaways</strong></p><ul><li>Keep the questions and answers you already trust. They become your evaluation set, and every change after that is measurable.</li><li>Check the evaluator, not just the model. Our “best” model returned empty answers and the LLM judge still marked them correct.</li><li>Check retrieval separately before you fix anything. Our biggest gain came from the prompt, not from search or a bigger model.</li><li>On Databricks Free Edition you can ship a mobile-accessible agent with nothing running all the time — for workspace admins. Test as your real users: ours failed silently for everyone else.</li></ul><h3><strong>Three questions from my notebook</strong></h3><p>I’ll follow three real questions through this post. They’re from my log, and each one breaks in a different way.</p><p>1. <strong>The tag-up. </strong>“Runner on 1st runs on the hit, the ball is caught. Is the runner out?” Answer: not automatically. Leaving on the hit is legal. The runner is out only if they or 1st base are tagged before they get back (Rule 17.10).</p><p>2. <strong>Time.</strong> “Does the ball need to be inside the diamond before the umpire can call Time?” Answer: no. Rule 11 says the ball must be held by a player in an <em>*infield position*</em>, and most infield positions are outside the diamond.</p><p>3. <strong>Rotation.</strong> “Can the same kid play the same position two innings in a row?” Answer: we’ll get to that one. Nobody got it right the first time, including Claude.</p><h3><strong>Why not just keep using Claude?</strong></h3><p>Honestly, for a few rulebooks you could.</p><p>All three documents together are about 65,000 tokens. That fits easily in a modern model’s context window, and Claude reading the whole lot is what produced the answers I trusted in the first place.</p><p>So why bother?</p><p><strong>The phone wasn’t the reason.</strong> My Claude Code session lives on my laptop, but the Claude mobile app with a Project holding the PDFs would answer the same questions from my pocket. For one umpire, that’s the simplest option. <a href="https://www.mechanicalrock.io/blog/databricks-genie-one-opens-the-doors-for-business-users">Genie One</a> has a mobile app too, so it’s a draw.</p><p><strong>I wanted to try Databricks on something real.</strong> Genie One, Genie Agents and the new bundle resource types are easier to judge on a small real problem than on a demo.</p><p><strong>I wanted the option to share it.</strong> If the local association or other umpires ever wanted it, Unity Catalog permissions would let me give a group access, with audit and usage tracking. That was the plan, anyway — it turned out harder than it looks (more below). Claude Team or Enterprise projects can be shared too, but everyone needs a seat in your organisation. Not a great fit for volunteers.</p><p><strong>I wanted to build it as if the rules were much longer.</strong> A few rulebooks fit in a prompt. A company’s policies or product manuals won’t. Retrieval also means each question sends 5–10k tokens to a cheap model instead of the whole corpus to an expensive one.</p><p><strong>What Claude still does better</strong></p><ul><li><strong>Model quality.</strong> Free Edition has no Claude models. I ended up on GPT-OSS-120B, and it shows on edge cases.</li><li><strong>Memory.</strong> My local session kept a log of past rulings and built on them. Genie remembers your conversations, but the agent doesn’t learn from them.</li><li><strong>Zero infrastructure.</strong> The Claude setup took minutes. The Databricks version took a pipeline, a SQL function, an agent, permissions and an evaluation framework.</li></ul><h3><strong>What did I actually build?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUgLqUYNmtEOdqG3pYO-pw.png" /><figcaption>The two flows: ingest when a rulebook changes, answer when someone asks</figcaption></figure><p>It’s RAG — retrieval-augmented generation. Instead of giving the model every document every time, you first <em>*retrieve*</em> the few sections that match the question, then the model <em>*generates*</em> an answer from just those. It answers from the rulebook in front of it rather than from what it half-remembers about baseball, and it can cite the rule it used.</p><p>There are two flows: one runs when a rulebook changes, the other every time someone asks a question.</p><p>1. <strong>Rulebooks </strong>— the PDFs sit in the repo, and a job copies them into a Unity Catalog volume.</p><p>2. <strong>Parse &amp; chunk</strong>— `ai_parse_document` turns each PDF into headings, text and page numbers. I split that into one chunk per rule (`17.10 Leaving Base Early`), each prefixed with the document, rule number and pages so it makes sense on its own.</p><p>3. <strong>Knowledge base</strong>— chunks go into a Delta table with an embedding each (`gte-large-en`), plus a small table of keyword weights.</p><p>4. <strong>Phone</strong> — I ask a question in the Databricks mobile app. Genie One routes it to the “Teeball Umpire” Genie Agent.</p><p>5. <strong>Genie agent</strong> — its only job is to call a SQL function, `ask_rulebook(question)`.</p><p>6. <strong>Find rules + answer</strong> — the function embeds the question, ranks chunks by similarity plus keyword overlap, takes the top 5 from each document and sends them to GPT-OSS-120B with an answering prompt. The answer comes back with citations: “Fair ball (Rule 14c, p12)”.</p><p>Everything is deployed with <a href="https://www.mechanicalrock.io/blog/an-ode-to-databricks-asset-bundles">Declarative Automation Bundles</a> (DABs) — schema, volume, jobs, permissions and the Genie Agent itself, via the `genie_spaces` resource type in newer CLI versions. Nothing runs all the time: serverless jobs, pay-per-token models, and a SQL warehouse that auto-stops.</p><p>The code is on GitHub: <a href="https://github.com/maciejtarsa/databricks-teeball-agent">databricks-teeball-agent</a>— the bundle, ingest and evaluation jobs, prompts and evaluation sets.</p><p>The Genie Agent definition caught me out. I told it in plain text to “always call `ask_rulebook`”, and it ignored me — it kept trying to answer from the table and then said it couldn’t. What worked was an example query with a parameter:</p><pre>example_question_sqls:<br>  - question:<br>      - &quot;Runner on 1st runs on the hit and the ball is caught. Is the runner out?&quot;<br>    sql:<br>      # Genie maps any similar question onto this pattern and fills :question<br>      - &quot;SELECT ${var.catalog}.${var.schema}.ask_rulebook(:question) AS answer&quot;<br>    parameters:<br>      - name: question<br>        type_hint: STRING</pre><p>Genie answers by writing SQL, so give it SQL to copy. With one example it sent my questions to the function every time. (Mine, at least. More on that later.)</p><h3><strong>What didn’t work along the way?</strong></h3><p>My <a href="https://www.mechanicalrock.io/blog/databricks-genie-one-opens-the-doors-for-business-users">Genie One post</a> covered the business-user side. This time I was building on it, and Free Edition pushed back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*PYSC5C-BX-vV9xEJeuj_sw.png" /></figure><p>Losing Vector Search was a blessing. A Vector Search endpoint is billed every hour it exists, whether anyone asks a question or not. Embeddings in a Delta column got rid of the permission problem and the always-on cost.</p><p><strong>The one that stung was an orphan agent.</strong> Early on, before we’d committed to doing everything with DABs, Claude Code poked at the Genie API to see how agents were created. One call returned an error, so we both assumed nothing had been created. Days later, after tearing down my dev environment, the workspace still had two “Teeball Umpire” agents.</p><p>Genie One had been sending some of my real phone questions to the orphan, which didn’t use the rulebook pipeline at all. Lesson: an error response doesn’t mean nothing was created, and the bundle can’t clean up what it didn’t create.</p><p>Deleting it caused a second problem. My test business user could open the real agent directly, but Genie One’s chat couldn’t find it: “I’m not finding a Genie space called ‘teeball umpire’… a Genie space that hasn’t been indexed yet”. We’d recreated the agent twice that day to move it between folders, and each time it got a new ID. Genie One learns about agents in the background, and that takes a while.</p><p>A few hours later chat found it on the web. On mobile it still needed the agent’s name before it went looking. Chat routing is best-effort, the direct agent link always works, and don’t recreate an agent the day before you need it.</p><h3><strong>How do you know it’s any good?</strong></h3><p>I already had 12 questions from real games, each with an answer I’d checked against the rulebooks. That turned out to be the most useful thing in the repo. Instead of asking the agent questions one at a time and judging each answer by eye, I could check every change against all of them at once.</p><p><strong>The evaluation is just another bundle job.</strong> It runs every question through the agent, has a second LLM grade each answer against my ruling (CORRECT, PARTIAL or WRONG, plus “did it cite the right rule?”), and writes the results to a table. Comparing three models was one parameter:</p><pre># &#39;|&#39; separates the models because --params splits on commas<br>databricks bundle run -t prod eval_rulings \<br>  --params &quot;label=iter1-models,models=databricks-gpt-oss-120b|databricks-qwen35-122b-a10b|databricks-meta-llama-3-3-70b-instruct&quot;</pre><p>Each model gets a temporary copy of the SQL function, built from the same template as the live one, so experiments never touch the agent people are using.</p><p>First result: 5 correct, 3 partial, 4 wrong. Not great, but now I had a number to beat.</p><p>And the notebook questions? The tag-up came back as a bold <strong>**”Out”**</strong>, with the right condition in the bullets underneath. Right rule, wrong headline. An umpire glancing at a phone reads the headline. The judge marked it PARTIAL, and it has stayed PARTIAL in almost every run since.</p><h3><strong>Can you trust the judge?</strong></h3><p>Not blindly. In the model comparison, Qwen 3.5 came out on top with 8 out of 12 correct. Then I read its answers.</p><p>They were all empty.</p><p>Qwen is a reasoning model. With a 2,000-token limit it spent the whole budget thinking and returned nothing. The judge still marked 8 of those blank answers correct.</p><p>The fix was a higher token limit, plus a plain code check that marks empty answers WRONG before the judge sees them. Which brings me back to the main point: <strong>the evaluation set is the product, but only if you check the evaluator too.</strong></p><p>Same story, smaller: when GPT-OSS judged its own answers it marked 4 WRONG. An independent judge (Llama 4 Maverick) marked the same answers 0 WRONG. Use a judge that isn’t the model being judged, and read anything that looks odd.</p><h3><strong>Is 12 questions enough?</strong></h3><p>No. With 12 questions, one answer changing moves the score by 8 points, and the margin of error is around ±25 points. Fine for catching blank answers, useless for comparing two decent options.</p><p>So I went back to the model that wrote my trusted answers. Four Claude Opus 5.5 sub-agents, each reading both full TBAWA documents (the by-laws came later), wrote 301 questions with answers across all the rule areas in about six minutes. I checked a random 26 as the umpire. All 26 were right.</p><p>This is a “teacher and student” set-up: the expensive model with the whole document writes the test, and the cheap agent sits it.</p><p><strong>Bonus: writing the test exposed the rulebooks.</strong> The sub-agents skipped questions the documents can’t settle. Batting out of the box: the Rule Book says the ball is dead at contact, the Manual says wait and see if it’s caught. A fair ball rolling over the dead-ball line untouched isn’t covered at all. The Rule Book even refers to a rule (9.1d) that doesn’t exist.</p><p>With 301 questions the margin dropped to about ±5 points, and some of my earlier conclusions fell apart.</p><h3><strong>Where was it actually failing?</strong></h3><p>The bigger set was less flattering: 69% correct, 24% partial, 7% wrong. The breakdown by rule area was more useful than the total.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*NUArvBDULQdaBKaL4Mb_lA.png" /></figure><p>Two things I’d believed from the small set didn’t hold up. Hybrid search (keywords plus vectors) didn’t beat plain vector search overall — running the same setup twice differed by 4 points, more than the gap between them. And it helped the numbered rules but hurt the Manual’s umpiring sections.</p><p><strong>My instinct was to fix search.</strong> First I added a retrieval-only check: for each question, did the right rule even make it into what the model saw? No answers, no judge, so it was quick and nearly free.</p><p>Search found the right section 95% of the time, even in the weak area. The problem was what the model did with it.</p><p>The Time question is the clearest case. Search finds Rule 11 every time, and the agent even quotes the right definition of “infield position” — then concludes “inside the diamond” anyway. It flips between right and wrong across runs, and it’s wrong in the latest ones. That one needs a better model, not a better pipeline.</p><p>The rest of the failures had a pattern. My prompt said the Rule Book wins over the Manual, and the model took that too far: it ignored the Manual’s interpretations and procedures, which is exactly what an umpire needs for “what do I do and say?”. The prompt also asked for “the ruling in one line”, which suits “out or safe?” but not “how do I handle a tee foul?”.</p><p>Here’s the rewritten prompt:</p><pre>You are a TBAWA teeball rules assistant. The user is an umpire asking a situational or<br>procedural question, often during or right after a game, reading on a phone.<br><br>Answer ONLY from the excerpts below. Each excerpt starts with a header: document title |<br>rule number and heading (or section name) | pages.<br>The documents work together:<br>- The Rule Book (Official Rules, Edition 8) states the rules.<br>- The Manual (Annotated Rule Book &amp; Umpire Manual 7A) explains how to apply them:<br>  interpretations, worked scenarios, umpire procedures, exact calls and signals,<br>  positioning, and how to deal with coaches and spectators.<br>- The By-Laws (Wembley Tee-Ball Association, WTBA) are local rules for games in the<br>  Wembley competition. They add to the TBAWA rules (e.g. fielding position rotation,<br>  weather and heat, finals, fines) and are numbered separately: By-Law 12 is not<br>  Rule 12.<br>Use them together. Apply the Manual&#39;s interpretations and procedures unless they<br>directly contradict the Rule Book. Only on a direct contradiction does the Rule Book<br>(newer edition) win; then say so briefly.<br>Where a By-Law adds a requirement the TBAWA rules don&#39;t have, include it and label it as<br>a WTBA local rule (it applies to Wembley competition games). Never present a By-Law as a<br>TBAWA rule.<br><br>How to answer:<br>- Situation/ruling questions: start with the ruling in one line (e.g. &quot;Out&quot;, &quot;Safe&quot;,<br>  &quot;Foul ball&quot;, &quot;Dead ball, runners return&quot;, &quot;Obstruction - award 3rd&quot;), then the key<br>  conditions that decide it (including exceptions the Manual adds).<br>- Procedure questions (&quot;what should the umpire do/say/signal&quot;): give the steps in order,<br>  with the exact calls in quotes (e.g. &quot;Time!&quot;, &quot;Batter Up&quot;, &quot;Play Ball&quot;) and signals,<br>  as the Manual describes them.<br>- Keep to what decides the case. Max ~6 short bullets.<br>- Cite every point as (Document Rule X.Y, p N), e.g. (Rule Book 17.10, p15), (Manual<br>  17.11, p41) or (WTBA By-Law 12.3, p6). For Manual sections without a rule number, cite<br>  the section name and page, e.g. (Manual &quot;Signals&quot;, p62). Take rule numbers ONLY from<br>  excerpt headers or text; never invent them.<br>- Teeball is NOT baseball. Never apply baseball/MLB rules that aren&#39;t in the excerpts<br>  (e.g. fair/foul is decided by where the ball FIRST lands).<br>- If the excerpts don&#39;t cover the situation, say &quot;Not covered by the rules provided&quot; and<br>  flag it as umpire judgement, citing the closest rules.<br>- Be concise. No preamble. Refer to players as &quot;the runner&quot;, &quot;the fielder&quot; (no he/she).</pre><p>The important line is the one about precedence: the Rule Book only wins on a <em>direct contradiction</em>, not by default. Procedure questions also get their own answer format. (This is the live version, which also covers the Wembley by-laws — more on that below.)</p><p>That one change beat every model and search change I tried:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*oTHjlPmf-KUbGf7eziN_xA.png" /></figure><p>I also tidied how the Manual’s practical section was chunked, so sub-headings like “SAFE” and “OUT” keep their parent “Signals”. Search got slightly better, but the answers moved within the noise. I kept it because the data is cleaner, not because it helped.</p><p>Ask it now “the batter hit more tee than ball, what do I do and say?” and you get the Manual’s answer: pick up the tee, wait for the ball to land, both arms up, “Time, Foul Ball!”, reset, announce the strike, “Play Ball!”. That’s what I want in my ear at the plate.</p><h3><strong>What happens when a document is missing?</strong></h3><p>Then came the rotation question: can a kid play first base two innings running?</p><p>I asked Claude. Claude searched both rulebooks and said no, there’s no rotation rule — only Rule 19.2, which stops a player sitting out two fielding innings in a row. Confident, cited, and wrong for our games.</p><p>Wembley, my association, has its own by-laws. By-Law 12.3: “A player cannot play in the same position for two consecutive fielding innings.” Neither Claude nor the agent could know that. It wasn’t in anything they’d been given.</p><p>This is the case the whole design was built for. Adding the by-laws was one PDF in a folder, one line in a metadata file, and one run of the ingest job. One ingest run later the agent answered with the by-law and labelled it a local rule, not a TBAWA one.</p><p>It had one catch. The by-laws number from 1 to 43, so “By-Law 17” (safety bases) and “Rule 17” (base running) would have looked like the same rule to my search. They’re now labelled differently, and the rule-number boost only applies to TBAWA rules.</p><p>Three new questions went into the evaluation set. The original 15 scored exactly the same as before. And the rotation answer? Right ruling, right citation, plus a penalty that doesn’t exist — borrowed from the next by-law down. PARTIAL.</p><h3><strong>Who can actually use it?</strong></h3><p>Here’s what it looks like from the dugout, with the question from the diagram: the ball first lands fair between home and 3rd, then rolls foul before reaching 3rd. A coach once told me that’s foul, which is the baseball rule. In teeball only the first landing counts, so it’s fair.</p><p>I named the agent in the question, and Genie One handed it straight to the Teeball Umpire agent. After a wait (sped up below), the answer is right: fair, because it first landed in fair territory, citing Rule 14(c) in both the Rule Book and the Manual. Under it is the query the agent ran — one call to `ask_rulebook` — with the function’s own answer in the result row.</p><p>One thing worth knowing: Genie One rewrites that answer in its own words for the chat. The text you read isn’t exactly what the evaluation set measured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PZFRmJ0evRy0ftILhjT1gw.gif" /><figcaption>Asking from the dugout: Genie One routes the question to the Teeball Umpire agent, then the answer and the query behind it (thinking time sped up 10x)</figcaption></figure><p>I recorded that as an admin. My first attempt was as my test business user, and there the generated code showed something else: no `ask_rulebook`, just Genie’s own keyword search on the chunks table. That was the clue. Genie hadn’t skipped `ask_rulebook` by choice. The query history showed that every call that user had ever made to it had failed:</p><blockquote><em>[AI_FUNCTION_REGISTRY_LOOKUP_FAILURE] Failed to dynamically resolve function “ai_query” from AI Function Registry. INTERNAL: An unknown error occurred.</em></blockquote><p>Genie quietly fell back to its own keyword search and answered from that. Plausible answers, no error on screen, and none of the search or prompt work behind them. I’m an admin, so it always worked for me, and every check I ran passed.</p><p>Peeling it back took an afternoon, with Claude Code reading the query history and Genie Code suggesting fixes from inside the workspace. Each fix uncovered the next problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*HhEawc5PAeO-REEZNA3h0g.png" /></figure><p>fourth problem made it all confusing: permission changes don’t reach sessions that are already open, even after logging out and back in. The same query would fail in one SQL editor tab and work in a new one.</p><p>To be sure it was about being an admin and not about who owned the function, I made the same test user an admin, with fewer grants than before. Everything worked, on the web and on the phone.</p><p>So it’s admin-only for now. I undid the workarounds, and the agent still makes one call to `ask_rulebook`.</p><p>Opening it up properly means taking the model calls out of the user’s hands, for example with a Databricks App that runs as a service principal and calls the models itself. The catch: an app runs, and costs, while it’s started, which undoes “nothing always-on”. I couldn’t tell whether these are Free Edition limits or platform bugs. On a paid workspace I’d check before designing around them.</p><p>The lesson I’d take to any project: <strong>test as the user you’re building for, not as yourself.</strong> My evaluation set measured the pipeline well. It never checked whether my users could reach it.</p><h3><strong>What are the honest caveats?</strong></h3><ul><li><strong>75% correct is not 100%.</strong> About 1 in 20 answers is wrong. Fine as a second opinion at a teeball game, not for anything that matters more.</li><li><strong>Answers are only as complete as the documents.</strong> Claude and the agent both missed the rotation rule until the by-laws went in. Neither knew what it didn’t have.</li><li><strong>The test agrees with Opus, not with the truth.</strong> My check of 26 answers is what makes the teacher trustworthy, and 26 is a sample, not proof.</li><li><strong>Free Edition shapes the design.</strong> No Claude models and no Genie file search, plus a daily usage cap. On a paid account I’d make different choices.</li><li><strong>No memory.</strong> The agent doesn’t learn from conversations yet.</li><li><strong>Admins only. </strong>Non-admin users hit `ai_query` errors on this workspace, and Genie hid them behind its own fallback answers.</li><li><strong>Chat routing isn’t guaranteed.</strong> Genie One’s chat finds agents through a background index, which took a few hours to pick up a new agent (this workspace is also on the older Genie API version). On mobile, naming the agent in the question helps. Opening the agent directly always works.</li></ul><h3><strong>How do you start something like this?</strong></h3><p>1. <strong>Write down the questions you already have, with answers you trust.</strong> <em>Quick win: an hour.</em> Ten to twenty real ones beat a hundred made-up ones.</p><p>2. <strong>Put the evaluation in a job before you build the clever bit.</strong> <em>A day.</em> Question in, answer out, judge, table. Add a code check for empty or uncited answers, and run it as a real user, not just as yourself.</p><p>3. <strong>Build the simplest pipeline that answers with citations.</strong> <em>A few days.</em> Parse, chunk by the document’s own structure, embed, one function. Deploy it with DABs from day one, agent included.</p><p>4. <strong>Grow the evaluation set with a stronger “teacher” model, and spot-check it.</strong> <em>Half a day.</em> Aim for a few hundred questions, tagged by area.</p><p>5. <strong>Diagnose before you fix.</strong> <em>Ongoing.</em> Break scores down by area, check retrieval on its own, and run the same setup twice so you know your noise.</p><h3><strong>What would I plan for before scaling it?</strong></h3><p><strong>Opening it up to every umpire.</strong> An app in front that calls the models as a service principal, or whatever removes the non-admin `ai_query` limits. Decide whether an always-on app is worth it, or check whether a paid workspace behaves differently.</p><p><strong>Testing as real users, end to end.</strong> My evaluation calls the SQL function directly, so it never saw what users saw. I’ve since added a job that asks the deployed agent through the Genie API and records which query it ran. Next step is to run it as a non-admin test account, so a permissions problem shows up as a failed test, not a week of quiet fallback answers.</p><p><strong>Watching for silent failures.</strong> Genie hid every error behind a plausible answer. A small scheduled check on the query history — failed `ask_rulebook` calls, or agent questions answered without it — would have caught this on day one.</p><p><strong>Grading the answer people read.</strong> Genie One rewrites the function’s answer for the chat, and its shorter version drops conditions. When I graded what Genie actually showed, fewer answers were fully correct than when I graded the function on its own. If the chat is the product, that’s the version to test.</p><p><strong>A bigger corpus.</strong> Brute-force similarity in SQL is fine for a few thousand chunks. Beyond that you’d want a Vector Search index — but that costs money around the clock, and from Genie you’d need a different front end or a fix for the permission issue.</p><p><strong>Shared memory.</strong> Not built yet: a scheduled job pulls Genie conversations through the API, an LLM drafts candidate rulings, a human approves them, and approved rulings go into the knowledge base. Every umpire benefits from every good answer.</p><p><strong>More real questions in the evaluation set.</strong> My 12 notebook questions, three I asked from my phone and three about the by-laws are all in there now. They’re the best material there is, because that’s how the agent actually gets used.</p><p><strong>A long-context comparison.</strong> On a paid account I’d add a “whole rulebook to Claude” mode to the same evaluation and let the numbers decide between accuracy and cost per question.</p><h3><strong>So, can it replace my Claude session?</strong></h3><p>Sort of.</p><p>It’s on my phone, adding a document means dropping in a PDF, it gets three answers in four fully right, and it cites the rule every time. Sharing it with every umpire in the association will take an app in front of it.</p><p>But look at the notebook. The tag-up: right rule, misleading headline. Time: still wrong. Rotation: right after the by-laws went in, with a made-up penalty attached. Claude would have done better on the first two. It also missed the third.</p><h3><strong>Start with the test, not the agent</strong></h3><p>Building the pipeline and wiring it to Genie was the easy part. Getting it onto other people’s phones wasn’t, as it turned out. And making it <em>*good*</em> only became possible once I could measure it, and that came from the questions I’d been scribbling down at games all along.</p><p>Before you build your next agent, write down the questions you already know the answers to. <strong>The evaluation set is the real product — the agent is just the current best attempt at passing it.</strong></p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/building-a-knowledge-agent-on-databricks">the Mechanical Rock website</a>.</p><p>At <a href="https://www.mechanicalrock.io/">Mechanical Rock</a>, we build AI and data solutions on Databricks, and we care about whether they actually work. If you’re putting an agent in front of your users and want to measure it properly, <a href="https://www.mechanicalrock.io/lets-get-started">let’s have a chat</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a16bbb255c51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serving Operational Data from Snowflake: Hybrid Tables in Production]]></title>
            <link>https://maciejtarsa.medium.com/serving-operational-data-from-snowflake-hybrid-tables-in-production-65cf4c6df7f3?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/65cf4c6df7f3</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 03:56:53 GMT</pubDate>
            <atom:updated>2026-10-02T04:56:59.607Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was first published on <a href="https://www.mechanicalrock.io/blog/serving-operational-data-from-snowflake-hybrid-tables-in-production">the Mechanical Rock website</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1aSw438d8tCBFSWyYaa_Xg.png" /></figure><p>Snowflake is a data warehouse: you load data into it, transform it, and query it analytically. That’s the pitch, and for most use cases it holds. So when a client asked us to use Snowflake as a low-latency operational serving layer — sub-300ms response times, up to 10 requests per second — we had questions.</p><p>Spoiler: it worked, but not without some pain.</p><p>This blog covers what we tried, what we built, and all the rough edges that didn’t show up in the docs.</p><h3><strong>What we were building</strong></h3><p>The client was retiring a legacy system that served real-time operational data to an internal API. The goal was to lift that logic into Snowflake rather than rebuild it elsewhere. The API hitting the old system would simply be repointed at Snowflake’s SQL API (a stateless HTTP interface for querying Snowflake directly). No new infrastructure, no new services to operate.</p><p>The requirements were tight: average response time under 300ms, sustained at 10 requests per second in production.</p><p><strong>Why not just use Postgres or Aurora?</strong> The honest answer: it would have worked, but the brief didn’t allow for it. The data already lived in Snowflake, reverse-ETL to keep a 3.5M-row table in sync on a 10-minute cadence would have added a whole pipeline to build and operate, and there was no dedicated team to own a second database. Snowflake’s SQL API meant the existing data layer could serve the use case without adding infrastructure. The cost argument also narrows considerably once you factor all that in — more on that later.</p><h3><strong>Snowflake interactive tables — close, but no</strong></h3><p>The obvious first candidate were Snowflake’s <a href="https://docs.snowflake.com/en/user-guide/interactive">interactive tables </a>— a variant of dynamic tables optimised for low-latency reads using a dedicated interactive warehouse.</p><p>They get a lot right, latency is genuinely good and the execution model is familiar. However, there were three blockers for us:</p><ul><li><strong>Full refresh only.</strong> Interactive tables don’t currently support incremental refresh. For a 3.5M-row table, that’s a full scan every cycle. Fine for some use cases — not great when you’re trying to minimise warehouse costs in non-production environments.</li><li><strong>24/7 warehouse requirement. </strong>An interactive warehouse needs to stay running to serve queries without cold-start penalties. In production, that’s acceptable. In development and staging environments, it’s wasteful. Snowflake does offer a 40% discount for interactive warehouses, which softens the blow — but it still felt heavyweight for lower environments that see a fraction of the traffic.</li><li><strong>Can’t join with standard tables.</strong> Interactive warehouses can only query interactive tables. The moment you need to join fresh data from a standard table, you’re blocked. And we did need to join fresh data — that was a hard requirement, not a nice-to-have.</li></ul><p>There are promising things coming to interactive tables (single-row inserts are in the roadmap), but at the time, the constraints ruled them out.</p><h3><strong>Snowflake hybrid tables</strong></h3><p>Snowflake’s <a href="https://docs.snowflake.com/en/user-guide/tables-hybrid">hybrid tables</a> store data in two formats simultaneously: row-based for fast transactional lookups, and column-based for analytical queries. This is Snowflake’s play for HTAP (Hybrid Transactional/Analytical Processing) territory — a single system that handles both operational and analytical workloads.</p><p>A few things set them apart from standard Snowflake tables:</p><ul><li><strong>Index-based reads.</strong> Unlike standard tables which rely on partition pruning, hybrid tables support explicit indexes for point lookups (both primary — which is a requirements — and secondary). This is what makes sub-300ms single-row reads possible.</li><li><strong>In-place updates via MERGE.</strong> You can update individual rows without rewriting a whole table. For a serving layer that refreshes every 10 minutes from upstream data, this is the right primitive.</li><li><strong>Enforced constraints.</strong> Unique and referential integrity constraints are enforced, which matters for transactional workloads where you need to know a row exists before you reference it.</li></ul><h3><strong>The architecture we built</strong></h3><p>We ended up with two hybrid tables and a table function sitting in front of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l15JDTIiYxSRXv3RUW3MKw.png" /></figure><ul><li><strong>The serving layer.</strong> A single hybrid table holding ~3.5M rows of pre-computed eligibility data. A Snowflake task runs every 10 minutes, using a MERGE statement to update only the rows that have changed — not a full reload. This keeps the refresh lightweight and predictable.</li><li><strong>The fresh records table.</strong> A second, deliberately small hybrid table holding records that have arrived since the last refresh cycle. Because 10 minutes of lag means we’d be serving stale decisions for records that came in during that window, fresh responses are joined in at query time to apply any recent changes. This table gets archived into a standard table every 10 minutes as part of the same task cycle, keeping it small and the join cheap.</li><li><strong>The table function.</strong> Both tables are accessed through a single table function. Callers query it like this:</li></ul><pre>SELECT column_a, column_b, column_c<br>FROM TABLE(GET_ELIGIBLE_PRODUCTS(:customer_id))</pre><p>The <em>:customer_id</em> bind parameter gets resolved inside the function, which performs the index lookup against both hybrid tables and returns the merged result. The SQL API handles the rest.</p><p>Why wrap it in a table function? Two reasons — and the second one surprised us. More on that in the gotchas.</p><h3><strong>The gotchas</strong></h3><p>This is the section I wish had existed before we started. Several of these required Snowflake escalations and at least one required Snowflake to intervene at the infrastructure level.</p><p><strong>The query cache will return the wrong customer’s data.</strong></p><p>Snowflake caches query results based on query text only — bind parameters are ignored entirely. Two users querying with different customer IDs but the same parameterised SQL will get the same cached result. In practice, that means user A could receive user B’s eligibility data. The fix: embed the customer UUID directly in the SQL string rather than using bind parameters.</p><pre>-- BAD: Snowflake treats these as identical queries, returns cached result<br>SELECT * FROM TABLE(GET_ELIGIBLE_PRODUCTS(?))  -- bind param ignored by cache<br><br>-- GOOD: UUID in the string = unique query text = no cache collision<br>SELECT * FROM TABLE(GET_ELIGIBLE_PRODUCTS(&#39;a3f2e1d0-...&#39;))</pre><p>Since the UUID is now in the query string, validate it against a strict UUID format before constructing the SQL. This isn’t optional — it’s the injection guard that makes the approach safe.</p><p><strong>Masking policies silently break index lookups.</strong></p><p>When a masking policy is applied to a column that’s part of a hybrid table index, Snowflake switches from <em>ROW_BASED</em> scan mode to <em>COLUMN_BASED</em>. That bypasses the index entirely and falls back to a full column scan — a massive performance regression you won’t see coming until you deploy to an environment where masking policies are actually active (which, in our case, was production).</p><p>The fix is to effectively remove masking from the indexed columns. We created a <em>CLASSIFICATION_EXEMPT</em> tag with no masking policy attached and applied it to those columns only — all other tags in the platform still carry masking policies. This restores ROW_BASED scan mode and returns latency to the expected range.</p><p>The obvious downside: those columns are now unmasked. The compensating control is to restrict access to the hybrid table itself to only the roles that need it — tighter RBAC rather than column-level masking. It’s a valid trade-off, but go in with eyes open.</p><p><strong>Top-of-hour latency spikes — and it wasn’t the warehouse.</strong></p><p>At the top of each hour, we observed query latency jumping from 200–300ms to 400–600ms. The instinct is to blame the warehouse — but query execution time was ~16ms. The spikes were entirely in cloud services: compilation taking ~200ms, request receipt taking ~350ms. No data was being scanned.</p><p>Root cause: shared cloud services capacity experiencing contention at hour boundaries from other activity across the Snowflake platform. The warehouse was irrelevant. Resolved by Snowflake provisioning a dedicated cloud services tenancy for the account — something that requires an escalation, not a configuration change.</p><p><strong>Table function predicate pushdown — the non-obvious one.</strong></p><p>When we first queried the serving hybrid table joined with the fresh records table, Snowflake was doing a full table scan instead of using the index. The customer ID predicate wasn’t being pushed down through the join — Snowflake couldn’t prove the filter would only touch a small number of rows, so it scanned everything.</p><p>Wrapping the query in a table function changed the behaviour. Snowflake treats the table function as a single operation with a known lookup signature, which forces it to use the row-based index and perform a targeted lookup. This was the key optimisation that brought hybrid table performance close to parity with interactive tables.</p><p><strong>SQL API rate limiting isn’t warehouse-bound.</strong></p><p>The SQL API is stateless — every request creates a new session. That means every request goes through auth, query compilation, routing, and execution from scratch. At low volumes that’s fine. At 10 requests per second sustained, the Cloud Services layer starts to feel it before the warehouse does. We hit 429 (TooManyRequests) and 503 (ServiceUnavailable) errors under peak load.</p><p>The instinct is to scale up the warehouse. It doesn’t help — the bottleneck is upstream of it. Cloud Services is a shared layer handling session management and compilation for the whole account, and it has its own limits independent of warehouse size.</p><p>A few things that do help:</p><ul><li><strong>Retry with exponential backoff.</strong> 429s and 503s are transient. A well-implemented retry loop with jitter handles most burst scenarios without any architectural changes.</li><li><strong>Batch writes where you can.</strong> If your write path is hitting the SQL API individually for each record, that’s avoidable overhead. Combine records into fewer, larger statements.</li><li><strong>Consider a Snowflake connector for high-throughput paths.</strong> If the stateless model is genuinely the bottleneck, switching from raw SQL API to a Snowflake driver (Python connector, JDBC) gives you persistent sessions and connection pooling — at the cost of a more complex integration layer.</li></ul><p>If you’re expecting sustained high concurrency, test this early. It’s not a problem you’ll see in light integration testing.</p><p><strong>No Terraform or dbt support.</strong></p><p>Neither hybrid tables nor interactive tables are first-class citizens in Terraform or dbt (at the time of writing). We used <em>snowflake_execute</em> resources for anything that needed Terraform. Furthermore, our hybrid table resources exist outside the dbt lineage graph, which means they’re invisible to the catalog and out of the normal deployment flow. If your platform is heavily dbt-driven, expect friction.</p><p><strong>Cold starts matter more than you’d expect.</strong></p><p>If traffic drops off — overnight, over a weekend — the hybrid table warehouse will cold-start on the next request. Cold starts on hybrid tables can add several seconds to response time. In production, we ended up increasing the autosuspend timeout significantly to keep the warehouse warm and prioritise consistent latency over cost savings.</p><p>In lower environments, though, this is actually where hybrid tables have a clear advantage over interactive tables. Interactive warehouses need to stay running to serve queries at all times — you’re paying for uptime whether or not anything is hitting them. With hybrid tables, you can let the warehouse suspend and accept the occasional cold start. For development and staging traffic patterns, that trade-off is entirely reasonable.</p><h3><strong>Performance results</strong></h3><p>Before committing to this architecture in production, we ran performance tests on representative data volumes — not the full 3.5M rows, but a proportionally sized sample. The results were clear enough to guide the decision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bnTREpzFGI1g6_0PLBUgLw.png" /></figure><p><strong>Interactive tables</strong> hit approximately 150ms average — well inside the 300ms target.</p><p><strong>Hybrid tables without the table function</strong> came in around 300ms — right at the boundary, and degrading under load as concurrent requests increased. Not viable.</p><p><strong>Hybrid tables with the table function</strong> came in around 200ms — close to interactive table parity, and consistent. That’s the table function forcing index-based lookups rather than column scans.</p><p>One area where hybrid tables have a meaningful advantage: the serving warehouse can be configured as multi-cluster, automatically adding clusters to absorb traffic spikes. Interactive warehouses have no equivalent dynamic auto-scaling — you can spin up more of them manually, but nothing scales up or down on its own in response to load. For workloads with variable, spiky concurrency, that’s a real difference.</p><p>The other side of that trade-off is worth being honest about: interactive tables scale better as concurrency increases, if you’re willing to size and manage that scaling yourself. In our testing, interactive table latency stayed flat regardless of load, while hybrid tables — even with the table function in place — showed growing tail latency (p95/p99) as concurrent requests went up. At our production volume of 10 requests per second, hybrid tables keep up comfortably. But this isn’t a story where hybrid tables win outright — at 50 requests per second, interactive tables would pull decisively ahead, so long as you’ve provisioned enough warehouse capacity to handle it. If your workload doesn’t need to join fresh data at query time and you’re comfortable managing that capacity by hand rather than relying on autoscaling, interactive tables are the better bet at higher scale.</p><h3><strong>Cost: the honest napkin maths</strong></h3><p>We didn’t choose Snowflake because it was cheaper. Rather, we chose it because the data already lived there and the brief was to stay in one system. If your primary driver is cost — then a purpose-built operational database will still win on raw compute every time.</p><p>That said, here’s what we’re actually running. In the Sydney AWS region, Enterprise tier Snowflake costs USD $4.05 per credit. An X-Small warehouse consumes 1 credit per hour. We have two — one for reads, one for writes — so that’s around USD $5,800/month at 24/7. We may yet consolidate into a single warehouse (haven’t had the chance to validate the latency impact), which would bring it to around USD $2,900/month. X-Small was more than sufficient for our workloads.</p><p>For comparison, an Aurora PostgreSQL db.r6g.large in the same region runs at USD $0.3130/hr — roughly USD $225/month. Cheaper, yes. But that number doesn’t include a reverse-ETL pipeline to keep 3.5M rows in sync from Snowflake, an API layer to serve queries (SQL API is included with Snowflake), or the operational overhead of running a second system.</p><p>If your data already lives in Snowflake, the total cost of ownership comparison is less lopsided than the compute numbers suggest. If it doesn’t — and you’d be building sync infrastructure either way — a dedicated operational store is probably the right call.</p><h3><strong>Takeaways</strong></h3><p>Snowflake hybrid tables in production work. The performance is genuinely usable for operational serving workloads. But this is not Snowflake’s primary use case — and you will feel that.</p><p><strong>Use this approach when your data already lives in Snowflake.</strong> If you’re going to build a reverse-ETL pipeline and operate a separate database anyway, there’s a reasonable argument for a purpose-built operational store. But if the data is already in Snowflake and you need low-latency serving, staying in one system is the simpler path.</p><p><strong>The table function is not optional.</strong> Without it, you’re not using the index. Make that decision explicitly rather than discovering it after deployment.</p><p><strong>Go in expecting escalations.</strong> The masking policy issue, the top-of-hour spikes, and the dedicated cloud services tenancy all required opening tickets with Snowflake support. None of them were self-service fixes. If your team has a Snowflake account team, keep them in the loop early.</p><p><strong>Don’t skip the performance testing.</strong> Representative data, load testing at target concurrency, in a real Snowflake environment. The gap between interactive and hybrid (pre-optimisation) was significant enough that we would have made a different architectural choice had we not run the tests.</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/serving-operational-data-from-snowflake-hybrid-tables-in-production">the Mechanical Rock website</a>.<br>Here at <a href="https://www.mechanicalrock.io/">Mechanical Rock</a>, we build and operate data platforms — including the kinds that need to do things data platforms aren’t supposed to do. If you’re pushing Snowflake into operational territory and want a second pair of eyes over it, <a href="https://www.mechanicalrock.io/lets-get-started">get in touch</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65cf4c6df7f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks Genie One Opens the doors for business users]]></title>
            <link>https://maciejtarsa.medium.com/databricks-genie-one-opens-the-doors-for-business-users-2ff059e1945c?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ff059e1945c</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks-genie]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Wed, 12 Aug 2026 06:52:20 GMT</pubDate>
            <atom:updated>2026-08-12T06:52:20.654Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gs8bfhiR7M73G4y5E7YbkQ.png" /></figure><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/databricks-genie-one-opens-the-doors-for-business-users">the Mechanical Rock website</a>.</p><p>For a long time, a data platform was just a carrier of data for the visualisation platform. Ingest the data, push it through the medallion architecture and your end users will query and visualise it through their tool of choice (usually PowerBI).</p><p>Under no circumstances would you want to give your non technical users access to your data platform. Can you imagine the damage they could do? All those tabs, buttons and options.</p><p>Data platfrorms haven’t really made it usable for non technical users either. Yes, Snowflake had dashboards, but they had no version control and their sharing model wasn’t great. Now they have Streamlit, which solves some of this, but introduces a requirement for some coding ability — it’s no longer a drag and drop tool.</p><p>But wait… there’s something new, something different. Databricks Genie One!</p><h3><strong>What is Databricks Genie One?</strong></h3><p>The regular Databricks workspace (the Lakehouse) is not for business users. It’s too cluttered, too technical, and too much. Tabs everywhere, notebooks, clusters, settings — none of that belongs in front of someone who just wants to look at a dashboard or ask a question about the data.</p><p>Genie One is Databricks’ answer to that. It’s a separate, consumer-grade experience where business users can access AI/BI dashboards, chat with Genie, and use Databricks Apps — without ever seeing the standard workspace. Think of it as a curated front door: just the content they need, none of the machinery behind it.</p><p>Onboarding is straightforward: built-in consumer entitlements, seamless identity integration, and just-in-time provisioning mean you’re not managing access manually for every new user. And because it’s all built on Unity Catalog, the governance story doesn’t change — the same access controls, audit logs, and data policies apply whether someone is logging in through Genie One or the full workspace.</p><p>It’s also smarter than a simple portal. AI surfaces the most relevant content so users land on the right dashboard rather than hunting through a list. When they want to go deeper, Genie is right there. When they need to take action, Databricks Apps are right here alongside their analytics. Everything in one place, without the technical overhead.</p><h3><strong>Dashboards vs Genie — when to use which?</strong></h3><p>A dashboard answers the questions you anticipated. Genie answers the ones you didn’t.</p><p>A good dashboard covers a lot — but you can only anticipate a fraction of what users will actually ask. Genie fills that gap. The two work together: a user might start on a dashboard, spot something interesting, and ask Genie to dig deeper — without leaving the page or losing context.</p><h3><strong>How Genie takes dashboards to the next level</strong></h3><p><strong>Not just text-to-SQL — </strong>Genie uses an ensemble of AI agents working together — planning how to answer the question, generating SQL, visualising results, explaining the answer. It learns from Unity Catalog metadata, existing queries in dashboards and notebooks, and user feedback over time. The more you use it, the sharper it gets.</p><p><strong>The Genie Ontology</strong> — what powers this intelligence is a continuously-learned model of your business that sits underneath everything. It understands your terms, your data relationships, your metrics, and who’s allowed to see what. That’s what makes Genie feel like it understands your business rather than just querying a database.</p><p><strong>Transparent by design</strong> — when Genie answers a question, it surfaces the sources it used to get there. You can see exactly what data it reached for, which builds trust in a way that a black-box answer never would.</p><h3><strong>Getting started</strong></h3><p>I’ll be using <a href="https://www.databricks.com/learn/free-edition">Databricks Free Edition</a> for this so some features may be limited. Anyone can sign up with a non-corporate email address and there’s no need to provide any card details.</p><p>For sample data and analytics, I’ll be pulling from the <a href="https://github.com/databricks-demos/dbdemos">dbdemos repo</a> — a great collection of Databricks demo resources.</p><p>Installation is super simple, in a notebook run:</p><pre># to install demos<br>%pip install dbdemos<br><br># to list available dbdemos<br>import dbdemos<br>dbdemos.help()<br>dbdemos.list_demos()<br><br># to install specific demo<br>dbdemos.install(&#39;aibi-sales-pipeline-review&#39;, catalog=&#39;main&#39;, schema=&#39;dbdemos_aibi_sales_pipeline_review&#39;)</pre><p>There are quite a few demos to choose from — some of them might even be similar to your use cases — great resource if you’re building your own dashboards:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*62bP8jZ3kegaXMhdWEUw1Q.png" /><figcaption>List of available demos</figcaption></figure><p>For my purposes, I decided to give <em>AI/BI: Sales Pipeline Review</em> a go.</p><h3><strong>Permissions and users</strong></h3><p>Ideally, you’d create a dedicated <em>business_users</em> group with <em>Consumer access</em> only, and assign new users to that group exclusively. That keeps things clean and explicit.</p><p>In practice, Free Edition gets in the way. Without full account-level control over groups, you can’t remove users from the default <em>users</em> group — so any new user will always inherit those permissions. The workaround: restrict the default <em>users</em> group to <em>Consumer access</em> only, then create more permissive child groups for engineers and analysts who need full Lakehouse access. Not the cleanest setup, but it worked for testing access controls.</p><p>One more thing to remember: permissions alone aren’t enough. Business users also need at least <em>Can View</em> on each dashboard and Genie Agent they should access, Dashboard also need to be Published first — content won’t surface in Genie One until it’s explicitly shared with them and published.</p><h3><strong>What does the business user see?</strong></h3><p>Once your business user logs in, all they will be able to see it Genie One. Below is the view by regular user on the left, and user with <em>Consumer access</em> only on the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2Zl0Rmxrnk9grD7siaSQQ.png" /><figcaption>Databricks Home Comparison</figcaption></figure><p>The dashboard experience is clean and immediately usable. Tabs keep things organised across multiple views, and the whole thing is interactive — clicking on a chart element filters everything else on the page in real time. No configuration needed, no extra steps. Some dashboard examples below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84Qy0R69NN6l9Z5ByuBtZw.png" /><figcaption>Sales Pipeline Dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*not0iaB43X9a3ubwWkYfqQ.png" /><figcaption>Customer Support Dashboard</figcaption></figure><h3><strong>Asking Genie questions</strong></h3><p>But this is where the true value comes in — finding out more — getting to the root of the data. Genie is accessible from anywhere, from the main page, individual widgets, the dashboard page or Genie Agents. Depending on where you are asking the questions from, different context might be used. Genie Agents are like your domain experts, trained on specific subsets of data, often linked to a specific dashboard.</p><p>Conversing with Genie is very similar to other chat interfaces, with the exception of Genie having additional context of your data and your organisation. You can also clearly see the steps Genie is going through to work out the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h1sBpG9jKke0iWVTlHfDDA.png" /><figcaption>Asking Genie a question</figcaption></figure><p>Genie will often produce graphs and you can view the source code of the queries it used to provide the answers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*itLGSKa9ir2lU86fwLN4gQ.png" /><figcaption>Genie’s response</figcaption></figure><p>You can also view all the sources used for the response and provide feedback on the response usefuleness and accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jtjNwtYTeAbUcsQ_s-UeeA.png" /><figcaption>Genie’s sources and feedback</figcaption></figure><p><strong>The honest caveat — </strong>the quality of Genie’s answers depends heavily on the quality of what sits underneath. Point it at a clean, well-modelled domain — good column comments, certified tables, Metric Views defined for your key business metrics — and it performs well. Point it at a sprawling, undocumented catalog and the experience is average at best. Teams getting the most out of it in production tend to start narrow: one domain, one team, tight scope. Then they scale out as they build confidence and refine the setup.</p><p>It’s also worth setting up Benchmarks — known-good questions with verified SQL — so you can measure accuracy over time and catch regressions as the data evolves. Encouraging users to give feedback (thumbs up/down on answers) feeds that loop and makes Genie sharper over time.</p><h3><strong>Deploying Genie</strong></h3><p>Creating a dashboard in the UI is fast and intuitive — drag, drop, prompt, done. But “share this dashboard” is not a deployment strategy, and that’s where a lot of tools fall short.</p><p>Databricks takes a different approach. Once you’re happy with a dashboard, you can export it as a <em>.lvdash.json</em> file — a declarative definition of everything in that dashboard. That file can be checked into git, reviewed like any other code change, and deployed via Declarative Automation Bundles (DABs). Genie Agents work the same way. Both are first-class citizens in the DABs ecosystem.</p><p>In practice, this means you can build in the UI, export, commit, and promote through environments — dev to staging to prod — with a proper CI/CD pipeline behind it. The dashboard your business users see in production is the exact same artefact that was reviewed and tested in lower environments. No manual recreation, no drift.</p><h3><strong>Other notable features</strong></h3><ul><li><strong>Scheduling</strong>— business users can subscribe to a dashboard and have it delivered to their inbox on a schedule, no login required. The delivery is a static PDF snapshot — no interactivity — but that covers a surprising amount of real monitoring requirements. If your users just need to see the numbers at 9am on Monday, this handles it cleanly.</li><li><strong>Mobile app</strong> — the Genie One mobile app is genuinely useful for getting quick answers on the go. Same governed data, same permissions, just in your pocket. Not a replacement for the full experience, but for a sales manager who wants to check a number before a meeting, it does the job. Genie is also available in Slack and Teams for the same reason — meet users where they already are.</li><li><strong>MCP integration</strong> — there’s a Model Context Protocol (MCP) server for Genie, so developers can wire it into AI coding tools like Claude or Cursor. Niche, but it signals how Databricks is thinking about Genie — as a platform, not just a UI.</li><li><strong>Databricks Apps</strong> — custom apps sit alongside dashboards and Genie in the Genie One UI, letting teams build interactive experiences on top of the same governed data. A business user could move from a dashboard to a Genie conversation to a full app without ever leaving Genie One.</li></ul><h3><strong>What makes Genie One stand out?</strong></h3><p>Genie One is the most credible attempt yet at making a data platform genuinely usable for business users — not just technically possible, but actually approachable. The combination of governed access, AI-surfaced content, conversational data exploration, and a proper deployment story puts it ahead of where most BI tools sit today.</p><p>But it’s not magic. The teams getting real value from it in production have invested in their data foundations first — clean models, defined metrics, curated spaces. Genie amplifies good data work; it doesn’t paper over bad data. If your catalog is a mess, your business users will get confident-sounding wrong answers, which is worse than no answer at all.</p><p>The right way to think about it: Genie One is the front door. What you put behind it still matters.</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/databricks-genie-one-opens-the-doors-for-business-users">the Mechanical Rock website</a>.</p><p>Here at <a href="https://www.mechanicalrock.io/">Mechanical Rock</a>, we work with Databricks on real client engagements. If you’re thinking about putting data in front of your business users — or you’re already on Databricks and want to make more of it — don’t hesitate to <a href="https://www.mechanicalrock.io/lets-get-started">get in touch</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ff059e1945c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks and Snowflake: Where Things Stand Today]]></title>
            <link>https://maciejtarsa.medium.com/databricks-and-snowflake-where-things-stand-today-f43216317cfd?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f43216317cfd</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Fri, 08 May 2026 01:18:13 GMT</pubDate>
            <atom:updated>2026-05-08T01:18:13.773Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was first published on <a href="https://www.mechanicalrock.io/blog/databricks-and-snowflake-where-things-stand-today">the Mechanical Rock website</a>.</p><p><em>Disclaimer: This post was written in May 2026. Both platforms are evolving at a rapid pace — specific features and tooling may have changed by the time you read this.</em></p><p>Another Databricks vs Snowflake post? Yes. But hear me out.</p><p>Databricks and Snowflake are two of the most capable data platforms available today — but most of what’s written about them is either outdated, sponsored, or written by someone who’s only used one of them. Both platforms look very different today than they did two years ago, and the usual “Snowflake is SQL, Databricks is Spark” narrative doesn’t quite hold anymore.</p><p>We work with both regularly. Here’s where things stand today, and when we’d reach for one over the other.</p><h3><strong>Where things stand</strong></h3><p>Both platforms have been on an aggressive feature release cycle, and they’ve been converging in interesting ways. Snowflake has been investing heavily in Python and AI/ML capabilities — though Python in Snowflake has historically been fragmented across UDFs, Snowpark, and stored procedures. Snowflake Workspaces have improved the iterative development experience, but it’s still not as natural a primary Python environment as Databricks. Databricks has been doubling down on SQL, governance, and business-facing tooling. They’re not the same product, but the gap has narrowed.</p><p>That said — they still feel fundamentally different to work with. The simplest mental model that holds up under scrutiny: Snowflake is a platform-first experience, Databricks is an engineering-first platform. That distinction runs through everything — from how you debug failures to how you onboard new team members.</p><h3><strong>When I’d choose Snowflake</strong></h3><p><strong>If your team lives in SQL — Snowflake is your home.</strong></p><p>Everything in Snowflake is SQL-first — and that shows up in how predictable and debuggable it is for non-engineers. Your data engineers, analysts, and even some business users can operate in the same environment without needing to context-switch into Python or notebooks. Layer some orchestration on top and you’ve got yourself a solid data platform that’s genuinely easy to maintain. Databricks is increasingly SQL-capable, but it’s not SQL-native in its ergonomics — you feel that difference in debugging, observability, and onboarding analysts.</p><p>Coming from a traditional warehousing background? Snowflake will feel familiar in the best way.</p><p><strong>If you want AI augmentation without building a model.</strong></p><p>Snowflake Intelligence is genuinely accessible. Sentiment analysis, document extraction, image and video analysis — all available as SQL functions. For teams that want to experiment with AI without a dedicated ML team, it lowers the bar significantly.</p><p>That said — call it what it is: an AI augmentation layer, not an ML platform. You don’t get fine-grained control over model behaviour, costs can spike fast at higher volumes, and it won’t take you far beyond lightweight use cases. If you need production-grade AI, you still need a data scientist and a proper ML workflow.</p><p>Snowflake also offers Cortex Code — an AI coding assistant for SQL and Python available in both the UI and CLI (<a href="https://www.mechanicalrock.io/blog/taking-snowflake-cortex-code-cli-for-a-spin">we tested it previously</a>). It’s natively aware of your Snowflake environment: schemas, objects, and governance included. Worth knowing about if developer productivity tooling is on your radar.</p><p><strong>If you need transactional-style workloads alongside analytics.</strong></p><p>This one can be surprising. Snowflake’s <a href="https://docs.snowflake.com/en/user-guide/tables-hybrid">hybrid tables</a> and <a href="https://docs.snowflake.com/en/user-guide/interactive">interactive tables</a> are genuinely usable in practice — I’ve used them in production scenarios. Snowflake is moving into HTAP (Hybrid Transactional/Analytical Processing) territory — blending transactional and analytical workloads in a single system — and it’s a credible direction.</p><p>But it’s not a clean win yet. These features are promising, not widely proven at scale. Databricks also has a story here — Delta Lake with streaming pipelines and derived serving layers covers a lot of the same ground, just framed differently. If your workloads skew toward streaming-derived serving rather than strict transactional semantics, Databricks is a reasonable option too.</p><h3><strong>When I’d choose Databricks</strong></h3><p><strong>If you’re building or fine-tuning ML models.</strong></p><p>Databricks was purpose-built for this. The experimentation workflows, MLflow integration, model serving, feature engineering — it’s all there and it’s cohesive. If your team includes data scientists who want to experiment with different models, compare runs, and push things to production, Databricks is the right environment. Snowflake is catching up but it’s not there yet.</p><p><strong>If you want to build and ship data apps without leaving the platform.</strong></p><p><a href="https://www.databricks.com/product/databricks-apps">Databricks Apps</a> lets you build and deploy data and AI applications directly inside Databricks. Framework support is broader than people expect — Streamlit, Dash, Flask, FastAPI on the Python side, and Node.js frameworks including React, Angular, Svelte, and Express on the frontend. They run serverless, inherit Unity Catalog’s access controls automatically, and Databricks Genie can help you scaffold them.</p><p>This is a strong emerging direction — but be clear-eyed about where it is today: Databricks Apps isn’t yet mainstream or battle-tested, and the developer experience isn’t yet comparable to dedicated app platforms. It’s also worth noting that Snowflake’s Streamlit integration is already widely used. The vision is compelling; just don’t treat it as a mature platform yet.</p><p><strong>If business users need self-service analytics inside the platform.</strong></p><p>Snowflake is currently decommissioning their native dashboards, with Streamlit as the recommended path forward — genuinely capable, but requires Python. That raises the bar for teams expecting a no-code analytics experience. Databricks, by contrast, does have native drag-and-drop dashboards that are straightforward to create. They’ve also been investing heavily in <a href="https://www.databricks.com/product/ai-bi/genie">Genie AI</a> as a natural language interface for business users. On dashboarding specifically though, the gap is real — if keeping analytics inside the platform matters, Databricks has the clearer answer today.</p><p>That qualifier matters: most enterprises are already standardised on Power BI, Tableau, or Looker. If you’re in that camp, native dashboard capability barely enters the equation.</p><h3><strong>Engineering considerations: both platforms</strong></h3><p><strong>Deployment and DevOps</strong></p><p>Whichever platform you’re on, you need real deployment pipelines with version control, environment promotion, and change management. Clicking your way to prod isn’t a workflow.</p><p>For Databricks, <a href="https://www.mechanicalrock.io/blog/an-ode-to-databricks-asset-bundles">Declarative Automation Bundles (or DABs)</a> paired with Terraform is a match made in heaven. Define everything as code, deploy to dev from your laptop, promote through environments via CI/CD. It’s one of the most complete deployment stories I’ve encountered in practice.</p><p>Snowflake’s story here is more complicated — and that’s partly historical. The platform evolved feature by feature without a coherent deployment-first philosophy, and the fragmentation shows. Terraform works but historically lagged behind features (if you’ve ever written a `snowflake_execute` resource, you know the pain). <a href="https://github.com/Snowflake-Labs/schemachange">Schemachange</a> is a solid option and we’ve used it successfully on multiple projects.</p><p>Snowflake also launched Snowflake DevOps — a native declarative option with Git integration and `CREATE OR ALTER` syntax — and pushed it heavily for a while. <a href="https://www.mechanicalrock.io/blog/snowflake-devops-first-impressions-and-comparison-with-schemachange">We put it through its paces</a>: production-ready, but missing a few things schemachange handles better, and Snowflake has since gone noticeably quiet on it. <a href="https://docs.snowflake.com/en/user-guide/dcm-projects/dcm-projects-overview">DCM projects</a> (currently in preview) looks like the direction they’re actually heading — declarative pipelines for Snowflake. Haven’t tried it yet, so watch out for another analysis coming up soon. For now: Terraform + schemachange is the safe bet.</p><p><strong>The multi-developer problem</strong></p><p>How do multiple developers work on the same platform without overwriting each other? We get asked this constantly, and it applies to both platforms equally.</p><p>First rule: separate your infrastructure code from your application code. Infrastructure changes infrequently — your pipelines and transformations do. Don’t mix them.</p><p>Beyond that:</p><p>- <strong>Databricks</strong>: DABs dev mode handles this natively. Username-prefixed resources per developer, no extra config needed.</p><p>- <strong>Snowflake</strong>: dbt’s schema isolation is the cleanest solution. Without dbt, Snowflake multi-dev setups degrade fast — pointing Terraform or schemachange at a different target schema per developer is doable, but requires discipline the tooling won’t enforce for you.</p><p>Neither is painless at scale, but Databricks has the more elegant built-in answer here.</p><p><strong>Day-2 reality: debugging and observability</strong></p><p>The operational differences matter most when things go wrong.</p><p>Snowflake’s warehouse model makes failures relatively predictable — queries fail cleanly, errors surface clearly, and the execution model is familiar to anyone who’s debugged SQL before. Databricks is more flexible, but that flexibility means more moving parts: distributed compute failures, notebook state, cluster configuration. Lineage and observability tooling has improved significantly, but you’re still operating a distributed system with all the debugging complexity that implies.</p><p>Neither platform is hard to debug once you know it well. But Snowflake’s learning curve is shallower for teams coming from a SQL background — and that has real cost when something breaks at 2am.</p><h3><strong>Do you even need to choose?</strong></h3><p>Here’s something that doesn’t get said enough: you might not have to pick one and stick to it.</p><p>Open table formats — Apache Iceberg in particular — change the equation. Your data can live in S3 (or ADLS, or GCS) in an open format, and both Databricks and Snowflake can read and write to the same tables. <a href="https://www.mechanicalrock.io/blog/making-iceberg-work-on-aws">We’ve written about running Iceberg natively on AWS</a> — the same data accessible to Athena, Databricks, and Snowflake without copying or converting anything.</p><p>There’s also an underlying asymmetry worth naming here: Databricks is built on open standards — Delta Lake, Apache Spark, MLflow — while Snowflake’s ecosystem is more proprietary. For senior engineers who care about avoiding lock-in, that’s a real decision driver independent of the Iceberg question.</p><p>In theory, open formats mean you could use Snowflake for your SQL-heavy analytics workflows and Databricks for your ML workloads — both working off the same underlying data. No vendor lock-in, no duplication, no sync jobs.</p><p>In practice, it’s messier than that. Catalog fragmentation is real — two platforms with overlapping governance creates coordination overhead. Write coordination across engines requires careful design, or you’ll end up with conflicts or stale reads. Performance characteristics differ between engines on the same table. It’s worth understanding before you commit long-term — but go in expecting real operational complexity, not a clean architecture slide.</p><h3><strong>The real question</strong></h3><p>We’ve seen plenty of clients agonise over this decision. Ultimately it comes down to a few things:</p><p><strong>1. What does your team look like?</strong></p><p>SQL-heavy team? Snowflake. Python and ML people? Databricks. This is a good starting heuristic — but teams evolve. Optimising purely for today’s skillset can box you in later. The deeper question is whether you want a platform-first experience (Snowflake) or an engineering-first platform (Databricks) — that shapes everything from hiring to debugging to long-term architectural decisions.</p><p><strong>2. What are you trying to achieve?</strong></p><p>Pure analytics and BI? Snowflake. Advanced ML, real-time model serving, AI experimentation? Databricks. Somewhere in between? See point 1.</p><p><strong>3. What’s your appetite for operational overhead?</strong></p><p>Snowflake has a lower operational burden — it manages more for you, which is genuinely valuable. Databricks gives you more flexibility, but you own more of the responsibility. That trade-off is often the deciding factor in practice, especially for smaller teams.</p><p><strong>4. What does cost predictability look like for you?</strong></p><p>Snowflake is generally easier to reason about costs upfront. Databricks can be cheaper at scale, but it’s easier to misuse — compute costs in particular can surprise you if your workloads aren’t tuned. Neither platform is cheap if you’re not paying attention.</p><p><strong>5. Who’s already paying the bills?</strong></p><p>Let’s be honest — the most common outcome is that a client is already on one platform and wants to get more out of it, not start from scratch. Both platforms are genuinely capable. If you’re already on Snowflake and running well, you don’t need Databricks. The inverse is equally true.</p><p>If you are genuinely starting from scratch with no constraints — we’d default to Databricks for data-product and ML-heavy workloads, and Snowflake for analytics-first organisations that want something approachable and low-maintenance.</p><p>Both are good platforms. The right choice depends on where you’re coming from and where you want to go.</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/databricks-and-snowflake-where-things-stand-today">the Mechanical Rock website</a>.<br>Here at <a href="https://www.mechanicalrock.io/">Mechanical Rock</a>, we love finding solutions to customers’ problems and trying out new technologies. If you have challenges you’d like help with, please don’t hesitate to <a href="https://www.mechanicalrock.io/lets-get-started">get in touch</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f43216317cfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Iceberg Work on AWS: Architecture, Automation, and Analytics]]></title>
            <link>https://maciejtarsa.medium.com/making-iceberg-work-on-aws-architecture-automation-and-analytics-a618c10267d4?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a618c10267d4</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 05:49:58 GMT</pubDate>
            <atom:updated>2026-04-17T05:49:58.554Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was first published on <a href="https://www.mechanicalrock.io/blog/making-iceberg-work-on-aws">the Mechanical Rock website</a>.</p><p>We recently built a data pipeline to ingest data from various APIs into AWS, making it easily accessible and queryable by multiple teams. To achieve this, we used AWS Fargate to pull data from APIs, stored it in S3, and leveraged Apache Iceberg to add structure and enable analytics capabilities.</p><p>While Iceberg wasn’t a strict requirement, we chose it to provide a structured layer over raw S3 data and unlock advanced analytics features. However, deploying Iceberg effectively in a native AWS environment involves navigating several architectural decisions and trade-offs.</p><p>This post walks through the practical aspects of deploying and operating Iceberg on AWS — covering the architectural options we evaluated, the trade-offs we encountered, and the solutions we ultimately implemented.</p><h3><strong>Project Overview</strong></h3><p>Our initial focus was on Power BI access, with plans to support Databricks in the future, so interoperability was a key consideration from the start.</p><p>We chose <a href="https://aws.amazon.com/fargate/">AWS Fargate</a> for its serverless simplicity and <a href="https://developer.hashicorp.com/terraform">Terraform</a> to automate infrastructure provisioning, keeping the setup maintainable and repeatable.</p><p>The solution consisted of two main components:</p><p>1. <strong>Ingestion logic</strong> — A Python application running in Fargate</p><p>2. <strong>Infrastructure</strong> — Managed with Terraform</p><p>Our CI/CD pipeline builds the application into a Docker container, pushes it to ECR, and then uses Terraform to deploy the necessary AWS resources, including the Fargate task and EventBridge schedule.</p><p>Throughout the project, we prioritized simplicity and maintainability to make it easy for other teams to understand, operate, and extend the solution. The diagram below shows the overall architecture and key components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i79J7b_Yh7Ib-AxD1iigsA.png" /><figcaption>Iceberg on AWS architecture diagram</figcaption></figure><h3><strong>Why Apache Iceberg</strong></h3><p>Apache Iceberg has quickly become the go-to table format for modern data lakes — and for good reason. It brings structure and powerful features to your data lake, allowing you to layer a table abstraction over collections of files without the need for a full data platform. One of Iceberg’s biggest strengths is interoperability: multiple query engines can access and manipulate the same data seamlessly.</p><p>As an Open Table Format (OTF), Iceberg acts as a metadata layer on top of your data files, using supporting files such as:</p><ul><li><strong>Metadata files</strong> to track table state, schema changes, and partition evolution</li><li><strong>Manifest lists</strong> to reference manifests for a snapshot</li><li><strong>Manifest files</strong> to summarize partitions and provide file-level statistics</li></ul><p>Key reasons to adopt Iceberg include:</p><ul><li>Cross-platform and multi-engine support</li><li>Familiar SQL interface for querying and data manipulation</li><li>Schema and partition evolution without rewriting tables</li><li>Built-in versioning, time travel, and rollback</li><li>Safe handling of concurrent reads and writes</li></ul><p>Iceberg’s design makes it possible to build robust, flexible, and future-proof data architectures — especially in environments where multiple tools and teams need to work with the same underlying data.</p><h3><strong>Iceberg drawbacks</strong></h3><p>Despite its advantages, Iceberg comes with some trade-offs. Managing Iceberg tables adds operational complexity compared to simply querying raw files in S3. Tables rely on a catalog (like AWS Glue) and generate metadata, manifest, and snapshot files that require ongoing maintenance — without regular cleanup, metadata can accumulate and slow down query planning.</p><p>Interoperability, while a core goal, is more mature for reads than for writes. Write support and semantics can differ between engines, often leading teams to standardise on a single engine for writes and use others mainly for querying.</p><p>There are also cost implications on AWS: Iceberg increases S3 API calls and storage usage due to metadata and snapshot retention. Finally, as a relatively young ecosystem, Iceberg requires specialised knowledge to operate effectively, which can slow adoption for some teams.</p><h3><strong>Solution on AWS</strong></h3><p>With AWS as our core platform, we explored several approaches for implementing Iceberg tables.</p><p><strong>S3 tables</strong></p><p>Amazon S3 tables are a relatively new feature that make Apache Iceberg tables natively available in S3, eliminating the need to manage Iceberg directly. The main advantage is that AWS handles table maintenance for you — there’s no need to manually run compaction, manage snapshots, or clean up unused files.</p><p>However, exposing S3 tables to query engines like Athena requires Lake Formation, which currently involves some manual setup in the AWS UI and cannot be fully automated.</p><p>We also encountered several limitations with S3 tables and Terraform:</p><ul><li>Only primitive types are supported (no STRUCTs or other complex types)</li><li>No schema evolution — adding a column recreates the table instead of altering it (a Terraform limitation)</li><li>To avoid unwanted table recreation, you can add ignore_changes to metadata and manage schema changes elsewhere, such as in Athena:</li></ul><pre>  lifecycle {<br>    ignore_changes = [metadata]<br>  }</pre><p>Finally, interoperability between S3 tables and Databricks is limited. Since we wanted to eventually access these tables from Databricks, we decided against using S3 tables for our solution.</p><p><strong>Glue</strong></p><p>Because Iceberg tables require a catalog to manage metadata and enable interoperability across engines, we initially looked at AWS Glue as the natural choice on AWS. However, we quickly encountered a key limitation: Iceberg tables cannot be created using native Glue Catalog table definitions via Terraform. This is because Iceberg’s metadata layer must be initialized by an Iceberg-aware compute engine (such as Athena, EMR Spark, or the Iceberg AWS library), which goes beyond Glue’s declarative schema capabilities.</p><p>To work around this, we tried an infrastructure-as-code approach using Terraform’s null_resource with local-exec provisioners to run Athena DDL queries, allowing us to initialize the Iceberg metadata structure while keeping table definitions in version control. While this hybrid method works, it’s less declarative and adds complexity.</p><p>Ultimately, we moved away from this approach. Since we were already using Python for our main logic, we shifted to creating Iceberg tables via Athena directly from the app. This works well for infrequent runs, but for more frequent ingestion, we’d likely separate table creation and ingestion into distinct tasks.</p><p><strong>Amazon Athena</strong></p><p>Ultimately, we performed most of our operations using Amazon Athena. Our Python task generated the necessary SQL for table creation and submitted it to Athena, polling asynchronously for results — which were nearly instantaneous for empty tables.</p><p>A typical Athena query to create an Iceberg table looked like this:</p><pre>CREATE TABLE IF NOT EXISTS landing.source_table (<br>  id int COMMENT &#39;Unique identifier (primary key)&#39;,<br>  objectType string COMMENT &#39;Object type&#39;,<br>  ...<br>  _ingested_at timestamp(3) COMMENT &#39;Timestamp when record was loaded into Iceberg&#39;,<br>  _source_file string COMMENT &#39;Full S3 path to the source file&#39;,<br>  _is_current boolean COMMENT &#39;True if this is the current version of the record&#39;,<br>  _valid_from timestamp(3) COMMENT &#39;Timestamp when this version became valid&#39;,<br>  _valid_to timestamp(3) COMMENT &#39;Timestamp when this version was superseded (NULL for current)&#39;<br>)<br>COMMENT &#39;Table comment&#39;<br>LOCATION &#39;s3://iceberg-bucket/landing/source/table/&#39;<br>TBLPROPERTIES (<br>  &#39;table_type&#39;=&#39;ICEBERG&#39;,<br>  &#39;format&#39;=&#39;parquet&#39;,<br>  &#39;write_compression&#39;=&#39;snappy&#39;<br>)</pre><p>We also used Athena for ingestion. The Python script extracted data from the API and loaded it into S3 in its raw form (e.g., in raw/{source_name}/{endpoint_name}). We then implemented a four-step process to support slowly changing dimensions (SCD2), ensuring that duplicate records were not created when the same data was received from the APIs.</p><p><strong>Step 1: Create an external table (worked like a dream with JSON files)</strong></p><pre>CREATE EXTERNAL TABLE IF NOT EXISTS raw.temp_source_table (<br>  id int, objectType string,<br>  ...<br>)<br>ROW FORMAT SERDE &#39;org.openx.data.jsonserde.JsonSerDe&#39;<br>LOCATION &#39;s3://riceberg-bucket/raw/source/table/20260128_155042/&#39;</pre><p><strong>Step 2: Execute a merge operation to invalidate old rows if changed</strong></p><pre>MERGE INTO landing.source_table AS target<br>USING (<br>  SELECT *<br>  FROM (<br>      SELECT *, ROW_NUMBER() OVER (PARTITION BY id) AS rn, &quot;$path&quot; as source_path<br>      FROM raw.temp_source_table<br>  ) s<br>  WHERE s.rn = 1<br>) AS source<br>ON target.id = source.id AND target._is_current = true<br>WHEN MATCHED AND (COALESCE(target.objectType, NULL) &lt;&gt; (COALESCE(source.objectType, NULL)) OR ... ) THEN<br>    UPDATE SET <br>        _is_current = false,<br>        _valid_to = current_timestamp</pre><p>We use COALESCE here to make the comparison between source and target columns NULL safe. In SQL, direct comparisons involving NULLs do not behave as expected — NULL is not equal to anything, not even another NULL. By wrapping both sides of the comparison with COALESCE, we ensure that two NULLs are treated as equal, and a NULL on one side and a value on the other are treated as different.</p><p>This logic is crucial for implementing slowly changing dimensions (SCD2) in our ingestion process. We only want to update the state of an existing record if the new version has actually changed — if all relevant fields remain the same (including handling of NULLs), we avoid unnecessary updates. This prevents data from being reingested or duplicated during full loads from the source (for example, when an API endpoint returns all records every time, not just the changed ones). As a result, our table remains clean, efficient, and only reflects true changes in the source data.</p><p><strong>Step 3: Insert new records</strong></p><pre>INSERT INTO landing.source_table (id, objectType, ..., _ingested_at, _source_file, _is_current, _valid_from, _valid_to)<br>SELECT (id, objectType, ..., current_timestamp, source.source_path, true, current_timestamp, CAST(NULL AS timestamp(3)))<br>FROM (<br>  SELECT *, ROW_NUMBER() OVER (PARTITION BY id) AS rn, \&quot;$path\&quot; as source_path<br>  FROM raw.temp_source_table<br>) source<br>LEFT JOIN landing.source_table target<br>  ON target.id = source.id AND target._is_current = true<br>WHERE source.rn = 1 AND (<br>  target.id IS NULL<br>  OR (COALESCE(target.objectType, NULL) &lt;&gt; (COALESCE(source.objectType, NULL))) OR ...<br>  )</pre><p><strong>Step 4: Post ingestion, drop the external table</strong></p><pre>DROP TABLE IF EXISTS raw.temp_source_table</pre><p>Keeping the raw data as it comes from the API also had its benefits. If something failed later in the pipeline, the process could simply retry on the next run. We used `.pending` and `.complete` markers in S3 to track job status — at the start of each task, the script would look for any pending jobs and attempt to re-process them if needed. This approach improved reliability and made error recovery straightforward.</p><p><strong>Takeaways</strong></p><p>Apache Iceberg on AWS provides a robust foundation for modern data lakes, enabling features like schema evolution, ACID transactions, and cross-platform analytics. While it introduces some operational complexity — especially around metadata management and ingestion logic — these are manageable with the right automation and design patterns.</p><p>By leveraging AWS services and careful pipeline design, we achieved reliable, efficient data ingestion that avoids unnecessary updates and supports future analytics needs. Iceberg’s flexibility and open standards make it a strong choice for evolving data architectures on AWS.</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/making-iceberg-work-on-aws">the Mechanical Rock website</a>.<br>Here at <a href="https://www.mechanicalrock.io/">Mechanical Rock</a>, we love finding solutions to customers’ problems and trying out new technologies. If you have challenges you’d like help with, please don’t hesitate to <a href="https://www.mechanicalrock.io/lets-get-started">get in touch</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a618c10267d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taking Snowflake CoCo CLI for a Spin]]></title>
            <link>https://maciejtarsa.medium.com/taking-snowflake-cortex-code-cli-for-a-spin-3035e81cc8ef?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3035e81cc8ef</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[snowflake-cortex]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 01:36:34 GMT</pubDate>
            <atom:updated>2026-07-22T11:10:41.536Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was first published on the <a href="https://www.mechanicalrock.io/blog/taking-snowflake-cortex-code-cli-for-a-spin">Mechanical Rock website</a>.</p><p>Snowflake has just released the <a href="https://www.snowflake.com/en/product/features/cortex-code/">Snowflake CoCo CLI</a> — a native AI coding agent that claims to understand Snowflake’s data, compute, governance and operational semantics.</p><p>Until now, AI tools haven’t been particularly helpful for developing on Snowflake. When I asked ChatGPT for Snowflake queries, it often produced syntax that doesn’t exist in Snowflake. If anyone asked, I would have said: don’t use AI for Snowflake help.</p><p>So, is Snowflake CoCo CLI any better? Let’s find out.</p><p>We have a Snowflake Sandbox account that I’ve been meaning to clean up — removing roles, warehouses, and databases that are no longer needed. This seems like a great opportunity to automate the process, so that’s what I’ll focus on here.</p><h3><strong>Let’s set it up</strong></h3><p>Installation is easy</p><pre>curl -LsS https://ai.snowflake.com/static/cc-scripts/install.sh | sh</pre><p>Once installed, type <em>codex</em> into the terminal and go through the CLI guide to set up your preferences, connection etc. Very similar to other coding CLI agents. In fact — it looks VERY similar to Claude Code…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPKh_droI7fn-XYzRkeowQ.png" /><figcaption>Side by side image of Snowflake CoCo CLI and Claude Code CLI</figcaption></figure><p>This is where I came across the first issue — it’s been a while since anyone used our Snowflake Sandbox account, hence there were a few things to enable on the account level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sY8EplsT3i2xPdos1ejjSQ.png" /><figcaption>Error requiring access to AI models</figcaption></figure><p>So let’s run some commands in Snowflake to allow models</p><pre>ALTER ACCOUNT SET CORTEX_MODELS_ALLOWLIST = &#39;All&#39;;<br>-- the following command will take a few minutes to run<br>CALL SNOWFLAKE.MODELS.CORTEX_BASE_MODELS_REFRESH();<br>SHOW MODELS IN SNOWFLAKE.MODELS;</pre><p>And because we’re in Australia, we also need to enable cross region inference as the models we need are not currently available in Australia.</p><pre>ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = &#39;ANY_REGION&#39;;</pre><p>Once that is done, we should be able to use CoCo!</p><h3><strong>Plan</strong></h3><p>First, let’s plan what to do. I am going to ask CoCo to:</p><blockquote>I want to plan some tidy up in my account. I would like to clear roles, warehouse and databases that hasn’t been used or accessed in the past 6 months. I would like you to generate a plan for each and list them for me, I want to approve the list of the items to be removed before any action is taken — as I may have reason to keep some of them.</blockquote><p>Let’s see how it goes. (Note: I redacted some of the details in the screenshots to protect the names of our clients and employees, past and present.)</p><p>A bit of a bumpy start at the beginning as no warehouse was selected</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rWSGwulQigvVlkA4djrX0g.png" /><figcaption>Initial errors from planning phase</figcaption></figure><p>Despite this, the agent seems to be recovering and accessing the data I need</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*mCDo3MXOGMGZPmgrv2NfDg.png" /><figcaption>Agent recovering from errors and accessing required data</figcaption></figure><p>And at the end, I am getting a plan with separate sections for databases, warehouses and roles</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*xTPbYm4VV7tDjdDqCozF4w.png" /><figcaption>Plan for databasese</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*c2pKfaX5BnzYWA7T1NLaVA.png" /><figcaption>Plan for warehouses</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*lQGWpKOBF4YCJkHgaB-lKA.png" /><figcaption>Plan for roles</figcaption></figure><p>And an overall plan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*ejksD7Wxx1EKR0BlhwC9TA.png" /><figcaption>Overall plan</figcaption></figure><p>This is great. Let’s say I don’t want to make those changes now, let’s save the lists to a .md file where I can review them and mark the ones I want to keep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*obR2Y5qRiJe-m-lP4jaSbw.png" /><figcaption>Message confirming a plan has been saved</figcaption></figure><h3><strong>Plan execution</strong></h3><p>I want to simulate leaving the last session and starting again. I reviewed the list CoCo created, marked the items I want to keep and will now start a new session.</p><blockquote>In the last session, I asked you to generate a list of warehouses, databases and roles to remove, based on when they were last used. I now marked the ones I want to keep and would like to proceed with their deletion. I want to do this in stages, starting with database, then warehouses and finally roles. Read file account_cleanup_review.md and generate the plan for deletion of databases.</blockquote><p>The resulting plan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*6dVbM4Y4_p1rzrAHo8Y-9w.png" /><figcaption>Plan for dropping databases</figcaption></figure><p>I was happy to go ahead and start the deletion process. At this stage CoCo double checked that I want to run the first SQL statement</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*avnpTjxGUqa9PuarqLr9Cw.png" /><figcaption>Confirmation for dropping database</figcaption></figure><p>I was able to either confirm each statement or give it permission to run all the statements in that session.</p><p>Once done, I also get a confirmation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*hxtdKvFQFHEACHziM1l6Ag.png" /><figcaption>Confirmation that databases were dropped</figcaption></figure><p>The same approach applied to warehouses and roles — no manual clicking, no repetitive SQL. <strong>What would normally take hours was finished in minutes.</strong> For recurring tasks like this, save the prompt and reuse it with Codex going forward.</p><h3><strong>What else can CoCo to?</strong></h3><p>According to Snowflake — quite a lot, including:</p><ul><li>Finding data that has PII</li><li>Showing lineage for a table</li><li>Generating queries</li><li>Explaining why queries are slow and suggesting optimisations</li><li>Build Streamlit applications</li><li>Create dbt projects</li><li>Answer questions using semantic models</li></ul><p>More information is available in <a href="https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code-cli">Snowflake documentation</a></p><p>Let’s test one of these, let’s create a simple Streamlit app.</p><p><strong>Streamnlit app</strong></p><p>In plan mode, I prompted</p><blockquote>Let’s create a simple Streamlit app that will allow us to enter some data into Snowflake. Under DATA_INTERVIEWS database, I want you to create a new schema called CORTEX_TEST. I want to have a table there that will store customer preferences for receiving notifications (post/email/mobile) and I want a streamlit app that will have a form to enter new preferences. Plan this soltuion.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*kcaX8aQlV2HQH5zRncNLWw.png" /><figcaption>A plan for Streamlit application</figcaption></figure><p>There were a few steps to confirm, so I took my time to see what was happening. I ran into some permission issues, but the agent quickly adapted by creating a STAGE and uploading the Streamlit files there. At one point, the agent tried to open a Snowflake window in my browser, but I was using the wrong Chrome profile. I had to stop the agent and restart the deployment. Once everything was sorted, I was able to see the new Streamlit app in my Snowflake account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJO_BBN4dWH0QRzYkFkXLw.png" /><figcaption>Initial Streamlit app error</figcaption></figure><p>The app wasn’t quite what I expected at first, but hey, no big deal — I just grabbed a screenshot and showed it to the agent. It made some tweaks, which caused another error, then another fix, and so on.</p><p>After a few back-and-forths, I finally had a working Streamlit app. Maybe I should’ve tried running it locally first, but whatever — the app works!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*dJqsz_9bbO8nnwAPFSQpwA.png" /><figcaption>Initial Streamlit app — adding new user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*lJ9gwoO8EVo6RrIiBDvFfA.png" /><figcaption>Initial Streamlit app — viewing users</figcaption></figure><p>Sure — the app is not great — but it’s a start. I also wanted it simple, hence why I skipped validation to begin with. It is also something I created and deployed within a few minutes.</p><p>CoCo even suggested how I should deploy this with best DevOps practices in mind</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jkQ54yZjCurah9tJ9ghUMA.png" /><figcaption>DevOps deployment suggestions</figcaption></figure><p>Of course at the end, I asked CoCo to delete everything it created in Snowflake for this demo — which it did easily.</p><h3><strong>Takeaways</strong></h3><p>If you’ve used tools like Claude Code before, Snowflake CoCo will feel very familiar. In fact, when asked about it CoCo admits that:</p><blockquote>CoCo is built on Claude Code’s foundation — same core architecture and interaction patterns. The main additions are Snowflake-native integrations: SQL execution, connections, stages, Streamlit deployment, Cortex AI functions, etc.</blockquote><blockquote>You’ll notice the familiar tools (Read, Edit, Bash, Task agents) plus Snowflake-specific ones like snowflake_sql_execute and the #TABLE syntax for pulling schemas.</blockquote><p><strong>For Snowflake teams, an AI code assistant that understands your environment can be a game changer.</strong> CoCo won’t replace good engineering judgment — but it can dramatically amplify it.</p><p>Apply the usual AI caveats, review what it produces, and use it as leverage — not autopilot.</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/taking-snowflake-cortex-code-cli-for-a-spin">Mechanical Rock website</a>. <br>Here at <a href="https://www.mechanicalrock.io/">Mechanical Rock</a>, we don’t sit still. When new tools come out, we pick them up and try them out. If you have any use cases where Snowflake CoCo could help, or have some innovative idea you want to bring to life <a href="https://www.mechanicalrock.io/lets-get-started">let us know</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><p>Since publication, Snowflake Cortex Code has been renamed to Snowflake CoCo, the article has been updated to reflect that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3035e81cc8ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Ode to Databricks Asset Bundles]]></title>
            <link>https://maciejtarsa.medium.com/an-ode-to-databricks-asset-bundles-b13d1b938aab?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b13d1b938aab</guid>
            <category><![CDATA[dataops]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 03:21:40 GMT</pubDate>
            <atom:updated>2026-04-13T00:28:43.165Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>An Ode to </strong>Declarative Automation Bundles (formerly Databricks Asset Bundles)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzujBuyXcVlUgFQxxvHLSA.png" /></figure><p>This article was first published on the <a href="https://www.mechanicalrock.io/blog/an-ode-to-databricks-asset-bundles">Mechanical Rock website</a>.</p><p>If you are on Databricks and not using Asset Bundles, you are missing out. If you are on a different data platform — you are also missing out, and probably wish you were on Databricks. None of the other platforms have anything quite equivalent that makes development and deployment workflows this smooth.</p><p>Declarative Automation Bundles (DABs) allow you to deploy code, workflows, and workspace-level resources as a single unit by declaratively defining them in YAML files. They bridge the gap between higher-level infrastructure management (where tools like Terraform or OpenTofu shine) and UI-driven development in the Databricks workspace.</p><p>And let’s be honest — YAML is king these days!</p><h3><strong>Some of the killer features in DABs:</strong></h3><p><strong>Targets</strong></p><p>Targets enable reproducible deployments across multiple environments, very similar to dbt profiles. The same bundle can be deployed to dev, test, or prod with environment-specific configuration.</p><p><strong>Variables</strong></p><p>Variables let you control deployment behaviour per environment. For example, you might deploy a pipeline in a paused state in dev, but automatically unpause it in production.</p><p><strong>Deployment mode (multi-user development)</strong></p><p>In development mode, multiple users can work on the same bundle without stepping on each other’s toes. Databricks automatically prefixes deployed resources with the developer’s username, making it easy to distinguish who owns what.</p><p><strong>Notebooks as Python or SQL files</strong></p><p>One of the most underrated features: you can write notebooks as .py or .sql files, as long as they include the Databricks notebook header.</p><p>Example `sample_task.py`:</p><pre># Databricks notebook source<br><br># COMMAND ----------<br># DBTITLE 1,Set the parameters<br>dbutils.widgets.text(&quot;environment&quot;,&quot;dev&quot;)<br>env = dbutils.widgets.get(&quot;environment&quot;)<br><br># COMMAND ----------<br># DBTITLE 1,Create Schemas<br># Create control schema in bronze catalog<br>spark.sql(f&quot;create schema if not exists {env}_bronze.control&quot;)</pre><p>And the job definition that calls this notebook:</p><pre>resources:<br> jobs:<br>   sample_job:<br>     name: sample_job<br>     email_notifications:<br>       on_failure:<br>         - ${var.email_notifications}<br>     tasks:<br>       - task_key: sample_task<br>         notebook_task:<br>           notebook_path: &quot;sample_task.py&quot;</pre><p>This approach gives you the best of both worlds:</p><ul><li>Clean, git-friendly Python and SQL files</li><li>Full notebook behaviour inside Databricks</li><li>Easy deployment via Asset Bundles</li></ul><p><strong>Config-driven development</strong></p><p>DABs encourage truly config-driven workflows. You can build reusable Python logic that reads from configuration files defining tables, sources, or pipelines. Adding a new table often means changing config only — no need to touch the core code.</p><p><strong>Permission management</strong></p><p>Asset Bundles can manage permissions alongside resource creation, both at the workspace level and per resource.</p><p>Example workspace-level permissions in a target:</p><pre>targets:<br> dev:<br>   workspace:<br>     host: https://xxx.cloud.databricks.com/<br>     root_path: /Shared/.bundle/${bundle.name}/${bundle.target}<br>   permissions:<br>     - group_name: dev_admin_group<br>       level: CAN_MANAGE<br>     - group_name: dev_developer_group<br>       level: CAN_VIEW</pre><p>Example workspace-level permissions in a target:</p><pre>resources:<br> dashboards:<br>   pipelines_dashboard:<br>     display_name: Pipelines Dashboard<br>     warehouse_id: ${var.warehouse_id}<br>     file_path: config/pipelines_dashboard.lvdash.json<br>     embed_credentials: true<br>     permissions:<br>       - group_name: ${var.env_code}_developer_group<br>         level: CAN_RUN<br>       - group_name: ${var.env_code}_admin_group<br>         level: CAN_RUN</pre><p><strong>Validation</strong></p><p>`databricks bundle validate` checks your YAML for syntax and correctness before deployment. It’s ideal for CI/CD pipelines to prevent configuration errors from sneaking in.</p><p>This validation complements — but does not replace — testing and validation of your SQL and Python logic.</p><p><strong>UI export</strong></p><p>You don’t need to write everything from scratch. Many supported resources can be created (or partially created) in the Databricks UI and then exported to YAML. You’ll usually need to replace hard-coded values with variables, but it’s a great way to experiment and discover available parameters.</p><p><strong>Custom bundle templates</strong></p><p>Beyond Databricks’ starter templates, you can create your own. This is especially useful in larger organisations where you want to enforce standards and reuse common patterns from day one.</p><h3><strong>What we’d like to see next</strong></h3><p><strong>Selective deployment</strong></p><p>Something akin to dbt’s ` — select`, allowing only specific resources to be deployed from a bundle. This would be particularly useful in development.</p><p><strong>Conditional logic or templating</strong></p><p>Native Jinja support or conditional resource creation would unlock even more flexibility.</p><h3>Getting started</h3><p>Getting started with Asset Bundles is refreshingly simple.</p><p>Follow one of <a href="https://docs.databricks.com/aws/en/dev-tools/bundles/tutorials">the official Databricks tutorials</a>. All you need is a Databricks account and a terminal.</p><pre>databricks bundle init</pre><p>This launches a friendly wizard that helps you choose a template and configure your project.</p><p>Before deploying, validate your bundle:</p><pre>databricks bundle validate</pre><p>Deploy to dev:</p><pre>databricks bundle deploy --target dev --profile dev</pre><p>Run a specific job or pipeline:</p><pre>databricks bundle run --target dev job_name</pre><p>Destroy resources when you’re done:</p><pre>databricks bundle destroy --target dev</pre><h3><strong>Learning resources and examples</strong></h3><p>Databricks provides a solid and continually growing set of resources to help you get up to speed with Asset Bundles.</p><p><a href="https://docs.databricks.com/aws/en/dev-tools/bundles/resources">The current list of supported bundle resources</a> is available in the official documentation. New resource types are added regularly, so it’s worth checking back as Asset Bundles continue to evolve.</p><p>In addition, Databricks maintains <a href="https://docs.databricks.com/aws/en/dev-tools/bundles/examples">a set of sample Asset Bundles</a> that demonstrate common patterns and best practices across different use cases</p><p>These examples are a great reference when you’re trying to understand how a particular resource is defined in YAML or how multiple resources fit together in a real-world bundle.</p><h3><strong>Best practice tips</strong></h3><ul><li>Use one workspace per environment (e.g. dev, test, prod)</li><li>Split workloads across multiple Asset Bundle repos as your platform grows (e.g. ingestion, control logic, data modelling)</li><li>Deploy to dev locally; deploy to higher environments via CI/CD</li><li>When introducing new resource types, prototype them in the UI first and export to YAML</li></ul><h3><strong>Takeaways</strong></h3><p>Declarative Automation Bundles are a powerful addition to the Databricks ecosystem. They simplify development workflows, encourage best practices, and make collaboration significantly easier. Combined with source control and Terraform for underlying infrastructure, they complete the Databricks resource management story.</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/an-ode-to-databricks-asset-bundles">Mechanical Rock website</a>. If you’re in the Perth area and want to chat about or get help with implementing Databricks for your data stack, <a href="https://www.mechanicalrock.io/lets-get-started">please reach out to Mechanical Rock team</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><p>Since publication, Databricks Asset Bundles have been renamed to Declarative Automation Bundles, the article has been updated to reflect that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b13d1b938aab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running dbt projects on Snowflake]]></title>
            <link>https://maciejtarsa.medium.com/running-dbt-projects-on-snowflake-4e6d76b16139?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e6d76b16139</guid>
            <category><![CDATA[snowflake-data-cloud]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Fri, 04 Jul 2025 02:28:25 GMT</pubDate>
            <atom:updated>2026-01-12T04:13:29.070Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Anq4b75Dg7STBE6N5NH2hQ.png" /></figure><p>This article was first published on the <a href="https://www.mechanicalrock.io/blog/running-dbt-on-snowflake">Mechanical Rock website</a>.</p><p>We’ve seen dbt being run manually from the local CLI, in dbt Cloud, using Cosmos in managed Airflow, using Databricks tasks, as well as in CI/CD pipelines. But Snowflake just introduced another way to run it natively on their platform — with their new Workspaces feature and Git integration. Let’s give it a go.</p><p>But why is it important? We’ve had clients who used Apache Airflow exclusively for orchestrating dbt workloads, and others who started with CI/CD pipelines but eventually needed to move to a more advanced orchestrator. In both cases, while another tool is used for the orchestration of the dbt workload, the bulk of the compute happens in Snowflake. Having the ability to run dbt natively on Snowflake could be a game changer for these workloads — completely removing the need to spend money and resources on other compute.</p><h3><strong>Disclaimer about dbt Fusion</strong></h3><p>The timing of this new feature introduction in Snowflake comes shortly after dbt Labs announced dbt Fusion — a new Rust-based engine for dbt transformations. There is currently a lot of confusion about what this means for dbt Core customers, with some speculation about the potential discontinuation of dbt Core altogether. While there is some risk in investing in the migration of dbt Core orchestration, dbt Labs has stated that there will be no changes to dbt Core’s license, support, or maintenance. For specific details, please refer to <a href="https://www.getdbt.com/licenses-faq">the dbt Licensing FAQ</a>.</p><h3><strong>Setup</strong></h3><p><strong>dbt project</strong></p><p>The most likely use case is bringing an existing dbt project into Workspaces. For this reason, we’ll use a sample dbt project with some existing models. Snowflake provides <a href="https://github.com/Snowflake-Labs/getting-started-with-dbt-on-snowflake">a sample dbt project</a> that can be used. We’re going to copy the contents of the `tasty_bytes_dbt_demo` directory into our `dbt` directory for Snowflake Git integration to pick them up.</p><p>Apart from some name changes, we will keep it almost the same as in the sample repo. One notable difference is that we want to access a private Git repository, so we will need a secret object that stores our GitHub API credentials. As in the sample repo, we will have two environments — `dev` and `prod`. We will assume that, until now, we have been running this project somewhere else, such as in an Airflow instance or through manual calls from the CLI.</p><p><strong>Snowflake Requirements</strong></p><p>Workspaces are currently in preview in Snowflake. Preview features will need to be enabled on your account using the `ACCOUNTADMIN` role.</p><pre>-- To check the status of your account settings for preview access<br>SELECT SYSTEM$GET_PREVIEW_ACCESS_STATUS();<br>-- To enable preview features<br>SELECT SYSTEM$ENABLE_PREVIEW_ACCESS();</pre><p>For more information on accessing preview features, check out <a href="https://docs.snowflake.com/en/release-notes/preview-features">Snowflake Documentation</a>.</p><p>Workspaces for dbt Projects also require Personal databases to be enabled. This can be done using the `ACCOUNTADMIN` role.</p><pre>-- to enable personal database on account level<br>ALTER ACCOUNT SET ENABLE_PERSONAL_DATABASE = TRUE;<br>-- or for specific user only<br>ALTER USER &quot;USERNAME&quot; SET ENABLE_PERSONAL_DATABASE = TRUE;</pre><p>Secondary roles access is another requirement. This can be enabled for a user</p><pre>ALTER USER &quot;USERNAME&quot; SET DEFAULT_SECONDARY_ROLES = (&#39;ALL&#39;);</pre><p>Importantly, if your account has a session policy which disables use of secondary roles, you will not have access to Workspaces. I got stuck on this for a while, as the errors returned from Snowflake were not very descriptive.</p><p>Other requirements are related to Git integration — a secret if your repository is private — and an API integration object.</p><pre>-- replace the values with your username and Git API token<br>CREATE OR REPLACE SECRET git_secret<br>  TYPE = password<br>  USERNAME = &#39;git_username&#39;<br>  PASSWORD = &#39;git_token&#39;;<br><br>-- replace the url with your Git account<br>CREATE OR REPLACE API INTEGRATION git_api_integration<br>  API_PROVIDER = git_https_api<br>  API_ALLOWED_PREFIXES = (&#39;https://github.com/my-account&#39;)<br>  ALLOWED_AUTHENTICATION_SECRETS = (dbt_demo.integrations.git_secret)<br>  ENABLED = TRUE;</pre><p>Finally, if you require any dbt packages, a network rule and external access integration will be required.</p><pre>-- add additional URLs if required<br>CREATE OR REPLACE NETWORK RULE dbt_network_rule<br>  MODE = EGRESS<br>  TYPE = HOST_PORT<br>  -- Minimal URL allowlist that is required for dbt deps<br>  VALUE_LIST = (<br>    &#39;hub.getdbt.com&#39;,<br>    &#39;codeload.github.com&#39;<br>    );<br><br>CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION dbt_ext_access<br>  ALLOWED_NETWORK_RULES = (dbt_network_rule)<br>  ENABLED = TRUE;</pre><p>While you could now create a Git repository programmatically, there is currently no programmatic way to create a Workspace and connect it to an existing Git repository object. Hence, the next step needs to be done in the UI.</p><figure><img alt="Snowflake User interface for creating a Workspace" src="https://cdn-images-1.medium.com/max/599/1*fNt_m0pf8wMO88RTpxPTmQ.png" /><figcaption>Figure 1: Snowflake User Interface for creating a Workspace</figcaption></figure><p>In order to use the sample Git repo from Snowflake, we also need some sample data. Instructions on how to create and load it can be found in <a href="https://github.com/Snowflake-Labs/getting-started-with-dbt-on-snowflake/tree/main/tasty_bytes_dbt_demo/setup">the sample dbt project repo</a> or <a href="https://github.com/maciejtarsa/dbt-on-snowflake/tree/main/setup">the Git repo for this</a>.</p><h3><strong>Working example</strong></h3><p>dbt commands can be executed in the UI by selecting your project (based on directory), profile (based on your `profiles.yml` file), and dbt command from the drop-downs.</p><figure><img alt="Drop downs for running dbt commands" src="https://cdn-images-1.medium.com/max/806/1*EarQ-jvGPB2ZyUS7rYp_EA.png" /><figcaption>Figure 2: Running dbt commands</figcaption></figure><p>You can then inspect the outputs in the Outputs tab. Here’s an example of running `dbt deps`.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oe8yVWkG7ycdtfoRIkmDIg.png" /><figcaption>Figure 3: Output of running `dbt deps`</figcaption></figure><p>Equally, we can run `dbt compile`. As this command will produce a manifest, we will be able to inspect our dbt models visually on the DAG view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*vXQg4s9K1vBZyumQYt5gyQ.png" /><figcaption>Figure 4: Output of running `dbt compile`</figcaption></figure><p>Selecting a model in the DAG view also opens the source code for that model and highlights the file in the file tree, which is quite useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXdujdxa-31ulStlX5ISDA.png" /><figcaption>Figure 5: Dag view of compiled project</figcaption></figure><p>Unfortunately, selecting a lot of the models leaves us with a lot of open tabs in the editor, and they each need to be closed manually.</p><p>Anyway — time to run the models. The output is your standard `dbt run` output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*W2Om6H63dRw9b7YkuhIxog.png" /><figcaption>Figure 6: `dbt run` output</figcaption></figure><p>This is all well and good — we can run dbt in our personal Workspace, which is the equivalent of running it from your laptop.</p><p>Deployment is the next step. We need to deploy our dbt project from our Workspace — this will create a dbt project object. That object can then be used to schedule, run, and monitor a dbt project outside of the Workspace. It’s worth noting that a dbt project is a schema-level object and it supports role-based access control (RBAC).</p><p>This operation can either be done in the UI, or with the following Snowflake command:</p><pre>CREATE OR REPLACE DBT PROJECT DBT_DEMO.DEV.DBT_PROJECT_DEV<br> FROM snow://workspace/&quot;USER$MaciejTarsa&quot;.PUBLIC.&quot;dbt-on-snowflake&quot;/versions/live/dbt/;</pre><p>What’s interesting is that we’re creating it from a specific user’s Workspace. It would be interesting to see how multiple users can collaborate on a project at the same time, or better yet, if service accounts can be used for this purpose.</p><h3><strong>Running and scheduling</strong></h3><p>Ok, now that we have a dbt project object, let’s create a task that will execute it. The new `EXECUTE DBT PROJECT` command is helpful here. It can also be paired with arguments to specify models or dbt commands to run.</p><p>In the following example, we will schedule a dbt run in dev for a single model to run every hour at 5 minutes past the hour.</p><pre>CREATE OR REPLACE TASK dbt_demo.dev.run_prepped_data_dbt<br>        WAREHOUSE=dbt_wh<br>        SCHEDULE =&#39;USING CRON 5 * * * * UTC&#39;<br>      AS<br>  EXECUTE DBT PROJECT DBT_PROJECT_DEV ARGS=&#39;run --select customer_loyalty_metrics --target dev&#39;;<br>  ALTER TASK dbt_demo.dev.run_prepped_data_dbt RESUME;</pre><p>Note that a task can also be created in the UI of the Workspace from your dbt project. The task that runs the `EXECUTE DBT PROJECT` command needs to be in the same database and schema as the dbt project object.</p><h3><strong>Observability and alerts</strong></h3><p>An important aspect of working with dbt is the ability to monitor and inspect task execution — including drilling down to individual tasks and alerting relevant teams when model runs fail. I’m interested in understanding what Snowflake offers to support those needs.</p><p>dbt projects now have their own monitoring dashboard accessible through monitoring tools.</p><figure><img alt="dbt monitoring dashboard" src="https://cdn-images-1.medium.com/max/1024/1*X263CdVd51OsLPzuDu8gcw.png" /><figcaption>Figure 7: dbt monitoring dashboard</figcaption></figure><p>We can drill down on any individual run where we can see dbt output and telemetry tracing.</p><figure><img alt="dbt monitoring output" src="https://cdn-images-1.medium.com/max/1004/1*E9-YuTzKp7YnRF7VmafFTg.png" /><figcaption>Figure 8: dbt monitoring output</figcaption></figure><figure><img alt="dbt monitoring traces" src="https://cdn-images-1.medium.com/max/1024/1*ZtnIQDAhEudJ0xPRTvJT5w.png" /><figcaption>Figure 9: dbt monitoring traces</figcaption></figure><p>dbt run results are saved by Snowflake and can be exported to a named internal stage for further analysis if required. Apart from that — as we are using tasks here — all the usual Snowflake observability and monitoring can be used. For example, you could create a task which will monitor your dbt execution, and attach an alert that would notify of any failures.</p><h3><strong>Considerations and limitations</strong></h3><p>Workspaces are currently scoped to a user level. This means that you cannot create a Git repository with a dbt project in a shared database so that multiple users can collaborate on it — they would all need to create them individually in their Workspaces. Think of Workspaces like your individual environments. There is also currently no programmatic way to create Workspaces — they can only be created in the UI.</p><p>Working with Git in the Snowflake UI is quite painful at the start. It’s not quite as advanced as other Git tools — there’s also no support for using the command line. If you are used to running Git from the command line, this will feel very clunky to you — you are left with buttons for pushing, pulling, committing, etc. Running the Git commands is also quite slow; even adding a commit to a branch took a few seconds.</p><p>While the way you deploy a project as an object and schedule it with tasks is nice, I can see issues when multiple users deploy the same project simultaneously from their individual Workspaces. We need some way to deploy it from CI/CD — from the main branch only after the changes have been inspected and approved — not from individual users’ Workspaces. I expect having a service user’s Workspace would work here, but at the moment you cannot create a dbt project Workspace programmatically, so someone would still need to log into the UI as that service user.</p><p>There is still a way to develop and test models locally, then deploy and run them in higher environments directly in Snowflake. However, ideally, this should be paired with the ability to deploy from a Workspace that is not linked to any particular user.</p><h3>Conclusions</h3><p>Overall, this is a very interesting development and one worth watching. There are some clear benefits, such as not needing additional tools for your dbt runs or for integrating dbt results with native Snowflake monitoring. However, some critical features are still missing — especially the need to use an individual user’s Workspace for deployment. Nevertheless, if your stack currently relies on tools whose only job is to run dbt, fully switching to Snowflake is definitely worth considering. It is a good idea to experiment with this feature now, while it is still in preview, to see how it fits your workload and to be prepared for when it becomes generally available.</p><p>Some useful links to learn more:<br>- <a href="https://docs.snowflake.com/en/user-guide/ui-snowsight/workspaces">Snowflake Workspaces documentation</a><br>- <a href="https://docs.snowflake.com/en/user-guide/data-engineering/dbt-projects-on-snowflake">dbt projects on Snowflake</a><br>- <a href="https://docs.snowflake.com/en/user-guide/data-engineering/dbt-projects-on-snowflake-getting-started-tutorial">dbt projects on Snowflake getting started tutorial</a></p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/running-dbt-on-snowflake">Mechanical Rock website</a>. If you’re in the Perth area and want to chat about or get help with implementing Snowflake for your data stack, <a href="https://www.mechanicalrock.io/lets-get-started">please reach out to Mechanical Rock team</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e6d76b16139" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reduce that Snowflake spend!]]></title>
            <link>https://maciejtarsa.medium.com/reduce-that-snowflake-spend-763a56defdc6?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/763a56defdc6</guid>
            <category><![CDATA[snowflake-data-cloud]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cost-optimization]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Tue, 24 Jun 2025 05:26:45 GMT</pubDate>
            <atom:updated>2026-01-12T04:13:45.347Z</atom:updated>
            <content:encoded><![CDATA[<p>Tried and tested methods to reduce your Snowflake spending</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Om7mIDTRbHOaWyUeiOIoUQ.png" /></figure><p>This article was first published on the <a href="https://www.mechanicalrock.io/blog/reduce-that-snowflake-spend">Mechanical Rock website</a>.</p><p>Snowflake is a powerful data warehousing platform that makes it incredibly easy to onboard new workloads and data sources. In the early stages, the focus is often on rapid development and feature expansion — not cost. But as usage scales, so do expenses, and without proactive management, organisations can find themselves facing significantly higher bills than anticipated.</p><p>There are numerous posts out there with steps to optimise your Snowflake costs, hence we won’t be repeating them here. Today we’re presenting some of the more interesting aspects of Snowflake cost optimisations that we used and came across. That being said — <a href="https://ludic.mataroa.blog/blog/i-accidentally-saved-half-a-million-dollars/">don’t forget to reduce that auto-suspend</a>!</p><h3><strong>Right size compute</strong></h3><p>General purpose warehouses are handy — you can assign the same warehouse to all users and they can take advantage of query co-location. But soon, some workloads will require more compute and you may end up increasing the size of your general purpose warehouse. Now, even the tiniest of queries will potentially cost twice as much or more. It’s a double edged sword. The question of consolidating your warehouses into a single one versus splitting one into multiples is never a final decision — you should be regularly revisiting it. And the best solution is probably a mix of both.</p><p>For example, if you have multiple workloads of similar complexity running at the same time, but hitting different warehouses, it may be a good idea to consolidate these into a single warehouse. However, if you have many different workloads (especially if some are light queries and some heavier queries) hitting the same warehouse, it may be worth considering splitting it into multiple warehouses. Light queries can run on the smallest warehouse while heavier ones on bigger warehouses. The benefit here is that a light query will not spin up an expensive warehouse.</p><h3><strong>Reduce query predicates</strong></h3><p>Snowflake comes out of the box with some effective caching mechanism. For example, query cache will return the same result if Snowflake received exactly the same query, the underlying data hasn’t changed and the results were last retrieved within the last 24 hours. When query cache is retrieved — no virtual warehouse is activated and hence no warehousing costs are accrued — often the most expensive part of using Snowflake.</p><p>Now imagine that you have a service that queries Snowflake for some aggregated data and hence includes a query predicate like <em>timestamp &lt;= CURRENT_DATE()</em>. We will also have regular ingests of fresh data into the table being queried. Seems like the right solution, each query should be receiving the most up to date data. But what if the service querying Snowflake doesn’t need today’s data. In one of our projects we came across an example where only the data from up to the previous day was being used. As a result, the query cache was not being utilised (underlying data changed), and each query was spinning up the virtual warehouse to execute that query. Reducing the predicate to yesterday’s date would have greatly increased the usage of query caching in this instance.</p><h3><strong>Reduce frequency of data ingests</strong></h3><p>We live in a world where everyone wants to have fresh data as soon as possible. But that’s not necessarily what data warehousing is all about. It may be worth reconsidering how often new data is ingested into your system and whether you actually need it that often. As usual, this may be a give and take — if you ingest data less often, your individual compute operations will take longer. If you’re thinking of reducing ingest frequency a good rule of thumb would be to check how long the current ingests are taking — if it’s less than the minimum 60 seconds you’ll be charged for — it may be worth reducing that frequency. Serverless tasks can be a saviour here as well. If your individual tasks are taking less than 60 seconds and you are not co-locating queries on the same warehouse, serverless tasks can be a great solution here. Especially as they currently cost 0.9x of the regular compute!</p><h3><strong>Reduce data scanned</strong></h3><p>You may be using some pre-set views that load many columns but only some are actually used in your heavy hitting queries. Your original view may have only included a couple of columns, but then another requirement resulted in other columns being added. In the meantime, your original workload is still using the same columns, but now scans a lot more data to produce the same result.</p><p>This was the case in one of the environments we looked at recently. Snowflake was receiving a large number of queries which used a view containing 20 different columns. However, only 4 of those columns were actually being used. After some experimentation, we reduced bytes scanned per query from an average of 300MB to 80MB and the total execution time from an average of 800ms to 300ms. While overall the compute cost remained the same most of the time (because of the minimum 60 seconds charge), this reduced the load on that warehouse and allowed to free up resources for additional workloads without increasing compute size and costs.</p><h3><strong>Inefficient queries</strong></h3><p>Sometimes you won’t be able to control all the queries coming into your Snowflake environment. You’ll have other teams sending in inefficient and unoptimised queries and these may make up a big bulk of your Snowflake spending. Suggest some changes to the teams running those queries — but also give them a hand. Starting with a message suggesting they try and optimise those queries would be great — but if that doesn’t get you anywhere — work with them. They may not have the knowledge or resources to make that change. Another good idea would be to create some views for their workloads — with that you control at least part of the execution of those heavy workloads. It’s all about communication.</p><h3><strong>Are you using Snowflake for the correct thing?</strong></h3><p>Snowflake excels as a data warehousing solution, but can get pretty expensive when used for more operational workloads which involve a lot of reads and writes. We’ve seen organisations use Snowflake as their API backend, which resulted in queries from the API making up about half of their Snowflake compute costs. While a setup like this may be easy and quick to achieve — data is in Snowflake already and your API layer can easily connect to it — it may not be the best use of Snowflake. Each query coming from the API would spin up your warehouse if it’s not up already (unless query cache can be utilised). Depending on how many requests you are receiving, this may lead to your warehouse being up most of the time.</p><p>This is where other technologies may be more suitable. One solution we would suggest is looking at Iceberg Tables. If you save the table being queried by the API into external Iceberg table format, other query engines can query it — this may be as simple as querying it directly from an AWS Lambda. Other potential solutions are; exporting data from Snowflake into another database for operational querying or saving pre-computed results to an S3 bucket. This is a nice segue to our next point…</p><h3><strong>Talk to your teams and look beyond Snowflake</strong></h3><p>Snowflake is just one part of the puzzle. Time and time again we see teams working in silos, often making assumptions about what the requirements are or creating whole solutions because of a single request. Cooperation with other teams can often clarify what is actually needed — align what your team is working on with what others are planning or implementing already — and even avoid duplication of efforts. For example, if Snowflake’s baked-in caching can be utilised, perhaps there is no need for the service reading data from Snowflake to implement their own caching solution. It’s also important to learn how — and when — to say ‘no.’ Sure, that feature someone mentioned might be cool and useful to some users, but does it align with the strategic goals of your platform?</p><h3><strong>Other things to consider</strong></h3><p>And just for completeness, here’s a list of other commonly used ways to optimise your Snowflake costs:</p><ul><li>Reduce warehouse auto-suspend</li><li>Reduce warehouse size</li><li>Set minimum clusters to 1</li><li>Ensure correct table clustering</li><li>Drop unused tables</li><li>Lower data retention</li><li>Use transient tables</li><li>Enable query timeouts</li></ul><h3><strong>Takeaways</strong></h3><p>This list goes on. There are many ways of optimising Snowflake, but these are some of the more interesting aspects we came across. Perhaps in a few months we’ll have enough examples to write another piece.</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/reduce-that-snowflake-spend">Mechanical Rock website</a>. If you’re in the Perth area and want to chat about or get help with implementing Snowflake for your data stack, <a href="https://www.mechanicalrock.io/lets-get-started">please reach out to Mechanical Rock team</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=763a56defdc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake DevOps — first impressions and comparison with schemachange]]></title>
            <link>https://maciejtarsa.medium.com/snowflake-devops-first-impressions-and-comparison-with-schemachange-30481715a60e?source=rss-b8b8507219c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/30481715a60e</guid>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[schemachange]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Maciej Tarsa]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 00:59:40 GMT</pubDate>
            <atom:updated>2026-01-12T04:13:59.844Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Snowflake DevOps — first impressions and comparison with schemachange</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bv_EQWcfYjFyB8UeQVtoeQ.png" /><figcaption>Header image from <a href="https://docs.snowflake.com/en/developer-guide/builders/devops">Snowflake</a></figcaption></figure><p>This article was first published on the <a href="https://www.mechanicalrock.io/blog/snowflake-devops-first-impressions-and-comparison-with-schemachange">Mechanical Rock website</a>.</p><h3><strong>Snowflake resource lifecycle management tools</strong></h3><p>There are a number of options for programmatically managing the lifecycle of Snowflake resources. Terraform has previously been a popular choice — however due to many issues encountered — it is not recommended for teams without a wealth of Terraform and Infrastructure-as-Code (IaC) experience. As an alternative, we have been using schemachange — a tool following an imperative-style approach. It provides a low barrier of entry for teams used to SQL language while offering a good set of functionalities.</p><p>Despite the number of tools available, there is a gap in Snowflake’s native ability to provide object lifecycle management. Snowflake has been working on filling this gap and the recent introduction of <a href="https://www.snowflake.com/en/blog/devops-snowflake-accelerating-development-productivity/">Snowflake DevOps may sufficiently fill that space</a>. The goal of this post is to evaluate whether Snowflake DevOps is ready to replace schemachange as an object management tool.</p><h3><strong>Our requirements</strong></h3><p>There are a number of things we want to be able to achieve with the tool of choice</p><ul><li>Snowflake securable objects such as roles, users, warehouses, databases and tables should be defined in code</li><li>It should be possible to deploy these using CI/CD tools (automated deployment)</li><li>It should be possible to deploy to multiple environments in Snowflake (either logical or physical separation)</li><li>Ideally some testing should be possible — e.g. test that expected objects were created or that no additional objects of specific type exist in the environment</li></ul><p>Next, we’ll introduce a sample deployment to Snowflake using both schemachange and Snowflake DevOps and evaluate both based on a number of criteria.</p><p>All the code used in this post, including the steps to set up both solutions, can be found <a href="https://github.com/maciejtarsa/schemachange-vs-snowflake-devops">in our Git repository</a>.</p><h3><strong>schemachange</strong></h3><p>Schemachange follows an imperative style approach — meaning that Snowflake resources need to be explicitly defined and removed — e.g. just removing them from the code base won’t remove them from the Snowflake environment — schemachange does not maintain the state of what exists in your account.</p><p>The tool requires some initial setup in order to be able to run the deployment. You are most likely to perform this initial setup in the UI in a Snowflake workbook — but is it useful to save it to a git repository anyway to keep information about what has been deployed. This includes:</p><ul><li>A user for schemachange to authenticate with</li><li>A role for that user to assume</li><li>A database, schema and table for storage of change history table</li><li>A warehouse used for executing scripts</li></ul><p>Note that schemachange can use existing resources for the above — with the exception of the change history table — but that table can be created in an existing database and schema as well.</p><p>There are 3 types of schemachange scripts:</p><ul><li>Versioned, e.g. <em>V1.1__name.sql</em> — applied only once</li><li>Repeatable, e.g. <em>R__name.sql</em> — applied at each run but only if contents of the file have changed — a hash of the contents of the file is kept in the history table</li><li>Always, e.g. <em>A__name.sql</em> — applied at every run</li></ul><p>They will be applied in that order — versioned first, then repeatable and always at the end.</p><p>As an imperative tool — it is designed to mostly work with versioned files, however in order to use pseudo-declarative style — we opted to define most of our resources using Repeatable scripts with the following constructs:</p><pre>CREATE WAREHOUSE IF NOT EXISTS WH_{{ ENV }}_DATA_ENG<br>WITH INITIALLY_SUSPENDED = TRUE;<br>USE WAREHOUSE WH_{{ ENV }}_SCHEMACHANGE;<br><br>ALTER WAREHOUSE WH_{{ ENV }}_DATA_ENG<br>SET WAREHOUSE_SIZE = XSMALL<br>AUTO_SUSPEND = 60;</pre><p>That way we first create a warehouse only if it doesn’t exist already and specify only the minimum parameters required. Then alter it to provide the parameters we expect to change in the future. If that resource needs changing later (e.g. size of a warehouse) — we just change the alter script — as it’s a repeatable file it will get applied at the next deployment. If we used <em>CREATE OR REPLACE</em>, any existing grants (or data if it’s a database, schema, etc.) would be lost.</p><p>We also found uses for the other types of scripts:</p><ul><li>Always scripts for running tests — we want the tests to run after each deployment run and as the last step — to confirm we have the resources we expect</li><li>Versioned scripts for removal of resources — as a one off action these are perfect for dropping existing resources and having that history recorded</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*HXjmdpywYPQh2-kf8haw_Q.png" /><figcaption><em>Figure 1: Sample deployment of schemachange — 3 scripts were applied — our Always scripts — and 6 were skipped — Versioned and Repeatable</em></figcaption></figure><p>To learn more about schemachange, <a href="https://github.com/Snowflake-Labs/schemachange">their GitHub page is a great start</a>.</p><h3><strong>Snowflake DevOps</strong></h3><p>Snowflake recently released a set of tools under the umbrella ‘Snowflake DevOps’. The aim is to provide a powerful way to maintain a single source of truth with the use of a declarative approach to object management and automation of CI/CD workflows. The key to this is the new Git integration which can be used to securely connect your git repository to a Snowflake Notebook or to SQL or Python files. Snowflake updated their CLI tooling and introduced Snowflake CLI which is a key element of this integration.</p><p>The other key building blocks are:</p><ul><li>the new <em>CREATE OR ALTER</em> statement which combines <em>CREATE OR REPLACE</em> with <em>ALTER</em> and is now compatible with most Snowflake objects</li><li><em>EXECUTE IMMEDIATE FROM</em> command which allows you to execute SQL from a Git repository in Snowflake</li></ul><p>The initial setup is quite similar to schemachange — you’ll need a user, role, database and schema. You won’t need a table to store the history of scripts run, but you will need an api integration for your git repository instead. Again — you could use existing resources and define your git integration in one of the existing schemas if you choose to.</p><p>Snowflake Devops is declarative — allowing for your resources definition to be concise, idempotent and easy to understand. However, we had high hopes for Snowflake managing the state of objects — this is not currently the case — but more on that later.</p><p>Your SQL scripts will generally be very similar to schemachange, e.g. the warehouse declared earlier would be equivalent to:</p><pre>CREATE OR ALTER WAREHOUSE WH_{{ ENV }}_DATA_ENG<br>WITH INITIALLY_SUSPENDED = TRUE<br>WAREHOUSE_SIZE = XSMALL<br>AUTO_SUSPEND = 60;</pre><p>The seamless integration between Python and SQL is an advantage — you can have your definition in SQL or Python and switch as needed. You can pass parameters for your Jinja scripts, you can also specify which scripts to run by pattern matching. Unfortunately, it looks like all scripts will always be run, whether there are any changes or not. However you can use git diff to get the changed files only and to specify that only those should be run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*blGU5GwJyLFeTTZaiewg6Q.png" /><figcaption><em>Figure 2: Sample deployment with Snowflake DevOps — 6 scripts were successfully executed</em></figcaption></figure><p>To learn more about Snowflake DevOps, check out <a href="https://docs.snowflake.com/en/developer-guide/builders/devops">Snowflake documentation</a> or their <a href="https://quickstarts.snowflake.com/guide/getting_started_with_snowflake_devops/#0">QuickStart Guide</a>.</p><h3><strong>Evaluation</strong></h3><p>Having performed a minimal setup of Snowflake infrastructure using both tools, we can now evaluate if Snowflake DevOps is mature enough to replace schemachange.</p><p><strong>Initial setup</strong></p><p>Initial setup is very similar — both tools need a user, role, database, schema and warehouse. Schemachange also needs a table to store the history of deployments (1 per environment), while DevOps needs a git integration to connect to the repository where the code is stored. One potential issue with schemachange’s table is that it could become quite big fairly quickly — as many deployments are run, the number of records could grow quite quickly — that table may eventually need some optimisation.</p><p><strong>Maintaining state</strong></p><p>Schemachange is stateless — therefore it doesn’t maintain the state — the user needs to manage this. However, it does allow for skipping files with no changes made (with use of Repeatable files). This can be very useful if only small changes are made — a bit like Terraform only amending resources which are altered. Snowflake DevOps doesn’t maintain the state either and as far as we could find, there was no easy way to only run scripts for changed resources. Using git diff is an option — but creates another overhead.</p><p><strong>Removal of resources</strong></p><p>Being an imperative tool — any removals of resources have to be explicit in schemachange — you need to include a <em>DROP</em> statement. In the past, we used versioned files for this purpose, which worked quite well. Snowflake DevOps is a declarative tool — however as it does not maintain the state — removal has to be explicit as well. Unfortunately — there is no facility to run that operation once only as part of the deployment. You will either end up re-running <em>DROP IF EXISTS</em> on every deployment, drop resources outside of version control (please don’t), or have a separate set of deployment scripts for dropping resources. None of these are good options.</p><p><strong>Bringing in existing resources</strong></p><p>In both tools, you can bring existing resources into source control (add definitions for resources created previously into your code base). This will require transferral of ownership to the role deploying the tool — in order to <em>CREATE OR ALTER</em> a resource, the role performing this action needs to own the resource.</p><p><strong>Separation of environments</strong></p><p>You can use Jinja syntax in both tools — this allows for easy replacement of values in your scripts and you can call it in your pipelines by passing variables — e.g. have a deployment to Development and another to Production using the same scripts. You can also use Jinja to use conditional statements in both tools — e.g. only deploy a resource in a specific environment.</p><p><strong>Testing</strong></p><p>Neither tool has any native setup for testing. The proposed solution is to have multiple environments and if something fails to create in a lower environment — your deployment pipeline will prevent any changes to higher environments. Additionally with schemachange, we created a stored procedure which takes a temporary table containing expected results and a statement like <em>SHOW DATABASES</em> as arguments and compares the results of that statement to contents of the temporary table. The same setup can be achieved with Snowflake DevOps.</p><h3><strong>Takeaways</strong></h3><p>Overall — we think that Snowflake DevOps is mature enough to provide programmatic resource lifecycle management in Snowflake. As a fairly new tool — it is still missing some of the functionality we would have liked to see — e.g. a way to only run changed resources. However Snowflake is likely to be adding a lot of further developments into this area — it’s a space worth watching.</p><p>Having said that — if schemachange works well for you — keep using it. It is still a very mature tool with a lot of features and flexibility. There’s also nothing stopping you from using <em>CREATE OR ALTER</em> statements in schemachange as well!</p><p>This article was first published on <a href="https://www.mechanicalrock.io/blog/snowflake-devops-first-impressions-and-comparison-with-schemachange">Mechanical Rock website</a>. If you’re in the Perth area and want to chat about or get help with implementing Snowflake for your data stack, <a href="https://www.mechanicalrock.io/lets-get-started">please reach out to Mechanical Rock team</a> or find me on <a href="https://www.linkedin.com/in/maciejtarsa/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30481715a60e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>