DB Olympics

Queries · q356 · Head of Merchandising · week 2, night 4

Bundle Creation Timing: Seeded in a Batch or Built Up Organically?

“Does the suspiciously clean 100%/0% bundle adoption split by vertical look like genuine, ongoing merchant activity, or does it look like a one-time data-seeding event?”

Manager · asked the questionFreya LindgrenHead of Merchandising. Came from a fashion marketplace's catalog team. Responsible for helping merchants present their products well.
Analyst · planned the reportZara AhmedExploratory: looks at the raw detail of an unfamiliar area before aggregating it.
Engineer · wrote the SQLOmarPragmatic: the shortest correct query, aggregates first and joins dimensions afterwards, FILTER clauses for conditional counts.

Fictional people at a fictional company, each played by a language-model agent. Who they are and what they are told

  1. Freya Lindgren writes to Zara Ahmed

    The manager, at the start of week 2

    Subject: Good start — let's dig into the risk areas

    Hi Zara,

    This is really useful, and a few things jumped out that I want to understand better before Friday.

    The Cragsley Outfitters finding worries me most — our #2 merchant by revenue with real quality concentration, and some of those poorly-rated items are still selling briskly. That combination (strong sales, weak ratings, sizable product count) feels like the kind of thing that erodes trust quietly until it doesn't. I'd like to understand it better: is this concentrated in certain kinds of products, has it been building over time, and does it look like it's about to hit sales or is demand just lagging behind reputation?

    Second, the December rating dip needs a clearer story. You flagged it as needing a second month to confirm — I agree, but I'd also like to understand whether there's something explainable behind it (seasonal returns, a particular product push, shipping delays around the holidays) rather than just watching and waiting. If Fennel & Flint and Wiesgrund Wohnen are worth a check-in, I want to go into that conversation knowing roughly what happened.

    Third, I was surprised that going from zero to one image makes such a big difference but more images after that don't. Before I turn that into a merchant talking point, I want to know if we're actually looking at a real presentation effect or just a stand-in for something else — are the zero-image listings systematically different in some way, like older, or a different kind of product?

    Finally, on bundles: you said it's white space but we can't test performance yet because usage is too rare. I'd like to understand it a bit more anecdotally before we design a pilot — among the handful of merchants that do use bundles, is there anything that distinguishes them, even descriptively, from the ones that don't?

    Thanks again — this is exactly the kind of clarity I needed.

    Freya

  2. Zara Ahmed plans the night

    The analyst · week 2, night 4, request 1 of 3

    Night 3 findings: (1) Wiesgrund Wohnen's December reviews are scattered thinly across 10 different products (mostly 1 review each) rather than concentrated on one bad item — but nearly all of them are fragile homeware: vases, a frying pan, dinner plates, a casserole dish, glassware. That points away from 'systemic quality problem' and toward 'breakage in transit,' which wouldn't show up in on-time-delivery stats (an item can arrive on schedule but shattered). (2) The 3-year December history splits the two merchants clearly: Fennel & Flint shows a real, monotonic 3-year rating decline (4.43 → 3.71 → 3.14) alongside order growth (28 → 45 → 69), consistent with a merchant whose quality control hasn't kept pace with scale; Wiesgrund Wohnen's history is noisier and non-monotonic (4.00 → 3.57 → 3.50, with 2023 already at 28.6% 1-2-star on a tiny sample), more consistent with episodic bad luck than a trend. (3) The bundle-by-vertical split is suspiciously clean — exactly 100% of merchants in six verticals (Beauty, Books & Stationery, Consumer Electronics, Food & Coffee, Home & Living, Jewelry) have made at least one bundle, and exactly 0% in the other five (Apparel & Footwear, both B2B verticals, Pet Supplies, Sports & Outdoor) have made any. A binary split with no partial adoption anywhere is unusual for organic merchant behavior and makes me suspect this may reflect how bundles were seeded/templated per vertical rather than a genuine merchandising choice — I want to check the creation-date distribution before I tell Freya it's a real behavioral pattern. For this final night: (A) check whether bundle creation clusters in one burst (seeding) or spreads out over time (organic), (B) test the fragile-goods-breakage theory with actual return/damage data across Home & Living, and (C) run the same product-level breakdown for Fennel & Flint's December reviews that we did for Wiesgrund, to see if their decline is broad-based or concentrated.

    Bundle Creation Timing: Seeded in a Batch or Built Up Organically?
    Question
    Does the suspiciously clean 100%/0% bundle adoption split by vertical look like genuine, ongoing merchant activity, or does it look like a one-time data-seeding event?
    One row per
    calendar month, 2023-01 through 2025-12
    Columns
    • month
    • bundles_created_count
    • distinct_tenants_creating_a_bundle
  3. Omar writes the SQL

    The engineer · 2 dry runs on the empty schema, then the submission

    Dry run 1 · STATUS: REJECTED
    WITH months AS (
      SELECT DISTINCT month_start
      FROM calendar_days
      WHERE month_start >= DATE '2023-01-01' AND month_start <= DATE '2025-12-01'
    ),
    bundles AS (
      SELECT
        DATE_TRUNC('month', created_at)::date AS month_start,
        COUNT(*) AS bundles_created_count,
        COUNT(DISTINCT tenant_id) AS distinct_tenants_creating_a_bundle
      FROM product_bundles
      GROUP BY 1
    )
    SELECT
      TO_CHAR(m.month_start, 'YYYY-MM') AS month,
      COALESCE(b.bundles_created_count, 0) AS bundles_created_count,
      COALESCE(b.distinct_tenants_creating_a_bundle, 0) AS distinct_tenants_creating_a_bundle
    FROM months m
    LEFT JOIN bundles b ON b.month_start = m.month_start
    ORDER BY m.month_start
    Dry run 2 · 1 change from the dry run before · STATUS: COMPILES (dry run on the empty schema, no data read)
    WITH months AS (  SELECT DISTINCT month_start  FROM calendar_days  WHERE month_start >= DATE '2023-01-01' AND month_start <= DATE '2025-12-01'),bundles AS (  SELECT    DATE_TRUNC('month', created_at)::date AS month_start,    COUNT(*) AS bundles_created_count,    COUNT(DISTINCT tenant_id) AS distinct_tenants_creating_a_bundle  FROM product_bundles  GROUP BY 1)SELECT  TO_CHAR(m.month_start, 'YYYY-MM') AS month,  STRFTIME(m.month_start, '%Y-%m') AS month,  COALESCE(b.bundles_created_count, 0) AS bundles_created_count,  COALESCE(b.distinct_tenants_creating_a_bundle, 0) AS distinct_tenants_creating_a_bundleFROM months mLEFT JOIN bundles b ON b.month_start = m.month_startORDER BY m.month_start

    “Query compiles correctly. Submitting.”

    Submitted · the SQL of the last dry run, unchanged · Submitted to tonight's batch. Your work on this request is done.

    “Submitted. The report will show bundle creation counts and distinct tenant counts per month across the full 2023–2025 calendar, which should make it easy to see whether creation activity is spread out (organic) or piled into one or two months (seeding event).”

  4. The report comes back overnight

    As Zara Ahmed saw it, from the small dataset the agents worked on

    month   | bundles_created_count | distinct_tenants_creating_a_bundle
    --------+-----------------------+-----------------------------------
    2023-01 |                     2 |                                  1
    2023-02 |                     0 |                                  0
    2023-03 |                     6 |                                  2
    2023-04 |                     4 |                                  1
    2023-05 |                     4 |                                  1
    2023-06 |                     1 |                                  1
    2023-07 |                     0 |                                  0
    2023-08 |                     0 |                                  0
    2023-09 |                     0 |                                  0
    2023-10 |                     0 |                                  0
    2023-11 |                     1 |                                  1
    2023-12 |                     2 |                                  1
    2024-01 |                     1 |                                  1
    2024-02 |                     0 |                                  0
    2024-03 |                     0 |                                  0
    2024-04 |                     0 |                                  0
    2024-05 |                     3 |                                  1
    2024-06 |                     2 |                                  1
    2024-07 |                     1 |                                  1
    2024-08 |                     5 |                                  3
    2024-09 |                     0 |                                  0
    2024-10 |                     9 |                                  3
    2024-11 |                     0 |                                  0
    2024-12 |                     3 |                                  1
    2025-01 |                     0 |                                  0
    2025-02 |                     0 |                                  0
    2025-03 |                     3 |                                  1
    2025-04 |                     2 |                                  1
    2025-05 |                     8 |                                  4
    2025-06 |                     1 |                                  1
    2025-07 |                     1 |                                  1
    2025-08 |                     6 |                                  2
    2025-09 |                     7 |                                  3
    2025-10 |                     0 |                                  0
    2025-11 |                     0 |                                  0
    2025-12 |                     0 |                                  0
    (36 rows)
  5. What came of it

    The memo and the queries that followed; links found by title, so inferred

    It builds on:

  6. It becomes benchmark query q356

    Changed only where the benchmark needs the same result on every system

    • spellingcast
    • placeholderyear month
    • determinismthe standard leaves the place of NULLs in a sort to the implementation: NULLS LAST ascending, NULLS FIRST descending, as in the reference results
    The benchmark text, against the submitted SQL
    WITH months AS (  SELECT DISTINCT month_start  FROM calendar_days  WHERE month_start >= DATE '2023-01-01' AND month_start <= DATE '2025-12-01'),bundles AS (  SELECT    DATE_TRUNC('month', created_at)::date AS month_start,    CAST(DATE_TRUNC('month', created_at) AS date) AS month_start,    COUNT(*) AS bundles_created_count,    COUNT(DISTINCT tenant_id) AS distinct_tenants_creating_a_bundle  FROM product_bundles  GROUP BY 1)SELECT  STRFTIME(m.month_start, '%Y-%m') AS month,  {{year_month(m.month_start)}} AS month,  COALESCE(b.bundles_created_count, 0) AS bundles_created_count,  COALESCE(b.distinct_tenants_creating_a_bundle, 0) AS distinct_tenants_creating_a_bundleFROM months mLEFT JOIN bundles b ON b.month_start = m.month_startORDER BY m.month_startORDER BY m.month_start NULLS LAST
    WITH months AS (
      SELECT DISTINCT month_start
      FROM calendar_days
      WHERE month_start >= DATE '2023-01-01' AND month_start <= DATE '2025-12-01'
    ),
    bundles AS (
      SELECT
        CAST(DATE_TRUNC('month', created_at) AS date) AS month_start,
        COUNT(*) AS bundles_created_count,
        COUNT(DISTINCT tenant_id) AS distinct_tenants_creating_a_bundle
      FROM product_bundles
      GROUP BY 1
    )
    SELECT
      strftime(m.month_start, '%Y-%m') AS month,
      COALESCE(b.bundles_created_count, 0) AS bundles_created_count,
      COALESCE(b.distinct_tenants_creating_a_bundle, 0) AS distinct_tenants_creating_a_bundle
    FROM months m
    LEFT JOIN bundles b ON b.month_start = m.month_start
    ORDER BY m.month_start NULLS LAST
    1 ms10 ms100 msHyper3.3 msDuckDB14.7 msGizmoSQL45.0 msclickhouse_brew35.0 msFirebolt28.7 msDataFusionwrong resultClickHouse7.8 ms
    • DataFusionrow 1: col 1: "2023-01" vs "YYYY-MM"
  7. Everything, as recorded

    The agents' own records, as the role play wrote them; only the personal data of the person who ran it is redacted

    Omar's whole session, 9 turns
    • The request, as Omar received it
      Report request from Zara Ahmed (analyst for the Head of Merchandising):
      
      Title: Bundle Creation Timing: Seeded in a Batch or Built Up Organically?
      Question: Does the suspiciously clean 100%/0% bundle adoption split by vertical look like genuine, ongoing merchant activity, or does it look like a one-time data-seeding event?
      Grain: one row per calendar month, 2023-01 through 2025-12
      Columns:
      - month
      - bundles_created_count
      - distinct_tenants_creating_a_bundle
      Details: Table: product_bundles. bundles_created_count = count of product_bundles rows with created_at in that month, across all tenants. distinct_tenants_creating_a_bundle = count of distinct tenant_id values among those rows. Build off the full calendar so every month appears even with zero bundles created. Order by month ascending. If the counts cluster heavily into one or two months, that points to a seeding/backfill event rather than organic, ongoing adoption.
      
      Check your query with the warehouse's dry_run tool, then hand it in with submit.
    • Omar calls dry_run
      WITH months AS (
        SELECT DISTINCT month_start
        FROM calendar_days
        WHERE month_start >= DATE '2023-01-01' AND month_start <= DATE '2025-12-01'
      ),
      bundles AS (
        SELECT
          DATE_TRUNC('month', created_at)::date AS month_start,
          COUNT(*) AS bundles_created_count,
          COUNT(DISTINCT tenant_id) AS distinct_tenants_creating_a_bundle
        FROM product_bundles
        GROUP BY 1
      )
      SELECT
        TO_CHAR(m.month_start, 'YYYY-MM') AS month,
        COALESCE(b.bundles_created_count, 0) AS bundles_created_count,
        COALESCE(b.distinct_tenants_creating_a_bundle, 0) AS distinct_tenants_creating_a_bundle
      FROM months m
      LEFT JOIN bundles b ON b.month_start = m.month_start
      ORDER BY m.month_start
    • The warehouse answers
      STATUS: REJECTED
        - does not compile: Catalog Error: Scalar Function with name to_char does not exist!
    • Omar calls dry_run
      WITH months AS (
        SELECT DISTINCT month_start
        FROM calendar_days
        WHERE month_start >= DATE '2023-01-01' AND month_start <= DATE '2025-12-01'
      ),
      bundles AS (
        SELECT
          DATE_TRUNC('month', created_at)::date AS month_start,
          COUNT(*) AS bundles_created_count,
          COUNT(DISTINCT tenant_id) AS distinct_tenants_creating_a_bundle
        FROM product_bundles
        GROUP BY 1
      )
      SELECT
        STRFTIME(m.month_start, '%Y-%m') AS month,
        COALESCE(b.bundles_created_count, 0) AS bundles_created_count,
        COALESCE(b.distinct_tenants_creating_a_bundle, 0) AS distinct_tenants_creating_a_bundle
      FROM months m
      LEFT JOIN bundles b ON b.month_start = m.month_start
      ORDER BY m.month_start
    • The warehouse answers
      STATUS: COMPILES (dry run on the empty schema, no data read)
      COLUMNS: month, bundles_created_count, distinct_tenants_creating_a_bundle
    • OmarQuery compiles correctly. Submitting.
    • Omar calls submit
      WITH months AS (
        SELECT DISTINCT month_start
        FROM calendar_days
        WHERE month_start >= DATE '2023-01-01' AND month_start <= DATE '2025-12-01'
      ),
      bundles AS (
        SELECT
          DATE_TRUNC('month', created_at)::date AS month_start,
          COUNT(*) AS bundles_created_count,
          COUNT(DISTINCT tenant_id) AS distinct_tenants_creating_a_bundle
        FROM product_bundles
        GROUP BY 1
      )
      SELECT
        STRFTIME(m.month_start, '%Y-%m') AS month,
        COALESCE(b.bundles_created_count, 0) AS bundles_created_count,
        COALESCE(b.distinct_tenants_creating_a_bundle, 0) AS distinct_tenants_creating_a_bundle
      FROM months m
      LEFT JOIN bundles b ON b.month_start = m.month_start
      ORDER BY m.month_start
    • The warehouse answers
      Submitted to tonight's batch. Your work on this request is done.
    • OmarSubmitted. The report will show bundle creation counts and distinct tenant counts per month across the full 2023–2025 calendar, which should make it easy to see whether creation activity is spread out (organic) or piled into one or two months (seeding event).