Skip to content

Commit 6a7c469

Browse files
committed
fix: flat array
1 parent 4a69540 commit 6a7c469

File tree

3 files changed

+20
-40
lines changed

3 files changed

+20
-40
lines changed

src/containers/Tenant/Query/QueryResult/components/ResultSetsViewer/ResultSetsViewer.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {Tabs, Text} from '@gravity-ui/uikit';
2-
import {flatten} from 'lodash';
32

43
import {QueryResultTable} from '../../../../../../components/QueryResultTable';
54
import type {ParsedResultSet} from '../../../../../../types/store/query';
@@ -54,12 +53,12 @@ export function ResultSetsViewer(props: ResultSetsViewerProps) {
5453
<Text variant="subheader-3">
5554
{currentResult?.truncated ? i18n('title.truncated') : i18n('title.result')}
5655
</Text>
57-
{currentResult?.resultChunks ? (
56+
{currentResult?.result ? (
5857
<Text
5958
color="secondary"
6059
variant="body-2"
6160
className={b('row-count')}
62-
>{`(${currentResult?.totalCount})`}</Text>
61+
>{`(${currentResult?.result.length})`}</Text>
6362
) : null}
6463
{props.rowsPerSecond ? (
6564
<Text
@@ -79,10 +78,7 @@ export function ResultSetsViewer(props: ResultSetsViewerProps) {
7978
{currentResult ? (
8079
<div className={b('result')}>
8180
{renderResultHeadWithCount()}
82-
<QueryResultTable
83-
data={flatten(currentResult.resultChunks || [])}
84-
columns={currentResult.columns}
85-
/>
81+
<QueryResultTable data={currentResult.result} columns={currentResult.columns} />
8682
</div>
8783
) : null}
8884
</div>

src/store/reducers/query/query.ts

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -215,47 +215,35 @@ const slice = createSlice({
215215
const {columns, rows} = chunk.result;
216216

217217
if (!state.result.data.resultSets[resultIndex]) {
218-
state.result.data.resultSets[resultIndex] = {};
218+
state.result.data.resultSets[resultIndex] = {
219+
columns: [],
220+
result: [],
221+
};
219222
}
220223

221224
if (columns && !state.result.data.resultSets[resultIndex].columns?.length) {
222-
const columnsWithIndex = [INDEX_COLUMN, ...columns];
223-
if (!state.result.data.resultSets) {
224-
state.result.data.resultSets = [];
225-
}
226-
227-
if (state.result.data.resultSets[resultIndex]) {
228-
state.result.data.resultSets[resultIndex].columns = columnsWithIndex;
229-
} else {
230-
state.result.data.resultSets[resultIndex] = {
231-
columns: columnsWithIndex,
232-
result: [],
233-
};
225+
state.result.data.resultSets[resultIndex].columns?.push(INDEX_COLUMN);
226+
for (const column of columns) {
227+
state.result.data.resultSets[resultIndex].columns?.push(column);
234228
}
235229
}
236230

237-
const indexedRows = (rows || []).map((row, index) => [
238-
(state.result?.data?.resultSets?.[resultIndex].totalCount || 1) + index,
239-
...row,
240-
]);
231+
const indexedRows = rows || [];
232+
const startIndex =
233+
state.result?.data?.resultSets?.[resultIndex].result?.length || 1;
234+
235+
indexedRows.forEach((row, index) => {
236+
row.unshift(startIndex + index);
237+
});
241238

242239
const formattedRows = parseResult(
243240
indexedRows,
244241
state.result.data.resultSets[resultIndex].columns || [],
245242
);
246243

247-
// Update result set by pushing formatted rows directly
248-
if (!state.result.data.resultSets?.[resultIndex].resultChunks) {
249-
// eslint-disable-next-line new-cap
250-
state.result.data.resultSets[resultIndex].resultChunks = [];
244+
for (const row of formattedRows) {
245+
state.result.data.resultSets[resultIndex].result?.push(row);
251246
}
252-
253-
state.result.data.resultSets[resultIndex].resultChunks.push(formattedRows);
254-
state.result.data.resultSets[resultIndex].totalCount = state.result.data.resultSets[
255-
resultIndex
256-
].totalCount
257-
? formattedRows.length + state.result.data.resultSets[resultIndex].totalCount
258-
: formattedRows.length;
259247
}
260248
},
261249
setStreamQueryResponse: (state, action: PayloadAction<QueryResponseChunk>) => {
@@ -382,9 +370,7 @@ export const queryApi = api.injectEndpoints({
382370
querySettings.tracingLevel && enableTracingLevel
383371
? TracingLevelNumber[querySettings.tracingLevel]
384372
: undefined,
385-
limit_rows: isNumeric(querySettings.limitRows)
386-
? Number(querySettings.limitRows)
387-
: undefined,
373+
limit_rows: 100000000,
388374
transaction_mode:
389375
querySettings.transactionMode === 'implicit'
390376
? undefined

src/types/store/query.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import type {ValueOf} from '../common';
2323
export interface ParsedResultSet {
2424
columns?: ColumnType[];
2525
result?: KeyValueRow[];
26-
resultChunks?: KeyValueRow[][];
27-
totalCount?: number;
2826
truncated?: boolean;
2927
}
3028

0 commit comments

Comments
 (0)