Skip to content

Commit a701c02

Browse files
committed
test(reporting): run the new report scenarios on SQLite, MySQL and D1 and the MySQL Cube lane
The engine lanes added in #421 now run all 19 report scenarios. The MySQL adopter tables gain the nodes, sessions, measurements, auths and all_types tables, the api-contract MySQL schema gains the disputed/category/sku columns, and the MySQL Cube lane covers all 21 served reports. A naive timestamp keeps its wall clock without a zone suffix on the SQLite and D1 wire form; two scenarios no longer depend on engine-specific NULL ordering or on a Postgres-only clock expression.
1 parent f70521b commit a701c02

15 files changed

Lines changed: 657 additions & 67 deletions

File tree

‎docs/CONFORMANCE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ manifest contains without moving these boundaries.
142142
A second live file (`cube-model-mysql.live.ts`) runs the MySQL path: the canonical golden
143143
generated with `dialect: "mysql"` is loaded into the same pinned Cube over a real MySQL 8.4
144144
holding the report views `buildReportViews` lowers (`fixtures/cube-model/canonical/seed.mysql.sql`),
145-
and each of the nine reports' Cube query is compared with `SELECT *` from its view, with the
145+
and each of the twenty-one served reports' Cube query is compared with `SELECT *` from its view, with the
146146
pre-aggregation used asserted. That is the smaller of the two honest options: the two MySQL
147147
*cases* (escaping, a quoted identifier) are still compiled, not executed, and the goldens hold
148148
their SQL. The lane runs Cube in development mode, so Cube's production mode with a separate

‎fixtures/api-contract-conformance/report/schema.mysql.sql‎

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ CREATE TABLE `invoices` (
99
`reference` VARCHAR(40) NOT NULL,
1010
`status` VARCHAR(20) NOT NULL,
1111
`amountCents` BIGINT NOT NULL,
12-
`issuedOn` DATE NOT NULL
12+
`issuedOn` DATE NOT NULL,
13+
`disputed` BOOLEAN NOT NULL
1314
);
1415

