Skip to content

feat: decode inline Arrow IPC + warehouse-compat fallback#329

Open
jamesbroadhead wants to merge 1 commit intostack/arrow-2-format-renamefrom
stack/arrow-3-inline-arrow-fix
Open

feat: decode inline Arrow IPC + warehouse-compat fallback#329
jamesbroadhead wants to merge 1 commit intostack/arrow-2-format-renamefrom
stack/arrow-3-inline-arrow-fix

Conversation

@jamesbroadhead
Copy link
Copy Markdown
Contributor

Summary

Serverless warehouses return ARROW_STREAM + INLINE results as base64 Arrow IPC in result.attachment rather than result.data_array. The previous code path discarded inline data for any ARROW_STREAM response (designed for EXTERNAL_LINKS), so these warehouses silently returned empty results.

This PR makes the analytics plugin work across classic and serverless warehouses by handling both dispositions for ARROW_STREAM, decoding inline Arrow IPC attachments server-side, and falling back to JSON_ARRAY when a warehouse rejects ARROW_STREAM + INLINE.

Stack

Based on #328. Merge order: #327#328 → this PR.

Changes

  • Inline Arrow IPC decoding (connectors/sql-warehouse/arrow-schema.ts + client.ts): detects result.attachment and decodes via apache-arrow's tableFromIPC, producing the same row-object shape as JSON_ARRAY regardless of warehouse backend. apache-arrow@21.1.0 added as a server dependency.
  • Format fallback: ARROW_STREAM + INLINE requests automatically fall back to JSON_ARRAY if a classic warehouse rejects them. Explicit format requests are respected without fallback.
  • Zod-validated SSE wire protocol (shared/sse/analytics.ts): single source of truth between server (AnalyticsPlugin._handleQueryRoute) and client (useAnalyticsQuery). Malformed payloads surface a clear error instead of silent undefined allocation.
  • Default remains JSON_ARRAY for compatibility.

Tests

Per-area additions:

  • connectors/sql-warehouse/tests/arrow-schema.test.ts (new, 514 lines)
  • connectors/sql-warehouse/tests/client.test.ts (new, 382 lines) — uses real base64 Arrow IPC captured from a live serverless warehouse
  • appkit-ui/src/react/hooks/__tests__/use-analytics-query.test.ts (new, 143 lines)
  • shared/src/sse/analytics.test.ts (new, 87 lines)
  • plugins/analytics/tests/analytics.test.ts (+449)

Test plan

  • Deploy an app against a serverless warehouse that returns ARROW_STREAM + INLINE attachments — verify useAnalyticsQuery returns rows
  • Deploy against a classic warehouse — verify JSON_ARRAY default works and ARROW_STREAM + EXTERNAL_LINKS still works
  • Verify automatic fallback when a warehouse rejects ARROW_STREAM + INLINE

Fixes #242. Replaces #256.

This pull request was AI-assisted by Isaac.

Serverless warehouses return ARROW_STREAM + INLINE results as base64 Arrow
IPC in result.attachment rather than result.data_array. The previous code
path discarded inline data for any ARROW_STREAM response (designed for
EXTERNAL_LINKS), so these warehouses silently returned empty results.

This commit makes the analytics plugin work across classic and serverless
warehouses by handling both dispositions for ARROW_STREAM, decoding inline
Arrow IPC attachments server-side, and falling back to JSON_ARRAY when a
warehouse rejects ARROW_STREAM + INLINE.

Changes
- Inline Arrow IPC decoding (new arrow-schema.ts) via apache-arrow's
  tableFromIPC, producing the same row-object shape as JSON_ARRAY
  regardless of warehouse backend. apache-arrow@21.1.0 added as a server
  dep.
- Format fallback: ARROW_STREAM + INLINE requests automatically fall back
  to JSON_ARRAY if a classic warehouse rejects them. Explicit format
  requests are respected without fallback.
- Zod-validated SSE wire protocol for /api/analytics/query (shared schema
  between server and client; malformed payloads surface a clear error
  instead of silent undefined).
- Default remains JSON_ARRAY for compatibility.

Stack: layer 3 of 3 carved from #256.
- #327 — coverage backfill (layer 1)
- #328 — AnalyticsFormat rename to API enum names (layer 2)
- (this PR) — the actual fix

Fixes #242

Co-authored-by: Isaac
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.

1 participant