Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,17 @@ extend type Query {
columnNames: [String!],
functions: [String!],
showDuplicatesOnly: Boolean
): String! @deprecated (reason: "use sqlGropingResultSet (25.3.1)")
): String! @deprecated (reason: "use asyncSqlGroupingResultSet (25.3.1)")

"Creates async task to get grouped SQL results"
sqlGropingResultSet(
asyncSqlGroupingResultSet(
projectId: ID,
contextId: ID!,
connectionId: ID!,
resultsId: ID!,
"Original results ID to group"
originalResultsId: ID!,
"Current results ID is needed to apply filters/sorting on top of grouping"
currentResultsId: ID,
columnNames: [String!],
functions: [String!],
showDuplicatesOnly: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ String generateGroupByQuery(@NotNull WebSQLContextInfo contextInfo,

@WebAction
WebAsyncTaskInfo getGroupingSqlResultSet(
@NotNull WebSession webSession,
@NotNull WebSQLContextInfo contextInfo,
@NotNull String resultsId,
@NotNull String originalResultsId,
@Nullable String currentResultsId,
@NotNull List<String> columnsList,
@Nullable List<String> functions,
@Nullable Boolean showDuplicatesOnly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ public void bindWiring(DBWBindingContext model) throws DBWebException {
getArgument(env, "showDuplicatesOnly"))
)
.dataFetcher(
"sqlGropingResultSet", env ->
"asyncSqlGroupingResultSet", env ->
getService(env).getGroupingSqlResultSet(
getWebSession(env),
getSQLContext(env),
getArgumentVal(env, "resultsId"),
getArgumentVal(env, "originalResultsId"),
getArgument(env, "currentResultsId"),
getArgumentVal(env, "columnNames"),
getArgument(env, "functions"),
getArgument(env, "showDuplicatesOnly"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,22 +649,22 @@ public String generateGroupByQuery(

@Override
public WebAsyncTaskInfo getGroupingSqlResultSet(
@NotNull WebSession webSession,
@NotNull WebSQLContextInfo contextInfo,
@NotNull String resultsId,
@NotNull String originalResultsId,
@Nullable String currentResultsId,
@NotNull List<String> columnsList,
@Nullable List<String> functions,
@Nullable Boolean showDuplicatesOnly,
@Nullable WebSQLDataFilter filter,
@Nullable WebDataFormat dataFormat,
boolean isInteractive
) throws DBException {
String generateGroupByQuery = generateGroupByQuery(contextInfo, resultsId, columnsList, functions, showDuplicatesOnly);
return asyncExecuteQuery(
contextInfo.getProcessor().getWebSession(),
contextInfo.getProjectId(),
return WebSQLUtils.createAsyncTaskExecuteSqlQuery(
webSession,
contextInfo,
generateGroupByQuery,
resultsId,
generateGroupByQuery(contextInfo, originalResultsId, columnsList, functions, showDuplicatesOnly),
currentResultsId,
filter,
dataFormat,
false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
query asyncSqlGroupingResultSet(
$projectId: ID
$contextId: ID!
$connectionId: ID!
$originalResultsId: ID!
$currentResultsId: ID
$columnNames: [String!]
$functions: [String!]
$showDuplicatesOnly: Boolean
$filter: SQLDataFilter
$dataFormat: ResultDataFormat
$isInteractive: Boolean
) {
taskInfo: asyncSqlGroupingResultSet(
projectId: $projectId
contextId: $contextId
connectionId: $connectionId
originalResultsId: $originalResultsId
currentResultsId: $currentResultsId
columnNames: $columnNames
functions: $functions
showDuplicatesOnly: $showDuplicatesOnly
filter: $filter
dataFormat: $dataFormat
isInteractive: $isInteractive
) {
...AsyncTaskInfo
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import type { IDatabaseResultSet } from '@cloudbeaver/plugin-data-viewer';
import type { IConnectionExecutionContextInfo } from '@cloudbeaver/core-connections';
import type { AsyncTaskInfo } from '@cloudbeaver/core-sdk';
import { type IDataQueryOptions, QueryDataSource } from '@cloudbeaver/plugin-sql-editor';

export interface IDataGroupingOptions extends IDataQueryOptions {
Expand All @@ -17,34 +18,30 @@ export interface IDataGroupingOptions extends IDataQueryOptions {
}

export class GroupingDataSource extends QueryDataSource<IDataGroupingOptions> {
override async request(prevResults: IDatabaseResultSet[]): Promise<IDatabaseResultSet[]> {
await this.generateQuery();
return await super.request(prevResults);
}

private async generateQuery(): Promise<void> {
const options = this.options;
const executionContextInfo = this.executionContext?.context;

if (!options || !executionContextInfo) {
return;
}

try {
const { query } = await this.graphQLService.sdk.getResultsetGroupingQuery({
projectId: executionContextInfo.projectId,
connectionId: executionContextInfo.connectionId,
contextId: executionContextInfo.id,
resultsId: options.sourceResultId,
columnNames: options.columns,
functions: options.functions,
showDuplicatesOnly: options.showDuplicatesOnly || false,
});
protected override async executeQuery(
executionContextInfo: IConnectionExecutionContextInfo,
options: IDataGroupingOptions,
currentResultsId: string | undefined,
limit: number,
): Promise<AsyncTaskInfo> {
const { taskInfo } = await this.graphQLService.sdk.asyncSqlGroupingResultSet({
projectId: executionContextInfo.projectId,
connectionId: executionContextInfo.connectionId,
contextId: executionContextInfo.id,
originalResultsId: options.sourceResultId,
currentResultsId: currentResultsId,
columnNames: options.columns,
functions: options.functions,
showDuplicatesOnly: options.showDuplicatesOnly,
filter: {
offset: this.offset,
limit,
constraints: options.constraints,
where: options.whereFilter || undefined,
},
dataFormat: this.dataFormat,
});

this.setOptions({ ...options, query });
} catch (exception: any) {
this.error = exception;
throw exception;
}
return taskInfo;
}
}
Loading