15-
CREATE TABLE `products` (
16+
CREATE TABLE `categories` (
1617
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
1718
`name` VARCHAR(200) NOT NULL
1819
);
1920

21+
CREATE TABLE `products` (
22+
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
23+
`name` VARCHAR(200) NOT NULL,
24+
`sku` VARCHAR(36),
25+
`categoryId` BIGINT,
26+
FOREIGN KEY (`categoryId`) REFERENCES `categories` (`id`)
27+
);
28+
2029
CREATE TABLE `sales` (
2130
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
2231
`productId` BIGINT NOT NULL,
@@ -48,6 +57,23 @@ CREATE VIEW `v_invoice_totals` AS
4857
COUNT(CASE WHEN i.`status` = 'PAID' THEN i.`id` END) / NULLIF(COUNT(i.`id`), 0) AS `paidShare`
4958
FROM `invoices` i;
5059

60+
CREATE VIEW `v_invoice_calendar` AS
61+
SELECT
62+
DATE(i.`issuedOn`) AS `issuedOnDay`,
63+
DATE(DATE_FORMAT(i.`issuedOn`, '%Y-%m-01')) AS `issuedOnMonth`,
64+
COUNT(i.`id`) AS `invoices`,
65+
CAST(SUM(i.`amountCents`) AS SIGNED) AS `totalCents`
66+
FROM `invoices` i
67+
GROUP BY DATE(i.`issuedOn`), DATE(DATE_FORMAT(i.`issuedOn`, '%Y-%m-01'));
68+
69+
CREATE VIEW `v_invoice_disputes` AS
70+
SELECT
71+
i.`disputed` AS `disputed`,
72+
COUNT(i.`id`) AS `invoices`,
73+
COUNT(CASE WHEN i.`amountCents` >= 60000 THEN i.`id` END) AS `bigInvoices`
74+
FROM `invoices` i
75+
GROUP BY i.`disputed`;
76+
5177
CREATE VIEW `v_product_revenue` AS
5278
SELECT
5379
p.`id` AS `productId`,
@@ -58,3 +84,24 @@ CREATE VIEW `v_product_revenue` AS
5884
FROM `products` p
5985
LEFT OUTER JOIN `sales` s ON p.`id` = s.`productId`
6086
GROUP BY p.`id`, p.`name`;
87+
88+
CREATE VIEW `v_sales_by_category` AS
89+
SELECT
90+
c.`name` AS `categoryName`,
91+
COUNT(s.`id`) AS `sales`,
92+
CAST(SUM(s.`amountCents`) AS SIGNED) AS `revenueCents`,
93+
MAX(s.`amountCents`) AS `maxCents`,
94+
COUNT(CASE WHEN s.`amountCents` >= 10000 THEN s.`id` END) AS `largeSales`
95+
FROM `sales` s
96+
INNER JOIN `products` p ON p.`id` = s.`productId`
97+
LEFT OUTER JOIN `categories` c ON c.`id` = p.`categoryId`
98+
GROUP BY c.`name`;
99+
100+
CREATE VIEW `v_sales_by_sku` AS
101+
SELECT
102+
p.`sku` AS `productSku`,
103+
COUNT(s.`id`) AS `sales`,
104+
CAST(SUM(s.`amountCents`) AS SIGNED) AS `revenueCents`
105+
FROM `sales` s
106+
INNER JOIN `products` p ON p.`id` = s.`productId`
107+
GROUP BY p.`sku`;

‎fixtures/api-contract-conformance/report/schema.sqlite.sql‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ CREATE TABLE "invoices" (
99
"status" TEXT NOT NULL,
1010
"amountCents" INTEGER NOT NULL,
1111
"issuedOn" TEXT NOT NULL,
12+
"disputed" INTEGER NOT NULL,
1213
CONSTRAINT "invoices_status_chk" CHECK ("status" IN ('OPEN', 'PAID', 'VOID'))
1314
);
1415

15-
CREATE TABLE "products" (
16+
CREATE TABLE "categories" (
1617
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
1718
"name" TEXT NOT NULL
1819
);
1920

21+
CREATE TABLE "products" (
22+
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
23+
"name" TEXT NOT NULL,
24+
"sku" TEXT,
25+
"categoryId" INTEGER,
26+
FOREIGN KEY ("categoryId") REFERENCES "categories" ("id")
27+
);
28+
2029
CREATE TABLE "sales" (
2130
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
2231
"productId" INTEGER NOT NULL,
@@ -48,6 +57,23 @@ CREATE VIEW "v_invoice_totals" AS
4857
CAST(COUNT(CASE WHEN i."status" = 'PAID' THEN i."id" END) AS REAL) / NULLIF(COUNT(i."id"), 0) AS "paidShare"
4958
FROM "invoices" i;
5059

60+
CREATE VIEW "v_invoice_calendar" AS
61+
SELECT
62+
date(i."issuedOn") AS "issuedOnDay",
63+
date(i."issuedOn", 'start of month') AS "issuedOnMonth",
64+
COUNT(i."id") AS "invoices",
65+
SUM(i."amountCents") AS "totalCents"
66+
FROM "invoices" i
67+
GROUP BY date(i."issuedOn"), date(i."issuedOn", 'start of month');
68+
69+
CREATE VIEW "v_invoice_disputes" AS
70+
SELECT
71+
i."disputed" AS "disputed",
72+
COUNT(i."id") AS "invoices",
73+
COUNT(CASE WHEN i."amountCents" >= 60000 THEN i."id" END) AS "bigInvoices"
74+
FROM "invoices" i
75+
GROUP BY i."disputed";
76+
5177
CREATE VIEW "v_product_revenue" AS
5278
SELECT
5379
p."id" AS "productId",
@@ -58,3 +84,24 @@ CREATE VIEW "v_product_revenue" AS
5884
FROM "products" p
5985
LEFT OUTER JOIN "sales" s ON p."id" = s."productId"
6086
GROUP BY p."id", p."name";
87+
88+
CREATE VIEW "v_sales_by_category" AS
89+
SELECT
90+
c."name" AS "categoryName",
91+
COUNT(s."id") AS "sales",
92+
SUM(s."amountCents") AS "revenueCents",
93+
MAX(s."amountCents") AS "maxCents",
94+
COUNT(CASE WHEN s."amountCents" >= 10000 THEN s."id" END) AS "largeSales"
95+
FROM "sales" s
96+
INNER JOIN "products" p ON p."id" = s."productId"
97+
LEFT OUTER JOIN "categories" c ON c."id" = p."categoryId"
98+
GROUP BY c."name";
99+
100+
CREATE VIEW "v_sales_by_sku" AS
101+
SELECT
102+
p."sku" AS "productSku",
103+
COUNT(s."id") AS "sales",
104+
SUM(s."amountCents") AS "revenueCents"
105+
FROM "sales" s
106+
INNER JOIN "products" p ON p."id" = s."productId"
107+
GROUP BY p."sku";

‎fixtures/cube-model/canonical/seed.mysql.sql‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ INSERT INTO `programs` (`id`,`title`,`priceCents`,`status`,`created_ts`) VALUES
1111
(4, 'Legacy', 700, 'ARCHIVED', '2026-05-31 23:59:59'),
1212
(5, 'Monday', 300, 'PUBLISHED', '2026-05-18 00:00:00'),
1313
(6, 'Fresh', 1000, 'PUBLISHED', UTC_TIMESTAMP(3) - INTERVAL 3 DAY),
14-
(7, 'Stale', 2000, 'PUBLISHED', UTC_TIMESTAMP(3) - INTERVAL 60 DAY);
14+
(7, 'Stale', 2000, 'PUBLISHED', UTC_TIMESTAMP(3) - INTERVAL 60 DAY),
15+
(8, 'Intro Flow', 1500, 'DRAFT', '2026-06-01 08:00:00'),
16+
(9, 'Open Gym', 0, 'PUBLISHED', '2026-05-17 08:00:00'),
17+
(10, 'Intro Archive', 900, 'ARCHIVED', '2026-05-31 12:00:00'),
18+
(11, 'Intro Premium', 9000, 'PUBLISHED', '2026-05-01 12:00:00');
1519
INSERT INTO `weeks` (`id`,`programId`,`label`,`durationMinutes`) VALUES
1620
(10, 1, 'Week 1', 30),
1721
(11, 1, 'Week 2', 60),
@@ -23,3 +27,43 @@ INSERT INTO `assets` (`id`,`ownerId`,`externalId`,`payload`,`recordedAt`,`observ
2327
('11111111-1111-4111-8111-111111111111','aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa','22222222-2222-4222-8222-222222222222','{"k": 1}','2026-05-04 03:30:00','2026-05-04 03:30:00','2026-05-03','03:30:00'),
2428
('33333333-3333-4333-8333-333333333333','44444444-4444-4444-8444-444444444444','55555555-5555-4555-8555-555555555555','{"k": 2}','2026-05-04 03:45:00','2026-05-04 03:45:00','2026-05-03','03:45:00'),
2529
('66666666-6666-4666-8666-666666666666','77777777-7777-4777-8777-777777777777','88888888-8888-4888-8888-888888888888','{"k": 3}','2026-05-04 04:10:00','2026-05-04 04:10:00','2026-05-04','04:10:00');
30+
INSERT INTO `measurements` (`id`,`tempC`,`massKg`,`preciseKg`) VALUES
31+
(1, 1.5, 8.5, 1.25),
32+
(2, -2.25, 12.5, 2.5),
33+
(3, 4.5, 20.25, 0.75),
34+
(4, 0.5, 7.5, 3.5);
35+
INSERT INTO `sessions` (`id`,`weekId`,`minutes`) VALUES
36+
(100, 10, 30),
37+
(101, 10, 40),
38+
(102, 11, 50),
39+
(200, 20, 25);
40+
INSERT INTO `nodes` (`id`,`label`,`parentId`) VALUES
41+
(1, 'root', NULL),
42+
(2, 'a', 1),
43+
(3, 'b', 1),
44+
(4, 'c', 2),
45+
(5, 'top', NULL);
46+
INSERT INTO `auths` (`id`,`type`,`reference`,`quantity`,`urgency`) VALUES
47+
(1, 'Bridge', 'A-1', 2, NULL),
48+
(2, 'Bridge', 'A-1', 3, NULL),
49+
(3, 'Copay', 'C-1', NULL, NULL),
50+
(4, 'PriorAuth', 'P-1', NULL, NULL),
51+
(5, 'Referral', 'R-1', NULL, 'routine'),
52+
(6, 'Referral', 'R-2', NULL, 'urgent'),
53+
(7, NULL, 'N-1', NULL, NULL);
54+
INSERT INTO `all_types` (
55+
`id`,`sVal`,`iVal`,`lVal`,`dVal`,`fVal`,`decVal`,`bVal`,`dateVal`,`timeVal`,`tsVal`,`tsTzVal`,
56+
`moneyVal`,`enumVal`,`intEnumVal`,`uuidVal`,`uriVal`,`inetVal`,`inet6Val`
57+
) VALUES
58+
('00000000-0000-4000-8000-000000000001','r1',10,7,0.5,0.5,1.5,true,'2026-05-01','00:00:00',
59+
'2026-05-01 00:00:00','2026-05-01 00:00:00',1000,'HIGH',5,
60+
'a1111111-1111-4111-8111-111111111111','urn:x:1','10.0.0.1','fe80::1'),
61+
('00000000-0000-4000-8000-000000000002','r2',20,3,0.5,0.5,2.5,true,'2026-05-01','00:00:00',
62+
'2026-05-01 00:00:00','2026-05-01 00:00:00',3000,'HIGH',5,
63+
'a1111111-1111-4111-8111-111111111111','urn:x:2','10.0.0.2','fe80::2'),
64+
('00000000-0000-4000-8000-000000000003','r3',5,9,0.5,0.5,0.5,false,'2026-05-02','00:00:00',
65+
'2026-05-02 00:00:00','2026-05-02 00:00:00',200,'LOW',NULL,
66+
'b2222222-2222-4222-8222-222222222222','urn:x:3','10.0.0.3','fe80::3'),
67+
('00000000-0000-4000-8000-000000000005','r5',99,1,0.5,0.5,9,true,'2026-05-01','00:00:00',
68+
'2026-05-01 00:00:00','2026-05-01 00:00:00',9999,'HIGH',5,
69+
'a1111111-1111-4111-8111-111111111111','urn:x:5','10.0.0.5','fe80::5');

0 commit comments

Comments
 (0)