Skip to content

Commit

Permalink
web,graphql: Remove row limit
Browse files Browse the repository at this point in the history
  • Loading branch information
tbantle22 committed Nov 13, 2023
1 parent bd4a551 commit 7ea53c5
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 45 deletions.
1 change: 0 additions & 1 deletion graphql-server/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ enum QueryExecutionStatus {
Success
Error
Timeout
RowLimit
}

type Status {
Expand Down
1 change: 0 additions & 1 deletion graphql-server/src/sqlSelects/sqlSelect.enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export enum QueryExecutionStatus {
Success,
Error,
Timeout,
RowLimit,
}

registerEnumType(QueryExecutionStatus, { name: "QueryExecutionStatus" });
16 changes: 3 additions & 13 deletions graphql-server/src/sqlSelects/sqlSelect.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,13 @@ export function fromSqlSelectRow(
};
}

// Get first 201 rows to determine if limit has been reached
const sliced = doltRows.slice(0, 201);
const rows: row.Row[] = sliced.map(row.fromDoltRowRes);
if (!rows.length) {
if (!doltRows.length) {
return res;
}
const columns: column.Column[] = Object.keys(sliced[0]).map(c => {
const rows: row.Row[] = doltRows.map(row.fromDoltRowRes);
const columns: column.Column[] = Object.keys(doltRows[0]).map(c => {
return { name: c, isPrimaryKey: false, type: "unknown" };
});

if (rows.length > 200) {
return {
...res,
columns,
rows: rows.slice(0, 200),
queryExecutionStatus: QueryExecutionStatus.RowLimit,
};
}
return { ...res, columns, rows };
}
8 changes: 0 additions & 8 deletions web/components/SqlDataTable/SqlMessage/SuccessMsg.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import DoltLink from "@components/links/DoltLink";
import Link from "@components/links/Link";
import useIsDolt from "@hooks/useIsDolt";
import { SqlQueryParams } from "@lib/params";
Expand Down Expand Up @@ -41,7 +40,6 @@ export default function SuccessMsg(props: Props) {
type ExecutionProps = {
rowsLen: number;
params: SqlQueryParams;
hitRowLimit?: boolean;
};

export function ExecutionMessage(props: ExecutionProps) {
Expand All @@ -55,12 +53,6 @@ export function ExecutionMessage(props: ExecutionProps) {
on <span className={css.bold}>{props.params.refName}</span>
</span>
)}
{props.hitRowLimit && (
<span>
{" "}
(for unlimited query results download <DoltLink />)
</span>
)}
</p>
);
}
Expand Down
18 changes: 0 additions & 18 deletions web/components/SqlDataTable/SqlMessage/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,4 @@ describe("test SqlMessage", () => {
expect(await screen.findByText("master")).toBeVisible();
expect(screen.getByText("1 row selected")).toBeVisible();
});

it("renders row limit message", async () => {
render(
<MockedProvider mocks={[databaseDetailsMock(true, false)]}>
<SqlMessage
params={params}
rowsLen={200}
executionStatus={QueryExecutionStatus.RowLimit}
/>
</MockedProvider>,
);

expect(await screen.findByText("master")).toBeVisible();
expect(screen.getByText(/200 rows selected/)).toBeVisible();
expect(
screen.getByText(/\(for unlimited query results download /),
).toBeVisible();
});
});
4 changes: 1 addition & 3 deletions web/components/SqlDataTable/SqlMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { QueryExecutionStatus } from "@gen/graphql-types";
import { isTimeoutError } from "@lib/errors/helpers";
import { SqlQueryParams } from "@lib/params";
import { isMultipleQueries } from "@lib/parseSqlQuery";
import SuccessMsg, { ExecutionMessage } from "./SuccessMsg";
import SuccessMsg from "./SuccessMsg";
import TimeoutMessage from "./TimeoutMsg";
import css from "./index.module.css";
import { improveGqlError } from "./utils";
Expand Down Expand Up @@ -43,8 +43,6 @@ export default function SqlMessage(props: Props) {
return <SuccessMsg {...props} />;
case QueryExecutionStatus.Timeout:
return <TimeoutMessage {...props} />;
case QueryExecutionStatus.RowLimit:
return <ExecutionMessage {...props} hitRowLimit />;
case QueryExecutionStatus.Error:
default:
if (props.executionMessage && isTimeoutError(props.executionMessage)) {
Expand Down
1 change: 0 additions & 1 deletion web/gen/graphql-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ export type QueryViewsArgs = {

export enum QueryExecutionStatus {
Error = 'Error',
RowLimit = 'RowLimit',
Success = 'Success',
Timeout = 'Timeout'
}
Expand Down

0 comments on commit 7ea53c5

Please sign in to comment.