feat(streaming): Streaming CSV uploads for over 100k records for constant memory usage - #35478
Conversation
Pulled from commit a4c85fa293333ce66f16f7da7d6dec7185c76496 Frontend Components: - StreamingExportModal: Modal with real-time progress tracking - Shows rows processed, file size, speed (rows/s, MB/s) - Progress bar with percentage completion - Cancel/retry functionality - Auto-download on completion - useStreamingExport hook: Manages streaming export lifecycle - Fetch API ReadableStream for chunked download - Real-time row counting from chunk data - Performance metrics (speed, throughput) - AbortController for cancellation - Blob creation for final download Integration: - Chart.jsx: Added streaming modal and export handling - exploreUtils: Modified exportChart() for streaming detection - Passes onStartStreamingExport callback for CSV - Extracts expectedRows for accurate progress - Fallback to legacy export for non-CSV User Experience: - Seamless CSV export with visual progress - Real-time feedback on large exports - No page navigation during export - Graceful error handling with retry option
- Added configurable testing mode for UI demonstration - Testing mode: 10k row chunks with 3.5s delay between chunks - Production mode: 1k row chunks with no delay - Controlled by ENABLE_SLOW_STREAMING_TEST flag - Helps visualize progress modal during development
|
Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #35478 +/- ##
===========================================
+ Coverage 0 68.09% +68.09%
===========================================
Files 0 632 +632
Lines 0 46445 +46445
Branches 0 5031 +5031
===========================================
+ Hits 0 31626 +31626
- Misses 0 13558 +13558
- Partials 0 1261 +1261
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
🎪 Showtime deployed environment on GHA for b5393a4 • Environment: http://34.220.88.207:8080 (admin/admin) |
|
🎪 Showtime deployed environment on GHA for ed5c1e3 • Environment: http://35.92.165.125:8080 (admin/admin) |
betodealmeida
left a comment
There was a problem hiding this comment.
This is looking great! left a few comments.
msyavuz
left a comment
There was a problem hiding this comment.
LGTM as well. Do you want to take another look @betodealmeida?
CSV_STREAMING_ROW_THRESHOLD=100000
🔧 Summary
This PR introduces streaming CSV export functionality for SQL Lab, enabling efficient exports of large query result sets with real-time progress tracking. Users can now export millions of rows without timeouts or memory errors, while seeing live progress updates during the download.
Screen.Recording.2025-10-03.at.2.06.36.PM.mov
🐛 The Issue
When exporting large SQL Lab query results or Charts to CSV, users face several critical problems:
For example, a data analyst trying to export a 500,000-row financial report would experience a frozen browser, no progress bar, and likely a timeout error after waiting several minutes.
🧠 Root Cause
The current CSV export loads all rows into memory at once before generating the file. This means:
The existing architecture simply cannot scale beyond a few thousand rows reliably.
✅ The Fix
This PR implements a complete streaming CSV export system that:
Backend Improvements
/api/v1/sqllab/export_streaming/) that sends data in chunks rather than all at onceFrontend Enhancements
CSV_STREAMING_ROW_THRESHOLDconfig (default: 1,000 rows)Configuration
Administrators can control when streaming activates by setting
CSV_STREAMING_ROW_THRESHOLDinsuperset_config.py. This same threshold is used for both Chart and SQL Lab exports, providing consistent behavior across the platform.🧪 How It Works
CSV_STREAMING_ROW_THRESHOLD(default 100k rows)The key difference is that data flows continuously from database → backend → browser in manageable chunks, rather than accumulating in memory all at once.
🖼️ UX Enhancements
After (with streaming):
Users now have full visibility and control over large exports, with the confidence that multi-million row downloads will complete successfully.
🎯 Impact
Memory Usage
User Experience