Repository navigation
Conversation
…text-to-…" This reverts commit 47d6ee0.
Re-applies the 312 query entities from #198, which #203 reverted because they broke the OSS datapack smoke test. - Add "contentType": "application/json" to every aspect in 04-queries.json. Without it the CLI's file source can't parse the GenericAspect envelope and rejects all 1,246 records. - Bump index.json to version 5 so CLIs that cached version 4 fetch the new file. - Drop the querySubjects record of noise/abandoned_logon_to_order_funnel. It pointed at order_entry.logon, which is not in the pack. The query stays, with no subjects, like the two schema-exploration noise queries. Co-Authored-By: Alex Skurikhin <alex.skurikhin@datahub.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexsku
left a comment
There was a problem hiding this comment.
Reviewed the full PR. The serialization fix checks out: all 1,245 records deserialize, all 312 packaged SQL statements match their source files, and referenced datasets and authors resolve within the pack.
I found two reproducible medium-priority correctness issues, detailed inline: existing caches can retain the earlier broken query file despite the version bump, and a query labeled canonical double-counts order-header revenue at line-item grain.
Validation included an isolated cache-upgrade reproduction and a small SQLite fixture for the revenue aggregation. I did not run Snowflake execution or an OSS server ingestion test. The passing CI check only validates image sizes.
| {"path": "02-data.json"}, | ||
| {"path": "03-context.json"} | ||
| {"path": "03-context.json"}, | ||
| {"path": "04-queries.json"} |
There was a problem hiding this comment.
[P2] Publish the corrected query file under a fresh URL
Reusing this path leaves users who cached the file from #198 with the broken serialization. The current datapack loader refreshes the index when its version changes, but caches child files by URL and reuses them unless no_cache is enabled. I reproduced a cached version 4 index plus the old query file: a normal load advanced the cached version to 5 while retaining the old bytes, producing 1,246 parse failures. Forcing a refresh fetched this PR's file and produced zero failures. Please give the corrected fixture a new filename and update this entry, or ship a loader fix that invalidates child files when the index version changes. A regression test should cover an upgrade with the earlier query file already cached.
There was a problem hiding this comment.
Fixed in b594a10. The file is now 04-queries-v2.json and index.json points to it, so every client fetches it from a new URL. The query README now says to rename the file whenever its content changes.
You're right about the loader: when the index version changes, download_pack fetches the index again but calls _resolve_index_file with no_cache=False, so cached child files are reused. I'm fixing that in a separate datahub PR, with a regression test for an upgrade where the old child file is already cached. This PR doesn't depend on it.
| SUM(order_total) AS total_revenue, | ||
| COUNT(DISTINCT order_id) AS order_count, | ||
| AVG(order_total) AS avg_order_value |
There was a problem hiding this comment.
[P2] Aggregate header totals once per order
order_details contains one row per line item, so SUM(order_total) repeats each order's revenue and AVG(order_total) weights orders by their item count. With a two-item order totaling 100 and a one-item order totaling 50, this query returns revenue 250 and AOV 83.33; the correct values are 150 and 75. The raw canonical variant returns revenue 150 for the same fixture. Please deduplicate to one row per order before aggregating and align the status filter with the raw canonical variant. The same issue occurs in 03-with_aov_per_class.sql and both packaged statements, so regenerate 04-queries.json after correcting the sources. A fixture with differing item counts per order would protect this behavior.
There was a problem hiding this comment.
Fixed in 53e5598. 01-canonical_mart and 03-with_aov_per_class now collapse order_details to one row per order, then exclude statuses 3 and 4 like 02-canonical_raw_join. The same bug was in customer_geo_distribution/03-mart_version, so I fixed that one too. The three packaged statements are regenerated and match their source files.
On your fixture (a two-item order totaling 100, a one-item order totaling 50, plus a cancelled order) in DuckDB, the new canonical query returns revenue 150 and AOV 75, the same as the raw canonical query. The old one returned 2,248.
The repo has no SQL test harness, so I didn't commit the fixture. I left aov_monthly/03-weighted_avg_anti, daily_order_volume_30d/04 and the noise queries unchanged, because they are meant to be wrong or approximate and their comments say so.
The datapack CLI caches each pack file by URL and reuses it when the index version changes. A client that cached 04-queries.json from #198 would keep the copy without contentType and fail to parse all 1,246 records. A new file name forces every client to fetch the fixed copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
analytics.order_details has one row per line item and repeats order_total on every row. Summing or averaging it there counts an order once per item. Collapse to one row per order first, and exclude status 3 and 4 like the raw canonical variant. Applies to revenue_by_customer_class 01 and 03 and customer_geo_distribution 03, and their packaged statements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Re-adds the 312 query entities from #198 with the bug fixed that made #203 revert them. This replaces #204, which re-applies #198 unchanged.
What changed
contentTypeon every aspect. None of the 1,246 aspects in Revert "Revert "feat(showcase-ecommerce): add 312 query entities for text-to-sql / anchor demo"" #204's04-queries.jsonhad"contentType": "application/json". Without it, the CLI's file source can't parse the GenericAspect envelope and rejects every record, sodatahub datapack load showcase-ecommerceexits non-zero. That is what broke the OSStests/datapack/test_datapack_smokerun.04-queries-v2.json. The CLI caches each pack file by URL and doesn't refetch it when the index version changes. A client that cached the broken04-queries.jsonfrom feat(showcase-ecommerce): add 312 query entities for text-to-sql / anchor demo #198 would keep it. A new URL forces a fresh fetch. The query README now says to rename the file whenever its content changes.index.jsonversion 4 → 5. So clients refetch the index and find the new file.analytics.order_detailshas one row per line item and repeatsorder_totalon each row.revenue_by_customer_class/01-canonical_mart,03-with_aov_per_classandcustomer_geo_distribution/03-mart_versionsummed it at that grain, which counted an order once per line item. They now collapse to one row per order and exclude statuses 3 and 4, like the raw canonical variant. The variants already commented as approximate or as the wrong way to do it (aov_monthly/03-weighted_avg_anti,daily_order_volume_30d/04) and the noise queries are unchanged on purpose.noise/abandoned_logon_to_order_funnelpointed atorder_entry_db.order_entry.logon, which is not in the pack. The query stays with no subjects, like the two schema-exploration noise queries.The commits keep Alex's revert of the revert first, then add the fixes, so the diff against #198 stays readable.
Testing
04-queries-v2.jsonfrom this branch withdatahub datapack load --url file://… --trust-custom --no-cache(CLI 1.7.0.12) into a local stack (GMS v2.4.0rc1): 1,245 records written, 0 failures. The stored statement forrevenue_by_customer_class/01-canonical_martmatches the new source file..sqlsource file.01-canonical_mart: revenue 2,248. New: revenue 150, AOV 75, the same as02-canonical_raw_join.mainthrough the registry, so it can only run after merge.Open question
@devashish2203 asked in the revert thread whether these queries belong in a separate pack, because OSS CI loads
showcase-ecommerce. This PR keeps them in the same pack. They add about 0.7 MB and load in about 5 s. If you'd rather have a separate pack, say so and I'll move the file out.#202 changes the same file and adds
05-query-usage.json. It will need a rebase onto this after merge.🤖 Generated with Claude Code