Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#210 - Add row count and "is_truncated" flag in query results #219

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ export function ResultPaginator({queryId, resultIndex, className}: Props) {
[dispatch],
);

const goToPage = useCallback((page: number) => {
dispatch(updateQueryResult(queryId, resultIndex, page));
}, []);
const goToPage = useCallback(
(page: number) => {
dispatch(updateQueryResult(queryId, resultIndex, page));
},
[queryId],
);

return (
<div className={b(null, className)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
position: relative;
overflow: auto;

&__result-info {
margin-bottom: 10px;
}

&__loading {
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Loader} from '@gravity-ui/uikit';
import {Loader, Text} from '@gravity-ui/uikit';
import React from 'react';
import {useSelector} from 'react-redux';
import block from 'bem-cn-lite';
Expand All @@ -20,14 +20,30 @@ import './index.scss';

const b = block('query-result-table');

const getResultRowsInfo = (result: QueryResultReadyState) => {
const {row_count: total} = result.meta.data_statistics;
const {is_truncated: truncated} = result.meta;
const {pageSize} = result.settings;
const start = pageSize * result.page + 1;
const end = Math.min(pageSize * result.page + pageSize, total);
return {start, end, total, truncated};
};

function QueryReadyResultView({result}: {result: QueryResultReadyState}) {
const mode = result?.settings?.viewMode;
const {start, end, total, truncated} = getResultRowsInfo(result);
return (
<>
<NotRenderUntilFirstVisible hide={mode !== QueryResultsViewMode.Scheme}>
<YQLSchemeTable result={result} />
</NotRenderUntilFirstVisible>
<NotRenderUntilFirstVisible hide={mode !== QueryResultsViewMode.Table}>
<div className={b('result-info')}>
<Text>
Rows {start}-{end} of {total}
{`${truncated ? ' (truncated)' : ''}`}
</Text>
</div>
<ResultsTable result={result} />
</NotRenderUntilFirstVisible>
</>
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/ui/pages/query-tracker/module/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ export type QueryResultMeta = {
};
$value: QueryResultMetaScheme[];
};
is_truncated: boolean;
data_statistics: {
chunk_count: number;
row_count: number;
Expand Down
Loading