Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/entities/product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fields:
product_id: Unique product identifier
name: Product display name
category: Product category
price: Current price in USD
price: Current price in RUB
in_stock: Whether the product is currently available
stock_quantity: Current inventory count
relationships: {}
2 changes: 1 addition & 1 deletion contracts/entities/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ primary_key: user_id
fields:
user_id: Unique user identifier
total_orders: Lifetime order count
total_spent: Lifetime spend in USD
total_spent: Lifetime spend in RUB
first_order_at: First order timestamp
last_order_at: Most recent order timestamp
preferred_category: Most frequently ordered category
Expand Down
6 changes: 3 additions & 3 deletions docker/postgres-source/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS orders_v2 (
user_id VARCHAR,
status VARCHAR,
total_amount DECIMAL(10,2),
currency VARCHAR DEFAULT 'USD',
currency VARCHAR DEFAULT 'RUB',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Expand All @@ -25,11 +25,11 @@ CREATE TABLE IF NOT EXISTS debezium_signal (
INSERT INTO orders_v2
(order_id, user_id, status, total_amount, currency)
VALUES
('ORD-CDC-SEED-1', 'USR-CDC-SEED-1', 'confirmed', 42.50, 'USD')
('ORD-CDC-SEED-1', 'USR-CDC-SEED-1', 'confirmed', 990.00, 'RUB')
ON CONFLICT (order_id) DO NOTHING;

INSERT INTO users_enriched
(user_id, total_orders, total_spent, first_order_at, last_order_at, preferred_category)
VALUES
('USR-CDC-SEED-1', 1, 42.50, NOW(), NOW(), 'electronics')
('USR-CDC-SEED-1', 1, 990.00, NOW(), NOW(), 'kettles')
ON CONFLICT (user_id) DO NOTHING;
39 changes: 22 additions & 17 deletions notebooks/01-agent-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Order ORD-20260410-2810 is currently pending. The latest total is $239.97 USD. Customer USR-27447 placed it at 2026-04-10T19:25:35.628323.\n",
"Order ORD-20260404-1001 is currently delivered. The latest total is 76,400.00 RUB. Customer USR-10001 placed it at 2026-07-05T20:28:28.343799.\n",
"{\n",
" \"order_id\": \"ORD-20260410-2810\",\n",
" \"user_id\": \"USR-27447\",\n",
" \"status\": \"pending\",\n",
" \"total_amount\": 239.97,\n",
" \"currency\": \"USD\",\n",
" \"created_at\": \"2026-04-10T19:25:35.628323\",\n",
" \"order_id\": \"ORD-20260404-1001\",\n",
" \"user_id\": \"USR-10001\",\n",
" \"status\": \"delivered\",\n",
" \"total_amount\": 76400.0,\n",
" \"currency\": \"RUB\",\n",
" \"created_at\": \"2026-07-05T20:28:28.343799\",\n",
" \"is_overdue\": false\n",
"}\n"
]
Expand All @@ -205,7 +205,7 @@
"order = client.get_order(DEMO_ORDER_ID)\n",
"answer = (\n",
" f\"Order {order.order_id} is currently {order.status}. \"\n",
" f\"The latest total is ${order.total_amount:.2f} {order.currency}. \"\n",
" f\"The latest total is {order.total_amount:,.2f} {order.currency}. \"\n",
" f\"Customer {order.user_id} placed it at {order.created_at.isoformat()}.\"\n",
")\n",
"print(answer)\n",
Expand Down Expand Up @@ -239,21 +239,26 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Today's revenue: $6,364.14 USD\n",
"Today's revenue: 138,310.00 RUB\n",
"{\n",
" \"metric_name\": \"revenue\",\n",
" \"value\": 6364.14,\n",
" \"unit\": \"USD\",\n",
" \"value\": 138310.0,\n",
" \"unit\": \"RUB\",\n",
" \"window\": \"24h\",\n",
" \"computed_at\": \"2026-04-10T16:26:00.763214Z\",\n",
" \"components\": null\n",
" \"computed_at\": \"2026-07-05T19:28:59.062718Z\",\n",
" \"components\": null,\n",
" \"meta\": {\n",
" \"as_of\": null,\n",
" \"is_historical\": false,\n",
" \"freshness_seconds\": null\n",
" }\n",
"}\n"
]
}
],
"source": [
"revenue = client.get_metric('revenue', '24h')\n",
"print(f\"Today's revenue: ${revenue.value:,.2f} {revenue.unit}\")\n",
"print(f\"Today's revenue: {revenue.value:,.2f} {revenue.unit}\")\n",
"print(json.dumps(revenue.model_dump(mode='json'), indent=2))\n"
]
},
Expand Down Expand Up @@ -288,10 +293,10 @@
"SELECT SUM(total_amount) as revenue FROM orders_v2 WHERE status != 'cancelled' AND created_at >= NOW() - INTERVAL '1 hour'\n",
"\n",
"Rows returned:\n",
"[{'revenue': '6364.14'}]\n",
"[{'revenue': '11160.00'}]\n",
"\n",
"Metadata:\n",
"{'data_freshness_seconds': None, 'execution_time_ms': 2, 'rows_returned': 1}\n"
"{'data_freshness_seconds': None, 'execution_time_ms': 6, 'has_more': False, 'next_cursor': None, 'page_size': 100, 'rows_returned': 1, 'total_count': 1}\n"
]
}
],
Expand Down Expand Up @@ -589,4 +594,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
4 changes: 2 additions & 2 deletions scripts/nl_sql_eval/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class GoldItem:
),
GoldItem(
id="products_in_category",
question="How many products are in the Electronics category?",
gold_sql="SELECT COUNT(*) FROM products_current WHERE category = 'Electronics'",
question="How many products are in the kettles category?",
gold_sql="SELECT COUNT(*) FROM products_current WHERE category = 'kettles'",
category="out-of-pattern",
),
GoldItem(
Expand Down
35 changes: 18 additions & 17 deletions scripts/nl_sql_eval/warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@

from src.processing.local_pipeline import _ensure_tables

# (order_id, user_id, status, total_amount)
# (order_id, user_id, status, total_amount)
_ORDERS = [
("ORD-1001", "USR-1", "delivered", 120.00),
("ORD-1002", "USR-1", "delivered", 80.00),
("ORD-1003", "USR-2", "pending", 200.00),
("ORD-1004", "USR-2", "cancelled", 50.00),
("ORD-1005", "USR-3", "delivered", 300.00),
("ORD-1006", "USR-3", "cancelled", 75.00),
("ORD-1007", "USR-1", "delivered", 45.50),
("ORD-1008", "USR-4", "pending", 150.00),
("ORD-1001", "USR-1", "delivered", 2490.00),
("ORD-1002", "USR-1", "delivered", 1690.00),
("ORD-1003", "USR-2", "pending", 4200.00),
("ORD-1004", "USR-2", "cancelled", 990.00),
("ORD-1005", "USR-3", "delivered", 6990.00),
("ORD-1006", "USR-3", "cancelled", 1590.00),
("ORD-1007", "USR-1", "delivered", 890.00),
("ORD-1008", "USR-4", "pending", 3490.00),
]

# (product_id, name, category, price, in_stock, stock_quantity)
# (product_id, name, category, price ₽, in_stock, stock_quantity) — kitchen-appliance
# legend, generator-spec.md §3 categories/RRC bands
_PRODUCTS = [
("PRD-1", "Wireless Mouse", "Electronics", 29.99, True, 120),
("PRD-2", "Mechanical Keyboard", "Electronics", 89.99, True, 45),
("PRD-3", "USB-C Hub", "Electronics", 49.99, False, 0),
("PRD-4", "Standing Desk", "Home", 399.00, True, 8),
("PRD-5", "Desk Lamp", "Home", 24.50, True, 60),
("PRD-6", "SQL Cookbook", "Books", 39.95, False, 0),
("PRD-1", "Electric Kettle 1.7L 2200W", "kettles", 2190.00, True, 120),
("PRD-2", "Stand Mixer 5L Planetary", "mixers", 6990.00, True, 45),
("PRD-3", "Cold-Press Juicer", "juicers", 4490.00, False, 0),
("PRD-4", "Air Fryer Grill 5.5L", "grills", 5490.00, True, 8),
("PRD-5", "Digital Kitchen Scale 5kg", "scales", 990.00, True, 60),
("PRD-6", "Mini Chopper 500ml", "choppers", 1490.00, False, 0),
]

# (session_id, user_id, is_conversion)
Expand All @@ -59,7 +60,7 @@ def build_demo_warehouse() -> duckdb.DuckDBPyConnection:
conn.execute(
"INSERT INTO orders_v2 "
"(order_id, user_id, status, total_amount, currency, created_at) "
"VALUES (?, ?, ?, ?, 'USD', NOW() - INTERVAL '5 minutes')",
"VALUES (?, ?, ?, ?, 'RUB', NOW() - INTERVAL '5 minutes')",
[order_id, user_id, status, amount],
)

Expand Down
62 changes: 31 additions & 31 deletions scripts/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,52 +191,52 @@ def seed_benchmark_fixtures(db_path: Path) -> None:
conn.execute(
"""
INSERT OR REPLACE INTO products_current VALUES
('PROD-001', 'Wireless Headphones', 'electronics', 79.99, TRUE, 142),
('PROD-002', 'Running Shoes', 'footwear', 129.99, TRUE, 58),
('PROD-003', 'Coffee Maker', 'kitchen', 49.99, TRUE, 203),
('PROD-004', 'Mechanical Keyboard', 'electronics', 149.99, TRUE, 37),
('PROD-005', 'Yoga Mat', 'fitness', 34.99, TRUE, 315),
('PROD-006', 'Backpack', 'accessories', 89.99, TRUE, 94),
('PROD-007', 'Water Bottle', 'fitness', 24.99, TRUE, 421),
('PROD-008', 'Desk Lamp', 'home', 44.99, FALSE, 0),
('PROD-009', 'Bluetooth Speaker', 'electronics', 59.99, TRUE, 167),
('PROD-010', 'Sunglasses', 'accessories', 119.99, TRUE, 72)
('PROD-001', 'Electric Kettle 1.7L 2200W', 'kettles', 2190.00, FALSE, 0),
('PROD-002', 'Air Fryer Grill 5.5L', 'grills', 5490.00, TRUE, 58),
('PROD-003', 'Immersion Blender Set 800W', 'blenders', 2490.00, TRUE, 203),
('PROD-004', 'Stand Mixer 5L Planetary', 'mixers', 6990.00, TRUE, 37),
('PROD-005', 'Drip Coffee Maker 1.2L', 'coffee', 3490.00, TRUE, 94),
('PROD-006', 'Waffle Maker Double', 'multibakers', 2290.00, TRUE, 142),
('PROD-007', 'Mini Chopper 500ml', 'choppers', 1490.00, TRUE, 315),
('PROD-008', 'Cold-Press Juicer', 'juicers', 4490.00, TRUE, 72),
('PROD-009', 'Digital Kitchen Scale 5kg', 'scales', 990.00, TRUE, 421),
('PROD-010', 'Vacuum Sealer Compact', 'vacuum-dry', 3290.00, TRUE, 167)
"""
)
conn.execute(
"""
INSERT OR REPLACE INTO orders_v2 VALUES
('ORD-20260404-1001', 'USR-10001', 'delivered',
159.98, 'USD', NOW() - INTERVAL '2 hours'),
76400.00, 'RUB', NOW() - INTERVAL '2 hours'),
('ORD-20260404-1002', 'USR-10002', 'shipped',
129.99, 'USD', NOW() - INTERVAL '90 minutes'),
('ORD-20260404-1003', 'USR-10001', 'confirmed',
249.97, 'USD', NOW() - INTERVAL '1 hour'),
48100.00, 'RUB', NOW() - INTERVAL '90 minutes'),
('ORD-20260404-1003', 'USR-10003', 'confirmed',
2650.00, 'RUB', NOW() - INTERVAL '1 hour'),
('ORD-20260404-1004', 'USR-10003', 'pending',
79.99, 'USD', NOW() - INTERVAL '45 minutes'),
1890.00, 'RUB', NOW() - INTERVAL '45 minutes'),
('ORD-20260404-1005', 'USR-10004', 'delivered',
89.99, 'USD', NOW() - INTERVAL '30 minutes'),
('ORD-20260404-1006', 'USR-10002', 'cancelled',
34.99, 'USD', NOW() - INTERVAL '20 minutes'),
2290.00, 'RUB', NOW() - INTERVAL '30 minutes'),
('ORD-20260404-1006', 'USR-10004', 'cancelled',
1590.00, 'RUB', NOW() - INTERVAL '20 minutes'),
('ORD-20260404-1007', 'USR-10005', 'confirmed',
179.98, 'USD', NOW() - INTERVAL '15 minutes'),
('ORD-20260404-1008', 'USR-10003', 'pending',
59.99, 'USD', NOW() - INTERVAL '5 minutes')
2990.00, 'RUB', NOW() - INTERVAL '15 minutes'),
('ORD-20260404-1008', 'USR-10005', 'pending',
3990.00, 'RUB', NOW() - INTERVAL '5 minutes')
"""
)
conn.execute(
"""
INSERT OR REPLACE INTO users_enriched VALUES
('USR-10001', 15, 2340.50, NOW() - INTERVAL '180 days',
NOW() - INTERVAL '1 hour', 'electronics'),
('USR-10002', 8, 890.20, NOW() - INTERVAL '90 days',
NOW() - INTERVAL '20 minutes', 'footwear'),
('USR-10003', 3, 210.00, NOW() - INTERVAL '30 days',
NOW() - INTERVAL '5 minutes', 'electronics'),
('USR-10004', 22, 4100.75, NOW() - INTERVAL '365 days',
NOW() - INTERVAL '30 minutes', 'accessories'),
('USR-10005', 1, 179.98, NOW() - INTERVAL '1 day',
NOW() - INTERVAL '15 minutes', 'electronics')
('USR-10001', 34, 1200000.00, NOW() - INTERVAL '365 days',
NOW() - INTERVAL '2 hours', 'grills'),
('USR-10002', 15, 460000.00, NOW() - INTERVAL '270 days',
NOW() - INTERVAL '90 minutes', 'coffee'),
('USR-10003', 4, 8900.00, NOW() - INTERVAL '60 days',
NOW() - INTERVAL '45 minutes', 'choppers'),
('USR-10004', 6, 15800.00, NOW() - INTERVAL '120 days',
NOW() - INTERVAL '20 minutes', 'blenders'),
('USR-10005', 3, 28500.00, NOW() - INTERVAL '10 days',
NOW() - INTERVAL '5 minutes', 'vacuum-dry')
"""
)
conn.execute(
Expand Down
64 changes: 32 additions & 32 deletions tests/load/run_load_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def seed_benchmark_data(duckdb_path: Path) -> None:
user_id VARCHAR,
status VARCHAR,
total_amount DECIMAL(10,2),
currency VARCHAR DEFAULT 'USD',
currency VARCHAR DEFAULT 'RUB',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
"""
Expand Down Expand Up @@ -229,52 +229,52 @@ def seed_benchmark_data(duckdb_path: Path) -> None:
conn.execute(
"""
INSERT OR REPLACE INTO products_current VALUES
('PROD-001', 'Wireless Headphones', 'electronics', 79.99, TRUE, 142),
('PROD-002', 'Running Shoes', 'footwear', 129.99, TRUE, 58),
('PROD-003', 'Coffee Maker', 'kitchen', 49.99, TRUE, 203),
('PROD-004', 'Mechanical Keyboard', 'electronics', 149.99, TRUE, 37),
('PROD-005', 'Yoga Mat', 'fitness', 34.99, TRUE, 315),
('PROD-006', 'Backpack', 'accessories', 89.99, TRUE, 94),
('PROD-007', 'Water Bottle', 'fitness', 24.99, TRUE, 421),
('PROD-008', 'Desk Lamp', 'home', 44.99, FALSE, 0),
('PROD-009', 'Bluetooth Speaker', 'electronics', 59.99, TRUE, 167),
('PROD-010', 'Sunglasses', 'accessories', 119.99, TRUE, 72)
('PROD-001', 'Electric Kettle 1.7L 2200W', 'kettles', 2190.00, FALSE, 0),
('PROD-002', 'Air Fryer Grill 5.5L', 'grills', 5490.00, TRUE, 58),
('PROD-003', 'Immersion Blender Set 800W', 'blenders', 2490.00, TRUE, 203),
('PROD-004', 'Stand Mixer 5L Planetary', 'mixers', 6990.00, TRUE, 37),
('PROD-005', 'Drip Coffee Maker 1.2L', 'coffee', 3490.00, TRUE, 94),
('PROD-006', 'Waffle Maker Double', 'multibakers', 2290.00, TRUE, 142),
('PROD-007', 'Mini Chopper 500ml', 'choppers', 1490.00, TRUE, 315),
('PROD-008', 'Cold-Press Juicer', 'juicers', 4490.00, TRUE, 72),
('PROD-009', 'Digital Kitchen Scale 5kg', 'scales', 990.00, TRUE, 421),
('PROD-010', 'Vacuum Sealer Compact', 'vacuum-dry', 3290.00, TRUE, 167)
"""
)
conn.execute(
"""
INSERT OR REPLACE INTO orders_v2 VALUES
('ORD-20260404-1001', 'USR-10001', 'delivered',
159.98, 'USD', NOW() - INTERVAL '2 hours'),
76400.00, 'RUB', NOW() - INTERVAL '2 hours'),
('ORD-20260404-1002', 'USR-10002', 'shipped',
129.99, 'USD', NOW() - INTERVAL '90 minutes'),
('ORD-20260404-1003', 'USR-10001', 'confirmed',
249.97, 'USD', NOW() - INTERVAL '1 hour'),
48100.00, 'RUB', NOW() - INTERVAL '90 minutes'),
('ORD-20260404-1003', 'USR-10003', 'confirmed',
2650.00, 'RUB', NOW() - INTERVAL '1 hour'),
('ORD-20260404-1004', 'USR-10003', 'pending',
79.99, 'USD', NOW() - INTERVAL '45 minutes'),
1890.00, 'RUB', NOW() - INTERVAL '45 minutes'),
('ORD-20260404-1005', 'USR-10004', 'delivered',
89.99, 'USD', NOW() - INTERVAL '30 minutes'),
('ORD-20260404-1006', 'USR-10002', 'cancelled',
34.99, 'USD', NOW() - INTERVAL '20 minutes'),
2290.00, 'RUB', NOW() - INTERVAL '30 minutes'),
('ORD-20260404-1006', 'USR-10004', 'cancelled',
1590.00, 'RUB', NOW() - INTERVAL '20 minutes'),
('ORD-20260404-1007', 'USR-10005', 'confirmed',
179.98, 'USD', NOW() - INTERVAL '15 minutes'),
('ORD-20260404-1008', 'USR-10003', 'pending',
59.99, 'USD', NOW() - INTERVAL '5 minutes')
2990.00, 'RUB', NOW() - INTERVAL '15 minutes'),
('ORD-20260404-1008', 'USR-10005', 'pending',
3990.00, 'RUB', NOW() - INTERVAL '5 minutes')
"""
)
conn.execute(
"""
INSERT OR REPLACE INTO users_enriched VALUES
('USR-10001', 15, 2340.50, NOW() - INTERVAL '180 days',
NOW() - INTERVAL '1 hour', 'electronics'),
('USR-10002', 8, 890.20, NOW() - INTERVAL '90 days',
NOW() - INTERVAL '20 minutes', 'footwear'),
('USR-10003', 3, 210.00, NOW() - INTERVAL '30 days',
NOW() - INTERVAL '5 minutes', 'electronics'),
('USR-10004', 22, 4100.75, NOW() - INTERVAL '365 days',
NOW() - INTERVAL '30 minutes', 'accessories'),
('USR-10005', 1, 179.98, NOW() - INTERVAL '1 day',
NOW() - INTERVAL '15 minutes', 'electronics')
('USR-10001', 34, 1200000.00, NOW() - INTERVAL '365 days',
NOW() - INTERVAL '2 hours', 'grills'),
('USR-10002', 15, 460000.00, NOW() - INTERVAL '270 days',
NOW() - INTERVAL '90 minutes', 'coffee'),
('USR-10003', 4, 8900.00, NOW() - INTERVAL '60 days',
NOW() - INTERVAL '45 minutes', 'choppers'),
('USR-10004', 6, 15800.00, NOW() - INTERVAL '120 days',
NOW() - INTERVAL '20 minutes', 'blenders'),
('USR-10005', 3, 28500.00, NOW() - INTERVAL '10 days',
NOW() - INTERVAL '5 minutes', 'vacuum-dry')
"""
)
conn.execute(
Expand Down