Function: useAnalyticsQuery()
useAnalyticsQuery<
T,K,F>(queryKey,parameters?,options?):UseAnalyticsQueryResult<InferResultByFormat<T,K,F>>
Subscribe to an analytics query and return its latest result. JSON_ARRAY results stream over SSE (with warehouse-readiness progress); ARROW_STREAM results are fetched as raw Arrow bytes directly from the query endpoint. Integration hook between client and analytics plugin.
The return type is automatically inferred based on the format:
format: "JSON_ARRAY"(default): Returns typed array from QueryRegistryformat: "ARROW_STREAM": Returns TypedArrowTable with row type preserved
Note: User context execution is determined by query file naming:
queryKey.obo.sql: Executes as user (OBO = on-behalf-of / user delegation)queryKey.sql: Executes as service principal
Type Parameters
Section titled “Type Parameters”T = unknown
K extends string = string
F extends AnalyticsFormat = "JSON_ARRAY"
Parameters
Section titled “Parameters”queryKey
Section titled “queryKey”K
Analytics query identifier
parameters?
Section titled “parameters?”InferParams<K> | null
Query parameters (type-safe based on QueryRegistry)
options?
Section titled “options?”Analytics query settings including format
Returns
Section titled “Returns”UseAnalyticsQueryResult<InferResultByFormat<T, K, F>>
Query result state with format-appropriate data type
Examples
Section titled “Examples”JSON_ARRAY format (default)
const { data } = useAnalyticsQuery("spend_data", params);// data: Array<{ group_key: string; cost_usd: number; ... }> | nullARROW_STREAM format
const { data } = useAnalyticsQuery("spend_data", params, { format: "ARROW_STREAM" });// data: TypedArrowTable<{ group_key: string; cost_usd: number; ... }> | null