Skip to content

Conversation

@ditadi
Copy link
Contributor

@ditadi ditadi commented Jan 22, 2026

Summary

  • Replace asUser API option with .obo.sql file naming convention for user-scoped query execution
  • Simplify analytics endpoints from two routes to one unified route
  • Remove asUser prop from all UI components (hooks, charts, tables)

Details

Convention-based execution context

Query execution context is now determined by file naming:

  • config/queries/<query_key>.sql → Executes as service principal (shared cache)
  • config/queries/<query_key>.obo.sql → Executes as user (OBO = On-Behalf-Of, per-user cache)

This is more declarative than passing asUser: true through the UI layer, as the query file itself declares its execution semantics.

API changes

Removed:

  • POST /api/analytics/users/me/query/:query_key
  • GET /api/analytics/users/me/arrow-result/:jobId
  • asUser option from useAnalyticsQuery, useChartData, TableWrapper, and chart components

Unchanged:

  • POST /api/analytics/query/:query_key (now handles both contexts)
  • GET /api/analytics/arrow-result/:jobId
  • Plugin.asUser(req) method (still available for custom plugins)

Cache behavior

  • .sql queries use global cache key (shared across all users)
  • .obo.sql queries use per-user cache key (isolated per user)

Test plan

  • Verify .sql queries execute as service principal
  • Verify .obo.sql queries execute as user
  • Verify cache isolation between .sql and .obo.sql queries
  • Verify global cache sharing for .sql queries across users
  • Verify per-user cache isolation for .obo.sql queries
  • Run pnpm typecheck - no type errors
  • Run pnpm test - all tests pass

@ditadi ditadi requested a review from MarioCadenas January 22, 2026 10:53
@pkosiec
Copy link
Member

pkosiec commented Jan 22, 2026

Could you please add a sentence about the .obo extension in the docs? docs/docs/plugins.md#analytics-plugin

@ditadi ditadi merged commit 00a74c1 into main Jan 22, 2026
4 checks passed
@ditadi ditadi deleted the feat/add-sql-conventions branch January 22, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants