Skip to content

fix(cubejs): stream csv/arrow exports from the source db, not Cube Store - #98

Merged
akshaykumar2505 merged 2 commits into
mainfrom
fix/cubestore-external-preagg-buffered
Oct 15, 2026
Merged

akshaykumar2505 merged 2 commits into
mainfrom
fix/cubestore-external-preagg-buffered

Conversation

@doktorhelgi

@doktorhelgi doktorhelgi commented Oct 15, 2026 •

Copy link
Copy Markdown

fix(cubejs): stream csv/arrow exports from the source db, not Cube Store

Problem

cxs2's dashboard proxy (/api/data-viz-demo/cube → dbx.fraios.dev/api/v1/load, arrow format) got HTTP 500 Error: Streaming queries to Cube Store aren't supported (4× on 2026-10-14, cube road_segments_driven). The export handler compiles the query normally, so a matching Cube Store rollup makes it external, and Cube's queue refuses to stream external queries.

Fix

buildLoadExportPlan compiles the export with disableExternalPreAggregations: true, the same thing Cube's own SQL API does before streaming (gateway.js sqlApiLoad). The query then runs against the source database (ClickHouse), and pre-aggregations stored there still apply.

The first version of this PR sent these queries to the buffered /load path instead. A review found that path cuts Arrow at 100k rows without saying so, skips the Dataset Exported audit and holds the whole result in memory, so it was replaced.

Trade-off: an export that a Cube Store rollup could have served now scans the source tables. That is slower, but the result is complete, streamed and audited.

Tests

  • New: compiles without Cube Store pre-aggregations so the export can stream. It checks the compile flag and that the export streams. It fails on main and passes with the fix.
  • node --experimental-test-module-mocks --test test/loadExport.test.js test/loadExportCapabilities.test.js → 13 pass, 0 fail.
  • Not run against the live stack.

🤖 Generated with Claude Code

doktorhelgi and others added 2 commits October 15, 2026 08:47
Cube's query queue refuses to stream a query whose compiled plan targets
Cube Store ("Streaming queries to Cube Store aren't supported"), so
arrow/csv /load requests that hit an external rollup failed with a 500.
The plan already flags pre-aggregations to skip the native ClickHouse
path, but still sent them to semantic streaming. When the compiled query
is external, fall through to the buffered /load pipeline instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the buffered fallback: that path cut Arrow at 100k rows,
skipped the Dataset Exported audit and held the whole result in memory.
Compile the export with disableExternalPreAggregations, as Cube's own
SQL API does for streaming, so the query never targets Cube Store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@doktorhelgi doktorhelgi changed the title fix(cubejs): buffered /load for csv/arrow queries that run on Cube Store fix(cubejs): stream csv/arrow exports from the source db, not Cube Store Oct 15, 2026
@akshaykumar2505
akshaykumar2505 merged commit 28df006 into main Oct 15, 2026
3 checks passed
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.

2 participants