DEV Community

Cover image for I Asked Snowflake Cortex Why Dogs and Beer Are Correlated
Katharina Rückbrodt
Katharina Rückbrodt

Posted on

I Asked Snowflake Cortex Why Dogs and Beer Are Correlated

This is a submission for Weekend Challenge: Dog Days Edition

What I Built

Spurious Bark 🐕 is a Streamlit app that answers a question nobody asked: does German dog tax revenue secretly control the rest of society?

You pick a second time series from a dropdown — marriages, beer production, whatever I could scrounge from official German statistics — and the app plots it next to dog tax revenue, calculates the real statistical correlation between the two using Snowflake, and then asks Snowflake Cortex to generate a completely fake, dead-serious "scientific explanation" for why they're connected. Think tylervigen.com/spurious-correlations, but with more tail-wagging.

Turns out dog tax revenue and beer production correlate at -0.836. Coincidence? Yes. Obviously yes. But Cortex will still try to convince you otherwise.

Demo

Dog tax revenue vs. beer production chart in the Spurious Bark app

Dog tax revenue vs. beer production chart in the Spurious Bark app

The app compares dog tax revenue against:

  • 💍 Marriages
  • 🍺 Beer production (in hectoliters, because Germany)

Both time series come from the German Federal Statistical Office (Destatis), loaded into Snowflake tables and joined live via SQL.

Code

SpuriousBark on GitHub

How I Built It

The stack is deliberately small: a local Streamlit app talking directly to Snowflake, no Streamlit-in-Snowflake, no extra services.

  • Data: dog tax revenue plus two comparison series (marriages, beer production), all pulled from Destatis' GENESIS-Online database and loaded into two Snowflake tables (dog_tax_revenue, comparison_series)
  • Correlation: computed live in Snowflake with a plain CORR() aggregate over a joined query — no pandas math, the database does the work
  • The punchline: SNOWFLAKE.CORTEX.COMPLETE() takes the correlation coefficient and the series name, and generates a short, silly, deliberately-fake explanation in the spirit of "spurious correlations" — then explicitly tells the reader it's nonsense, because correlation ≠ causation
  • Making it demo-proof: two things I added once I hit real-world snags —
    1. A demo mode that kicks in automatically if no Snowflake credentials are configured, using generated sample data, so the app is inspectable without any setup
    2. A graceful fallback for the Cortex call: my trial account turned out to have Cortex functions locked (a known trial-account limitation), so instead of crashing mid-demo, the app catches that and falls back to a canned example explanation with a clear "Cortex was unreachable" note — because nothing kills a hackathon demo like an uncaught exception in front of the judges
  • The look: bright, rounded, dog-themed UI (yes, there are paw print dividers) because a project about dogs should not look like a quarterly earnings report

Dog tax revenue vs. beer production chart in the Spurious Bark app
The comparison_series table, live in Snowflake — 17 rows of real German government data, no mocks.

Prize Categories

Submitting for Best use of Snowflake 🐾 — the entire correlation calculation runs as SQL inside Snowflake (CORR()), and the comedic core of the app is powered by SNOWFLAKE.CORTEX.COMPLETE() generating the fake explanations live.

Top comments (1)

Collapse
 
konark_13 profile image
Konark Sharma

Wow, I am enlightened. I didn't knew German dog gave taxes. Cool concept. 😁