fix(grid): reuse local result rows for csv/xlsx export instead of re-running query

* fix(grid): reuse local result rows for csv/xlsx export instead of re-running query

Exporting the full result set ("导出当前结果集全部数据 CSV") previously
re-executed the source SQL on the database via the backend streaming path
(exportQueryResultViaBackend -> start_query_result_export), and the frontend
fallback (fullExportResult/fetchTabResultForExport) did the same. For a slow
query this means running it a second time just to export rows already on
screen, which can hang or crash (e.g. a 2-minute paimon query returning 30
rows).

When the in-memory result already holds the complete set (no server-side
pagination, not truncated, no further pages), skip both re-executing paths and
write the displayed rows directly. Large/truncated/paginated results keep the
original streaming behavior unchanged.

* fix(grid): export raw in-memory result for complete local result set

---------

Co-authored-by: t8y2 <1156263951@qq.com>
This commit is contained in:
jischengandt8y2 authored and GitHub committed 2026-07-06 20:06:57 +08:00
1 parent 15114f58dd
commit 5db0fc4fb1
2 files changed
+39 -3

No files matched your search

@@ -3278,6 +3278,10 @@ const hasKnownTotalRowCount = computed(() => typeof serverKnownTotalRowCount.val
// rowCount IS the total. Without this hint, the "page is full → assume more"
// fallback in canGoNextDataGridPage lets the user keep clicking next forever.
const allRowsLoaded = computed(() => isResultsContext.value && props.pageLimit === undefined);
// True when the in-memory result already holds the complete result set (results
// context, no server-side pagination, not truncated, no further pages). Used to
// skip re-executing the query on export and instead write the local rows.
const hasCompleteLocalResult = computed(() => !!props.result && allRowsLoaded.value && props.result.truncated !== true && props.result.has_more !== true);
const canGoNextPage = computed(() => {
return canGoNextDataGridPage({
hasMore: props.result.has_more,
@@ -5827,6 +5831,8 @@ const {
hasRowSelection,
fullExportResult: props.fullExportResult,
queryResultExportRequest: props.queryResultExportRequest,
hasCompleteLocalResult,
completeLocalResult: computed(() => (hasCompleteLocalResult.value ? props.result : undefined)),
allExportResults: computed(() => props.allExportResults),
currentResultLabel: computed(() => props.result.sourceLabel),
exportFileBaseName: computed(() => props.exportFileBaseName),