Commit c1698df
fix(analytics): fall back to aggregate strategy when the driver can't run SQL (#1701)
Every dataset query on an in-memory-driver environment returned rows:[] with
HTTP 200 and the compiled SQL attached — dashboards read "No rows" forever
while looking healthy (live staging incident: even COUNT(*) FROM sys_user and
queries against nonexistent tables came back empty).
Root cause chain: InMemoryDriver.execute() returns null for raw SQL; the
analytics plugin's auto-bridge mapped null to [] silently; and the default
queryCapabilities unconditionally advertise nativeSql, so NativeSQLStrategy
was always selected even on drivers that cannot execute SQL.
Fix at both layers:
- the raw-SQL bridge now throws a TYPED error (code RAW_SQL_UNSUPPORTED) when
the engine returns null/undefined — an empty result is never fabricated;
- AnalyticsService.query treats that error as a runtime capability miss and
falls back to the next capable strategy (ObjectQLStrategy over the
aggregate bridge — the in-memory driver implements aggregate()), skipping
the proven-incapable one. Any other error propagates untouched, and when no
fallback exists the failure is loud and names the skipped strategies.
service-analytics: 109 tests green (3 new covering fallback, error
passthrough, and the no-fallback loud failure).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent d251d95 commit c1698df
3 files changed
Lines changed: 114 additions & 8 deletions
File tree
- packages/services/service-analytics/src
- __tests__
Lines changed: 63 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
Lines changed: 35 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
287 | 295 | | |
288 | 296 | | |
289 | 297 | | |
| |||
292 | 300 | | |
293 | 301 | | |
294 | 302 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
299 | 320 | | |
300 | 321 | | |
301 | 322 | | |
| |||
508 | 529 | | |
509 | 530 | | |
510 | 531 | | |
511 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
512 | 535 | | |
513 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
514 | 541 | | |
| 542 | + | |
515 | 543 | | |
516 | 544 | | |
517 | 545 | | |
518 | 546 | | |
519 | 547 | | |
520 | 548 | | |
521 | | - | |
| 549 | + | |
522 | 550 | | |
523 | 551 | | |
524 | 552 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
214 | 229 | | |
215 | | - | |
| 230 | + | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
| |||
0 commit comments