Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Shopify Engineering 11 min read Case study mediumAdept

ShopifyQL Notebooks: Simplifying Querying with Commerce Data Models

Shopify built commerce data models behind ShopifyQL Notebooks so merchants can query metrics like sales and view-to-purchase conversion without SQL or joining across departmental datasets. Good models are purpose-driven, explorable (right granularity, useful dimensions, fully additive metrics rather than semi- or non-additive ones) and extensible. The process runs from business questions to mock data and template queries, then to sourcing upstream tables, checking quality and consistency, and deriving freshness from upstream SLOs. Build time improved by switching from full-drop to incremental pipelines, at some cost in maintainability, and query speed improved with daily per-product roll-up tables for high-cardinality GROUP BYs.

Assumes: data warehousing basicsSQL aggregation

Related posts

  • Introducing ShopifyQL: Our New Commerce Data Querying Language

    Shopify Engineering easyNovice

    ShopifyQL is a commerce-focused query language for Shopify Plus merchants that reorders SQL-like syntax (FROM before SHOW, BY instead of GROUP BY) and adds VISUALIZE for direct charting, COMPARE TO for period-over-period analysis without joins or window functions, and DURING for named commerce date ranges like BFCM. It runs over purpose-built exploration data models: single flat tables at the lowest domain grain with fully additive metrics and overlapping coverage across products, orders and customers. Merchants use it through ShopifyQL Notebooks, partners through GraphQL APIs, and Shopify plans to power all Admin analytics with it, with pivoting, aggregate filters in WHERE and more chart types on the roadmap.

  • How Shopify Built An In-Context Analytics Experience

    Shopify Engineering mediumAdept

    Shopify embedded order and fulfillment metrics directly into the admin Orders page instead of keeping them in a separate Analytics section, after research showed merchants bouncing between pages to make decisions. The data science team validated candidate metrics against merchant workflows, segmented merchants to study the shape of each metric (hiding metrics that are inapplicable, constant, or only useful over long periods), and prototyped visualizations with real data. One result was choosing histograms over medians for fulfillment and delivery times. A shared data specification sheet kept Web, Android and iOS on the same queries. The underlying model uses an atomic grain of one row per fulfillment, in-transit or delivery event, and was built batch-first, then combined with streaming in a lambda architecture so batch supplies history and streaming covers recent data.

  • The Complex Data Models Behind Shopify's Tax Insights Feature

    Shopify Engineering mediumAdept

    Shopify's Tax Insights feature tells US merchants when they reach sales-tax economic nexus in each state. It runs on a pipeline of Spark data models over warehouse tables in GCS. State rules differ in dollar and order thresholds, inclusive or exclusive comparisons, excluded order types, and evaluation periods (prior calendar year, rolling 12 months, preceding four quarters). To handle this, the team built a rules lookup table with valid_from/valid_to dates, which drives a dimensional model of evaluation windows and thresholds per state per date. That model is joined to monthly merchant-state sales to produce a merchant-state-month liability model. The latest snapshot is pushed to Bigtable keyed by merchant ID for the app backend to serve. The team prototyped in SQL with BigQuery before PySpark, split the logic into intermediate models, and generalized the design so it later extended to Canadian GST.

  • A modern data stack for startups

    incident.io mediumAdept

    A small startup data stack built in two weeks: Fivetran (plus Stitch for connectors Fivetran lacks, like the Close CRM) extracts data into BigQuery, dbt transforms it, and Metabase lets non-engineers explore it without SQL. The dbt project skips 'base' models and goes straight to staging tables, producing dimension and fact marts only when joining across sources or doing complex transforms, which keeps schema maintenance low. Other practical details: Fivetran's xmin-cursor fallback for Heroku Postgres without logical replication, per-engineer BigQuery dev datasets, and using dbt-metabase to turn dbt relationship tests into Metabase foreign keys so joins auto-fill.

  • Retail data, reimagined: How Increff rebuilt its BI platform with ClickHouse

    ClickHouse mediumAdept

    Increff, a retail SaaS provider for brands like Puma and Adidas, replaced a BI stack of Pandas transformations, a serverless SQL warehouse and Superset after a client with 5x larger data caused query slowdowns and concurrency limits. The rebuilt platform uses DuckDB for most transformations, ClickHouse Cloud for warehousing and Redis caching for dashboards. It handles around a billion records at the same performance as before, with sub-second queries and 70–80% shorter data preparation times. Further tuning included a star schema with daily/weekly/monthly aggregated fact tables, time-based partitioning, LowCardinality and unsigned integer types, Jinja-templated Superset queries to drop unneeded joins, and explicit PREWHERE clauses.

The quest for software engineering knowledge.

Look:
Layout: