Files
openobserve/tests/test-data/query-agent/queries/union.json
T
Neha PandClaude Opus 4.7 494025f83b test: add ~100 query-agent queries covering re_match, production patterns, deep nesting, edge cases (#12735)
## Summary
- Expands the query agent test suite from **574 → 675 queries** across
13 category files
- **20 re_match queries** — testing `\d`, `[abc]`, `^anchor`, `a|b`,
coercion, boolean mode, COALESCE+CASE patterns found 224x in production
- **19 production-inspired queries** —
histogram+re_match+CASE+percentage, COALESCE chains,
re_match+re_not_match combined
- **19 deep-nesting queries** — INTERSECT, EXCEPT, subquery-in-HAVING,
double-NOT-EXISTS, 2-level correlated subqueries
- **15 edge-case queries** — empty results, division-by-zero via NULLIF,
STDDEV of single row, NULL grouping, BETWEEN edge
- **10 window-depth queries** — multiple window functions, WINDOW clause
reuse, NTH_VALUE, NTILE, CUME_DIST
- **5 histogram+re_match queries** — covering production pattern of
histogram + filtered metric extraction
- **5 FTS combo queries** — match_all +
histogram/re_match/window/aggregation
- **5 aggregation edge queries** — multiple FILTER clauses, STRING_AGG
with ORDER BY, HAVING complexity
- Expected values regenerated by DuckDB oracle

## Test plan
- [ ] CI passes (memtable + parquet phases)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-17 12:51:13 +00:00

1565 lines
44 KiB
JSON

{
"queries": [
{
"id": "Q123",
"sql": "SELECT 'critical' AS charge_tier, COUNT(*) AS cnt FROM \"{stream}\" WHERE charge_remaining < 30.0 GROUP BY 'critical' UNION ALL SELECT 'normal' AS charge_tier, COUNT(*) AS cnt FROM \"{stream}\" WHERE charge_remaining >= 30.0 GROUP BY 'normal' ORDER BY charge_tier ASC",
"category": "union",
"expected": {
"columns": [
"charge_tier",
"cnt"
],
"results": [
[
"critical",
"5"
],
[
"normal",
"9"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7319000000,
"end_offset": 7483000000
}
},
{
"id": "Q124",
"sql": "SELECT sorter_model, COUNT(*) AS cnt FROM \"{stream}\" WHERE throughput_rate >= 500.0 GROUP BY sorter_model UNION SELECT sorter_model, COUNT(*) AS cnt FROM \"{stream}\" WHERE throughput_rate < 300.0 GROUP BY sorter_model ORDER BY sorter_model ASC",
"category": "union",
"expected": {
"columns": [
"sorter_model",
"cnt"
],
"results": [
[
"SORT-A7",
"1"
],
[
"SORT-A7",
"2"
],
[
"SORT-M3",
"3"
],
[
"SORT-Q5",
"1"
],
[
"SORT-X1",
"3"
],
[
"SORT-Z9",
"2"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7379000000,
"end_offset": 7543000000
}
},
{
"id": "Q125",
"sql": "SELECT 'fast' AS speed_tier, COUNT(*) AS cnt, ROUND(AVG(throughput_rate), 2) AS avg_tput FROM \"{stream}\" WHERE throughput_rate >= 700.0 UNION ALL SELECT 'medium' AS speed_tier, COUNT(*) AS cnt, ROUND(AVG(throughput_rate), 2) AS avg_tput FROM \"{stream}\" WHERE throughput_rate >= 300.0 AND throughput_rate < 700.0 UNION ALL SELECT 'slow' AS speed_tier, COUNT(*) AS cnt, ROUND(AVG(throughput_rate), 2) AS avg_tput FROM \"{stream}\" WHERE throughput_rate < 300.0 ORDER BY speed_tier ASC",
"category": "union",
"expected": {
"columns": [
"speed_tier",
"cnt",
"avg_tput"
],
"results": [
[
"fast",
"3",
"841.67"
],
[
"medium",
"7",
"515.71"
],
[
"slow",
"4",
"195.0"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7439000000,
"end_offset": 7603000000
}
},
{
"id": "Q126",
"sql": "SELECT sorter_model, operation_mode, COUNT(*) AS cnt FROM \"{stream}\" GROUP BY sorter_model, operation_mode HAVING COUNT(*) > 0 UNION ALL SELECT NULL AS sorter_model, operation_mode, COUNT(*) AS cnt FROM \"{stream}\" WHERE throughput_rate >= 800.0 GROUP BY operation_mode ORDER BY cnt DESC, sorter_model ASC LIMIT 8",
"category": "union",
"expected": {
"columns": [
"sorter_model",
"operation_mode",
"cnt"
],
"results": [
[
"SORT-A7",
"hybrid",
"2"
],
[
"SORT-A7",
"auto",
"2"
],
[
"SORT-M3",
"manual",
"2"
],
[
"SORT-M3",
"auto",
"2"
],
[
"SORT-X1",
"hybrid",
"2"
],
[
"SORT-Z9",
"manual",
"2"
],
[
"None",
"auto",
"2"
],
[
"SORT-Q5",
"auto",
"1"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7499000000,
"end_offset": 7663000000
}
},
{
"id": "Q127",
"sql": "SELECT _timestamp, log FROM \"{stream}\" WHERE cell_temp >= 30.0 UNION ALL SELECT _timestamp, log FROM \"{stream}\" WHERE cell_temp < 20.0 ORDER BY _timestamp DESC LIMIT 10",
"category": "union",
"expected": {
"columns": [
"log"
],
"results": [
[
"Q129 warehouse event record 2"
],
[
"Q129 warehouse event record 1"
],
[
"Q128 warehouse event record 4"
],
[
"Q128 warehouse event record 1"
],
[
"Q127 warehouse event record 4"
],
[
"Q128 warehouse event record 0 ACK batch batchIdList:Q128-0"
],
[
"Q127 warehouse event record 3 ACK batch batchIdList:Q127-3"
],
[
"Q127 warehouse event record 2"
]
],
"results_mode": "rowsort",
"skip_sqllogictest": true
},
"time_offset": {
"start_offset": 7559000000,
"end_offset": 7723000000
}
},
{
"id": "Q128",
"sql": "WITH zone_agg AS (SELECT facility_zone AS location, 'zone' AS granularity, COUNT(*) AS total, ROUND(AVG(throughput_rate), 2) AS avg_tput FROM \"{stream}\" GROUP BY facility_zone), center_agg AS (SELECT control_center AS location, 'center' AS granularity, COUNT(*) AS total, ROUND(AVG(throughput_rate), 2) AS avg_tput FROM \"{stream}\" GROUP BY control_center), combined AS (SELECT * FROM zone_agg UNION ALL SELECT * FROM center_agg) SELECT * FROM combined ORDER BY granularity ASC, avg_tput DESC",
"category": "union",
"expected": {
"columns": [
"location",
"granularity",
"total",
"avg_tput"
],
"results": [
[
"CC-BETA",
"center",
"4",
"667.5"
],
[
"CC-DELTA",
"center",
"3",
"591.67"
],
[
"CC-GAMMA",
"center",
"3",
"320.0"
],
[
"CC-ALPHA",
"center",
"4",
"277.5"
],
[
"ZONE-3",
"zone",
"4",
"667.5"
],
[
"ZONE-1",
"zone",
"3",
"591.67"
],
[
"ZONE-4",
"zone",
"3",
"320.0"
],
[
"ZONE-2",
"zone",
"4",
"277.5"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7619000000,
"end_offset": 7783000000
}
},
{
"id": "Q129",
"sql": "SELECT facility_zone, sorter_model, COUNT(*) AS cnt, MAX(throughput_rate) AS max_tput FROM \"{stream}\" WHERE operation_mode = 'auto' GROUP BY facility_zone, sorter_model UNION SELECT facility_zone, sorter_model, COUNT(*) AS cnt, MAX(throughput_rate) AS max_tput FROM \"{stream}\" WHERE operation_mode = 'hybrid' GROUP BY facility_zone, sorter_model ORDER BY facility_zone ASC, max_tput DESC",
"category": "union",
"expected": {
"columns": [
"facility_zone",
"sorter_model",
"cnt",
"max_tput"
],
"results": [
[
"ZONE-1",
"SORT-M3",
"2",
"900.0"
],
[
"ZONE-2",
"SORT-Q5",
"1",
"480.0"
],
[
"ZONE-3",
"SORT-X1",
"2",
"840.0"
],
[
"ZONE-4",
"SORT-A7",
"2",
"725.0"
],
[
"ZONE-4",
"SORT-A7",
"2",
"480.0"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7679000000,
"end_offset": 7843000000
}
},
{
"id": "Q130",
"sql": "WITH auto_top AS (SELECT facility_zone, sorter_model, throughput_rate, ROW_NUMBER() OVER (PARTITION BY facility_zone ORDER BY throughput_rate DESC) AS rn FROM \"{stream}\" WHERE operation_mode='auto' AND throughput_rate IS NOT NULL), manual_top AS (SELECT facility_zone, sorter_model, throughput_rate, ROW_NUMBER() OVER (PARTITION BY facility_zone ORDER BY throughput_rate DESC) AS rn FROM \"{stream}\" WHERE operation_mode='manual' AND throughput_rate IS NOT NULL) SELECT facility_zone, sorter_model, throughput_rate, rn, 'auto' AS mode FROM auto_top WHERE rn <= 2 UNION ALL SELECT facility_zone, sorter_model, throughput_rate, rn, 'manual' AS mode FROM manual_top WHERE rn <= 2 ORDER BY mode ASC, facility_zone ASC, rn ASC",
"category": "union",
"expected": {
"columns": [
"facility_zone",
"sorter_model",
"throughput_rate",
"rn",
"mode"
],
"results": [
[
"ZONE-1",
"SORT-M3",
"900.0",
"1",
"auto"
],
[
"ZONE-1",
"SORT-M3",
"840.0",
"2",
"auto"
],
[
"ZONE-2",
"SORT-Q5",
"480.0",
"1",
"auto"
],
[
"ZONE-2",
"SORT-Q5",
"190.0",
"2",
"auto"
],
[
"ZONE-4",
"SORT-A7",
"480.0",
"1",
"auto"
],
[
"ZONE-4",
"SORT-A7",
"290.0",
"2",
"auto"
],
[
"ZONE-1",
"SORT-M3",
"555.0",
"1",
"manual"
],
[
"ZONE-1",
"SORT-M3",
"320.0",
"2",
"manual"
],
[
"ZONE-2",
"SORT-Z9",
"725.0",
"1",
"manual"
],
[
"ZONE-3",
"SORT-X1",
"610.0",
"1",
"manual"
],
[
"ZONE-3",
"SORT-X1",
"555.0",
"2",
"manual"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7739000000,
"end_offset": 7903000000
}
},
{
"id": "Q131",
"sql": "SELECT _timestamp, pallet_id, facility_zone, load_factor, 'day_shift' AS shift FROM \"{stream}\" WHERE runtime_hours IS NOT NULL AND CAST(FLOOR(CAST(runtime_hours AS FLOAT) / 24.0) AS INTEGER) % 2 = 0 UNION ALL SELECT _timestamp, pallet_id, facility_zone, load_factor, 'night_shift' AS shift FROM \"{stream}\" WHERE runtime_hours IS NOT NULL AND CAST(FLOOR(CAST(runtime_hours AS FLOAT) / 24.0) AS INTEGER) % 2 = 1 ORDER BY shift ASC, load_factor DESC LIMIT 20",
"category": "union",
"expected": {
"columns": [
"pallet_id",
"facility_zone",
"load_factor",
"shift"
],
"results": [
[
"PL-006",
"ZONE-4",
"88.1",
"day_shift"
],
[
"PL-004",
"ZONE-2",
"88.1",
"day_shift"
],
[
"PL-002",
"ZONE-4",
"55.2",
"day_shift"
],
[
"PL-001",
"ZONE-3",
"33.0",
"day_shift"
],
[
"PL-007",
"ZONE-1",
"33.0",
"day_shift"
],
[
"PL-007",
"ZONE-1",
"94.6",
"night_shift"
],
[
"PL-005",
"ZONE-3",
"72.8",
"night_shift"
],
[
"PL-003",
"ZONE-1",
"72.8",
"night_shift"
],
[
"PL-001",
"ZONE-3",
"67.9",
"night_shift"
],
[
"PL-003",
"ZONE-1",
"67.9",
"night_shift"
],
[
"PL-008",
"ZONE-2",
"45.3",
"night_shift"
],
[
"PL-002",
"ZONE-4",
"45.3",
"night_shift"
],
[
"PL-004",
"ZONE-2",
"21.4",
"night_shift"
],
[
"PL-008",
"ZONE-2",
"12.5",
"night_shift"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7799000000,
"end_offset": 7963000000
}
},
{
"id": "Q132",
"sql": "WITH ranked_all AS (SELECT _timestamp, pallet_id, facility_zone, throughput_rate, ROW_NUMBER() OVER (PARTITION BY facility_zone ORDER BY throughput_rate DESC) AS rn FROM \"{stream}\" WHERE throughput_rate IS NOT NULL) SELECT facility_zone, pallet_id, throughput_rate, rn, 'LEADER' AS label FROM ranked_all WHERE rn = 1 UNION ALL SELECT facility_zone, pallet_id, throughput_rate, rn, 'RUNNER_UP' AS label FROM ranked_all WHERE rn = 2 UNION ALL SELECT facility_zone, pallet_id, throughput_rate, rn, 'TRAILING' AS label FROM ranked_all WHERE rn >= 5 ORDER BY facility_zone ASC, rn ASC",
"category": "union",
"expected": {
"columns": [
"facility_zone",
"pallet_id",
"throughput_rate",
"rn",
"label"
],
"results": [
[
"ZONE-1",
"PL-007",
"900.0",
"1",
"LEADER"
],
[
"ZONE-1",
"PL-007",
"610.0",
"2",
"RUNNER_UP"
],
[
"ZONE-2",
"PL-008",
"725.0",
"1",
"LEADER"
],
[
"ZONE-2",
"PL-004",
"480.0",
"2",
"RUNNER_UP"
],
[
"ZONE-3",
"PL-001",
"840.0",
"1",
"LEADER"
],
[
"ZONE-3",
"PL-005",
"610.0",
"2",
"RUNNER_UP"
],
[
"ZONE-4",
"PL-006",
"725.0",
"1",
"LEADER"
],
[
"ZONE-4",
"PL-006",
"190.0",
"2",
"RUNNER_UP"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7859000000,
"end_offset": 8023000000
}
},
{
"id": "Q133",
"sql": "SELECT facility_zone, COUNT(*) FILTER (WHERE operation_mode='auto') AS auto_cnt, COUNT(*) FILTER (WHERE operation_mode='manual') AS manual_cnt, ROUND(AVG(throughput_rate) FILTER (WHERE operation_mode='auto'), 2) AS avg_tput_auto, ROUND(AVG(throughput_rate) FILTER (WHERE operation_mode='manual'), 2) AS avg_tput_manual, ROUND(AVG(cell_temp) FILTER (WHERE operation_mode='auto'), 2) AS avg_temp_auto, ROUND(AVG(cell_temp) FILTER (WHERE operation_mode='manual'), 2) AS avg_temp_manual FROM \"{stream}\" GROUP BY facility_zone ORDER BY facility_zone ASC",
"category": "union",
"expected": {
"columns": [
"facility_zone",
"auto_cnt",
"manual_cnt",
"avg_tput_auto",
"avg_tput_manual",
"avg_temp_auto",
"avg_temp_manual"
],
"results": [
[
"ZONE-1",
"1",
"2",
"610.0",
"437.5",
"28.9",
"20.6"
],
[
"ZONE-2",
"2",
"1",
"385.0",
"725.0",
"21.65",
"32.5"
],
[
"ZONE-3",
"0",
"2",
"None",
"582.5",
"None",
"25.45"
],
[
"ZONE-4",
"2",
"0",
"220.0",
"None",
"27.1",
"None"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7919000000,
"end_offset": 8083000000
}
},
{
"id": "Q134",
"sql": "SELECT CASE WHEN charge_remaining < 35.0 THEN 'low_charge' WHEN charge_remaining BETWEEN 35.0 AND 70.0 THEN 'medium_charge' ELSE 'high_charge' END AS category, COUNT(*) AS cnt, ROUND(AVG(cell_temp), 2) AS avg_temp, ROUND(AVG(throughput_rate), 2) AS avg_tput FROM \"{stream}\" GROUP BY category ORDER BY category ASC",
"category": "union",
"expected": {
"columns": [
"category",
"cnt",
"avg_temp",
"avg_tput"
],
"results": [
[
"high_charge",
"2",
"24.05",
"465.0"
],
[
"low_charge",
"6",
"29.22",
"598.33"
],
[
"medium_charge",
"6",
"28.1",
"446.67"
]
],
"results_mode": "rowsort"
},
"time_offset": {
"start_offset": 7979000000,
"end_offset": 8143000000
}
},
{
"id": "Q158",
"sql": "SELECT '10-20' AS bucket, count(distinct array_extract(regexp_match(event_detail, 'track ([A-Za-z0-9-]+)'), 1)) AS itemcount FROM \"{stream}\" WHERE str_match_ignore_case(event_detail, 'sorter batch') AND app_label != 'tax-prod-b' AND CAST(array_extract(regexp_match(event_detail, 'segment ([0-9]+)'), 1) AS INT) BETWEEN 1 AND 5 UNION ALL SELECT '21-30' AS bucket, count(distinct array_extract(regexp_match(event_detail, 'track ([A-Za-z0-9-]+)'), 1)) AS itemcount FROM \"{stream}\" WHERE str_match_ignore_case(event_detail, 'sorter batch') AND app_label != 'tax-prod-b' AND CAST(array_extract(regexp_match(event_detail, 'segment ([0-9]+)'), 1) AS INT) BETWEEN 6 AND 10",
"category": "union",
"expected": {
"columns": [
"bucket",
"itemcount"
],
"results": [
[
"10-20",
"0"
],
[
"21-30",
"0"
]
],
"results_mode": "rowsort",
"skip_sqllogictest": true
},
"time_offset": {
"start_offset": 9419000000,
"end_offset": 9583000000
}
},
{
"id": "Q197",
"sql": "SELECT facility_zone, 'auto_ops' AS category, COUNT(*) AS cnt, AVG(throughput_rate) AS avg_tput\nFROM \"{stream}\"\nWHERE operation_mode = 'auto' AND load_factor > 20.0\nGROUP BY facility_zone\nUNION\nSELECT facility_zone, 'manual_ops' AS category, COUNT(*) AS cnt, AVG(throughput_rate) AS avg_tput\nFROM \"{stream}\"\nWHERE operation_mode = 'manual' AND load_factor > 20.0\nGROUP BY facility_zone\nUNION\nSELECT facility_zone, 'hybrid_ops' AS category, COUNT(*) AS cnt, AVG(throughput_rate) AS avg_tput\nFROM \"{stream}\"\nWHERE operation_mode = 'hybrid' AND load_factor > 20.0\nGROUP BY facility_zone\nORDER BY category, avg_tput DESC",
"category": "union",
"time_offset": {
"start_offset": 11759000000,
"end_offset": 11923000000
},
"expected": {
"columns": [
"facility_zone",
"category",
"cnt",
"avg_tput"
],
"results": [
[
"ZONE-1",
"auto_ops",
"1",
"840.0"
],
[
"ZONE-4",
"auto_ops",
"2",
"335.0"
],
[
"ZONE-2",
"auto_ops",
"1",
"190.0"
],
[
"ZONE-3",
"hybrid_ops",
"2",
"582.5"
],
[
"ZONE-4",
"hybrid_ops",
"2",
"220.0"
],
[
"ZONE-3",
"manual_ops",
"2",
"870.0"
],
[
"ZONE-1",
"manual_ops",
"2",
"755.0"
],
[
"ZONE-2",
"manual_ops",
"1",
"290.0"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q198",
"sql": "SELECT region_code, facility_zone,\n COUNT(*) AS cnt,\n AVG(throughput_rate) AS avg_throughput,\n MAX(load_factor) AS max_load\nFROM \"{stream}\"\nWHERE load_factor >= 50.0 AND throughput_rate >= 300.0\nGROUP BY region_code, facility_zone\nUNION ALL\nSELECT region_code, facility_zone,\n COUNT(*) AS cnt,\n AVG(throughput_rate) AS avg_throughput,\n MAX(load_factor) AS max_load\nFROM \"{stream}\"\nWHERE load_factor < 50.0 AND throughput_rate < 300.0\nGROUP BY region_code, facility_zone\nORDER BY avg_throughput DESC\nLIMIT 20",
"category": "union",
"time_offset": {
"start_offset": 11819000000,
"end_offset": 11983000000
},
"expected": {
"columns": [
"region_code",
"facility_zone",
"cnt",
"avg_throughput",
"max_load"
],
"results": [
[
"AP-CENTRAL",
"ZONE-1",
"1",
"900.0",
"94.6"
],
[
"AP-CENTRAL",
"ZONE-3",
"1",
"900.0",
"94.6"
],
[
"EU-NORTH",
"ZONE-1",
"1",
"610.0",
"99.0"
],
[
"US-CENTRAL",
"ZONE-3",
"1",
"555.0",
"72.8"
],
[
"US-WEST",
"ZONE-3",
"1",
"320.0",
"67.9"
],
[
"US-WEST",
"ZONE-1",
"1",
"320.0",
"67.9"
],
[
"US-EAST",
"ZONE-4",
"1",
"150.0",
"45.3"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q381",
"sql": "SELECT 'item_page' AS source, component_name, COUNT(*) AS cnt FROM \"{stream}\" WHERE page_slug = 'itemPage' AND action_category = 'performanceMetric' GROUP BY component_name UNION ALL SELECT 'cart_page' AS source, component_name, COUNT(*) AS cnt FROM \"{stream}\" WHERE page_slug = 'cartPage' AND action_category = 'performanceMetric' GROUP BY component_name UNION ALL SELECT 'search_page' AS source, component_name, COUNT(*) AS cnt FROM \"{stream}\" WHERE page_slug = 'searchPage' AND action_category = 'performanceMetric' GROUP BY component_name",
"category": "union",
"time_offset": {
"start_offset": 22799000000,
"end_offset": 22873000000
},
"expected": {
"columns": [
"source",
"component_name",
"cnt"
],
"results": [
[
"item_page",
"pallet-mapper",
"2"
],
[
"cart_page",
"batch-sync",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q382",
"sql": "SELECT 'Android' AS platform, page_slug, COUNT(*) AS cnt FROM \"{stream}\" WHERE os_platform LIKE '%Android%' AND action_category = 'navigation' GROUP BY page_slug UNION ALL SELECT 'iOS' AS platform, page_slug, COUNT(*) AS cnt FROM \"{stream}\" WHERE (os_platform LIKE '%iOS%' OR os_platform LIKE '%iPhone%') AND action_category = 'navigation' GROUP BY page_slug UNION ALL SELECT 'Other' AS platform, page_slug, COUNT(*) AS cnt FROM \"{stream}\" WHERE os_platform NOT LIKE '%Android%' AND os_platform NOT LIKE '%iOS%' AND os_platform NOT LIKE '%iPhone%' AND action_category = 'navigation' GROUP BY page_slug",
"category": "union",
"time_offset": {
"start_offset": 22859000000,
"end_offset": 22933000000
},
"expected": {
"columns": [
"platform",
"page_slug",
"cnt"
],
"results": [
[
"iOS",
"homePage",
"2"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q383",
"sql": "SELECT coalesce(page_url, page_slug) AS source, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'navigation' AND page_slug = 'itemPage' GROUP BY source UNION ALL SELECT coalesce(page_url, page_slug) AS source, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'navigation' AND page_slug = 'cartPage' GROUP BY source",
"category": "union",
"time_offset": {
"start_offset": 22919000000,
"end_offset": 22993000000
},
"expected": {
"columns": [
"source",
"cnt"
],
"results": [
[
"https://shop.example.com/item/1002",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q384",
"sql": "SELECT 'east' AS region, error_code, COUNT(*) AS cnt FROM \"{stream}\" WHERE org_name = 'warehouse-east' AND action_category = 'performanceMetric' AND error_code IS NOT NULL GROUP BY error_code UNION ALL SELECT 'west' AS region, error_code, COUNT(*) AS cnt FROM \"{stream}\" WHERE org_name = 'warehouse-west' AND action_category = 'performanceMetric' AND error_code IS NOT NULL GROUP BY error_code",
"category": "union",
"time_offset": {
"start_offset": 22979000000,
"end_offset": 23053000000
},
"expected": {
"columns": [
"region",
"error_code",
"cnt"
],
"results": [
[
"east",
"E004",
"2"
],
[
"west",
"E005",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q385",
"sql": "SELECT 'mobile' AS device_class, action_category, COUNT(*) AS cnt FROM \"{stream}\" WHERE device_type IN ('Mobile', 'Tablet') AND action_category IN ('performanceMetric', 'navigation') GROUP BY action_category UNION ALL SELECT 'desktop' AS device_class, action_category, COUNT(*) AS cnt FROM \"{stream}\" WHERE device_type = 'Computer' AND action_category IN ('performanceMetric', 'navigation') GROUP BY action_category",
"category": "union",
"time_offset": {
"start_offset": 23039000000,
"end_offset": 23113000000
},
"expected": {
"columns": [
"device_class",
"action_category",
"cnt"
],
"results": [
[
"mobile",
"performanceMetric",
"2"
],
[
"desktop",
"performanceMetric",
"1"
],
[
"desktop",
"navigation",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q386",
"sql": "SELECT 'errors' AS event_type, error_code AS detail, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'performanceMetric' AND error_code IS NOT NULL AND exception_message LIKE '%Exception%' GROUP BY error_code UNION ALL SELECT 'upstream_errors' AS event_type, upstream_error_code AS detail, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'performanceMetric' AND upstream_error_code IS NOT NULL AND upstream_error_code LIKE '%UP-E%' GROUP BY upstream_error_code",
"category": "union",
"time_offset": {
"start_offset": 23099000000,
"end_offset": 23173000000
},
"expected": {
"columns": [
"event_type",
"detail",
"cnt"
],
"results": [
[
"errors",
"E009",
"1"
],
[
"errors",
"E003",
"1"
],
[
"errors",
"E001",
"1"
],
[
"upstream_errors",
"UP-E007",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q387",
"sql": "SELECT (CASE WHEN os_platform LIKE '%Android%' THEN 'Android' ELSE 'non-Android' END) AS platform, COUNT(CASE WHEN action_category = 'navigation' THEN 1 END) AS nav_cnt, COUNT(CASE WHEN action_category = 'performanceMetric' THEN 1 END) AS metric_cnt FROM \"{stream}\" GROUP BY platform UNION ALL SELECT 'TOTAL' AS platform, COUNT(CASE WHEN action_category = 'navigation' THEN 1 END) AS nav_cnt, COUNT(CASE WHEN action_category = 'performanceMetric' THEN 1 END) AS metric_cnt FROM \"{stream}\" ",
"category": "union",
"time_offset": {
"start_offset": 23159000000,
"end_offset": 23233000000
},
"expected": {
"columns": [
"platform",
"nav_cnt",
"metric_cnt"
],
"results": [
[
"Android",
"1",
"2"
],
[
"non-Android",
"0",
"4"
],
[
"TOTAL",
"1",
"6"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q388",
"sql": "SELECT * FROM (SELECT _timestamp, 'error' AS record_type, exception_message AS detail, action_category FROM \"{stream}\" WHERE action_category = 'performanceMetric' AND exception_message LIKE '%Exception%' LIMIT 10) UNION ALL SELECT * FROM (SELECT _timestamp, 'timeout' AS record_type, event_detail AS detail, action_category FROM \"{stream}\" WHERE action_category = 'performanceMetric' AND event_detail LIKE '%timeout%' LIMIT 10)",
"category": "union",
"time_offset": {
"start_offset": 23219000000,
"end_offset": 23293000000
},
"expected": {
"columns": [
"record_type",
"detail",
"action_category"
],
"results": [
[
"error",
"NetworkException: connection to batch sync failed",
"performanceMetric"
],
[
"error",
"ConfigurationException: missing facility_zone ZONE-3 override",
"performanceMetric"
],
[
"error",
"NetworkException: connection to batch sync failed",
"performanceMetric"
],
[
"error",
"OverflowException: throughput_rate 999.0 exceeds max capacity",
"performanceMetric"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q389",
"sql": "SELECT 'prod' AS env, error_code, COUNT(*) AS cnt FROM \"{stream}\" WHERE tag_a = 'prod' AND action_category = 'performanceMetric' AND error_code IS NOT NULL GROUP BY error_code UNION ALL SELECT 'staging' AS env, error_code, COUNT(*) AS cnt FROM \"{stream}\" WHERE tag_a = 'staging' AND action_category = 'performanceMetric' AND error_code IS NOT NULL GROUP BY error_code UNION ALL SELECT 'dev' AS env, error_code, COUNT(*) AS cnt FROM \"{stream}\" WHERE tag_a = 'dev' AND action_category = 'performanceMetric' AND error_code IS NOT NULL GROUP BY error_code",
"category": "union",
"time_offset": {
"start_offset": 23279000000,
"end_offset": 23353000000
},
"expected": {
"columns": [
"env",
"error_code",
"cnt"
],
"results": [
[
"prod",
"E001",
"2"
],
[
"dev",
"E009",
"2"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q390",
"sql": "SELECT 'page_nav' AS metric, page_slug AS label, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'navigation' GROUP BY page_slug UNION ALL SELECT 'component_err' AS metric, component_name AS label, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'performanceMetric' AND error_code IS NOT NULL GROUP BY component_name",
"category": "union",
"time_offset": {
"start_offset": 23339000000,
"end_offset": 23413000000
},
"expected": {
"columns": [
"metric",
"label",
"cnt"
],
"results": [
[
"page_nav",
"itemPage",
"2"
],
[
"component_err",
"batch-sync",
"2"
],
[
"component_err",
"zone-controller",
"1"
],
[
"component_err",
"pallet-mapper",
"1"
],
[
"component_err",
"track-router",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q391",
"sql": "SELECT org_name, (CASE WHEN os_platform LIKE '%Android%' THEN 'Android' ELSE os_platform END) AS platform, COUNT(*) AS cnt FROM \"{stream}\" WHERE org_name IN ('warehouse-south') AND action_category = 'interaction' GROUP BY org_name, platform UNION ALL SELECT 'warehouse-north' AS org_name, (CASE WHEN os_platform LIKE '%Android%' THEN 'Android' ELSE os_platform END) AS platform, COUNT(*) AS cnt FROM \"{stream}\" WHERE org_name = 'warehouse-north' AND action_category = 'performanceMetric' GROUP BY platform",
"category": "union",
"time_offset": {
"start_offset": 23399000000,
"end_offset": 23473000000
},
"expected": {
"columns": [
"org_name",
"platform",
"cnt"
],
"results": [
[
"warehouse-south",
"Android",
"2"
],
[
"warehouse-north",
"Android",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q392",
"sql": "SELECT error_code, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'performanceMetric' AND error_code IS NOT NULL GROUP BY error_code UNION ALL SELECT upstream_error_code, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'performanceMetric' AND upstream_error_code IS NOT NULL GROUP BY upstream_error_code ORDER BY cnt DESC, error_code ASC LIMIT 10",
"category": "union",
"time_offset": {
"start_offset": 23459000000,
"end_offset": 23533000000
},
"expected": {
"columns": [
"error_code",
"cnt"
],
"results": [
[
"E001",
"1"
],
[
"E009",
"1"
],
[
"UP-E003",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q500",
"sql": "SELECT 'error_bucket' AS source, error_code AS label, COUNT(*) AS cnt FROM \"{stream}\" WHERE error_code IS NOT NULL GROUP BY error_code UNION ALL SELECT 'response_bucket' AS source, CAST(response_code AS VARCHAR) AS label, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'performanceMetric' GROUP BY response_code ORDER BY source ASC, cnt DESC",
"category": "union",
"time_offset": {
"start_offset": 29939000000,
"end_offset": 30013000000
},
"expected": {
"columns": [
"source",
"label",
"cnt"
],
"results": [
[
"error_bucket",
"E002",
"2"
],
[
"error_bucket",
"E004",
"2"
],
[
"error_bucket",
"E003",
"1"
],
[
"error_bucket",
"E001",
"1"
],
[
"error_bucket",
"E005",
"1"
],
[
"response_bucket",
"503",
"2"
],
[
"response_bucket",
"400",
"1"
],
[
"response_bucket",
"401",
"1"
],
[
"response_bucket",
"500",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q501",
"sql": "SELECT page_slug, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'navigation' AND page_slug IS NOT NULL GROUP BY page_slug UNION ALL SELECT page_slug, COUNT(*) AS cnt FROM \"{stream}\" WHERE action_category = 'interaction' AND page_slug IS NOT NULL GROUP BY page_slug ORDER BY cnt DESC, page_slug ASC",
"category": "union",
"time_offset": {
"start_offset": 29999000000,
"end_offset": 30073000000
},
"expected": {
"columns": [
"page_slug",
"cnt"
],
"results": [
[
"itemPage",
"2"
],
[
"homePage",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q502",
"sql": "SELECT action_category, 'min' AS stat, ROUND(MIN(CAST(latency_ms AS FLOAT)), 1) AS val FROM \"{stream}\" WHERE latency_ms > 0 GROUP BY action_category UNION ALL SELECT action_category, 'max' AS stat, ROUND(MAX(CAST(latency_ms AS FLOAT)), 1) AS val FROM \"{stream}\" WHERE latency_ms > 0 GROUP BY action_category UNION ALL SELECT action_category, 'avg' AS stat, ROUND(AVG(CAST(latency_ms AS FLOAT)), 1) AS val FROM \"{stream}\" WHERE latency_ms > 0 GROUP BY action_category ORDER BY action_category ASC, stat ASC",
"category": "union",
"time_offset": {
"start_offset": 30059000000,
"end_offset": 30133000000
},
"expected": {
"columns": [
"action_category",
"stat",
"val"
],
"results": [
[
"interaction",
"avg",
"1076.7"
],
[
"interaction",
"max",
"3200.0"
],
[
"interaction",
"min",
"15.0"
],
[
"navigation",
"avg",
"78.0"
],
[
"navigation",
"max",
"78.0"
],
[
"navigation",
"min",
"78.0"
],
[
"performanceMetric",
"avg",
"956.0"
],
[
"performanceMetric",
"max",
"1900.0"
],
[
"performanceMetric",
"min",
"12.0"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q503",
"sql": "SELECT 'high_tput' AS label, COUNT(*) AS cnt, ROUND(AVG(CAST(throughput_rate AS FLOAT)), 1) AS avg_val FROM \"{stream}\" WHERE throughput_rate > 500 UNION ALL SELECT 'low_tput' AS label, COUNT(*) AS cnt, ROUND(AVG(CAST(throughput_rate AS FLOAT)), 1) AS avg_val FROM \"{stream}\" WHERE throughput_rate <= 500 UNION ALL SELECT 'high_load' AS label, COUNT(*) AS cnt, ROUND(AVG(CAST(load_factor AS FLOAT)), 1) AS avg_val FROM \"{stream}\" WHERE load_factor > 50 ORDER BY label ASC",
"category": "union",
"time_offset": {
"start_offset": 30119000000,
"end_offset": 30193000000
},
"expected": {
"columns": [
"label",
"cnt",
"avg_val"
],
"results": [
[
"high_load",
"4",
"83.5"
],
[
"high_tput",
"3",
"648.3"
],
[
"low_tput",
"4",
"317.5"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q504",
"sql": "SELECT component_name, COUNT(*) AS cnt FROM \"{stream}\" WHERE component_name IN ('sorter-engine', 'conveyor-driver', 'zone-controller', 'scan-hub') AND action_category = 'performanceMetric' GROUP BY component_name UNION ALL SELECT component_name, COUNT(*) AS cnt FROM \"{stream}\" WHERE component_name IN ('track-router', 'batch-sync', 'pallet-mapper', 'lane-monitor') AND action_category = 'performanceMetric' GROUP BY component_name ORDER BY cnt DESC, component_name ASC",
"category": "union",
"time_offset": {
"start_offset": 30179000000,
"end_offset": 30253000000
},
"expected": {
"columns": [
"component_name",
"cnt"
],
"results": [
[
"batch-sync",
"2"
],
[
"lane-monitor",
"2"
],
[
"pallet-mapper",
"1"
],
[
"track-router",
"1"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q505",
"sql": "SELECT 'Mobile' AS platform_type, COUNT(*) AS cnt, ROUND(AVG(CAST(latency_ms AS FLOAT)), 1) AS avg_lat FROM \"{stream}\" WHERE device_type = 'Mobile' AND latency_ms > 0 UNION ALL SELECT 'Computer' AS platform_type, COUNT(*) AS cnt, ROUND(AVG(CAST(latency_ms AS FLOAT)), 1) AS avg_lat FROM \"{stream}\" WHERE device_type = 'Computer' AND latency_ms > 0 UNION ALL SELECT 'Tablet' AS platform_type, COUNT(*) AS cnt, ROUND(AVG(CAST(latency_ms AS FLOAT)), 1) AS avg_lat FROM \"{stream}\" WHERE device_type = 'Tablet' AND latency_ms > 0 ORDER BY platform_type ASC",
"category": "union",
"time_offset": {
"start_offset": 30239000000,
"end_offset": 30313000000
},
"expected": {
"columns": [
"platform_type",
"cnt",
"avg_lat"
],
"results": [
[
"Computer",
"3",
"220.0"
],
[
"Mobile",
"4",
"2550.0"
],
[
"Tablet",
"0",
"None"
]
],
"results_mode": "rowsort"
}
},
{
"id": "Q556",
"sql": "SELECT component_name AS source, latency_ms AS metric, 'latency' AS metric_type FROM \"{stream}\" WHERE latency_ms > 500 UNION ALL SELECT component_name AS source, lcp_micros AS metric, 'lcp' AS metric_type FROM \"{stream}\" WHERE lcp_micros > 1000000 ORDER BY metric_type, metric DESC LIMIT 15",
"category": "union",
"time_offset": {
"start_offset": 33299000000,
"end_offset": 33373000000
},
"expected": {
"columns": [
"source",
"metric",
"metric_type"
],
"results": [
[
"sorter-engine",
"1900",
"latency"
],
[
"track-router",
"3200000",
"lcp"
],
[
"zone-controller",
"2500000",
"lcp"
],
[
"scan-hub",
"1800000",
"lcp"
],
[
"scan-hub",
"1800000",
"lcp"
],
[
"conveyor-driver",
"1200000",
"lcp"
],
[
"conveyor-driver",
"1200000",
"lcp"
],
[
"sorter-engine",
"1100000",
"lcp"
]
],
"results_mode": "rowsort"
}
}
],
"last_query_id": 158
}