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

CB-5114 add gql api for bigquery trace info #2732

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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 @@ -22,6 +22,7 @@
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
import org.jkiss.dbeaver.model.data.DBDRowIdentifier;
import org.jkiss.dbeaver.model.exec.trace.DBCTrace;
import org.jkiss.dbeaver.model.struct.*;

import java.util.HashSet;
Expand All @@ -38,6 +39,7 @@ public class WebSQLResultsInfo {
@NotNull
private final String id;
private DBDAttributeBinding[] attributes;
private DBCTrace trace;
private String queryText;

public WebSQLResultsInfo(@NotNull DBSDataContainer dataContainer, @NotNull String id) {
Expand Down Expand Up @@ -132,4 +134,11 @@ public boolean canRefreshResults() {
(!(entity instanceof DBSDocumentContainer) && !entity.getDataSource().getInfo().isDynamicMetadata());
}

public DBCTrace getTrace() {
return trace;
}

public void setTrace(@NotNull DBCTrace trace) {
this.trace = trace;
}
}
19 changes: 19 additions & 0 deletions server/bundles/io.cloudbeaver.server/schema/service.sql.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type SQLResultSet {
# can't update data or load LOB file if hasRowIdentifier = false
hasRowIdentifier: Boolean!
hasChildrenCollection: Boolean!
hasDynamicTrace: Boolean! @since(version: "24.1.2")
isSupportsDataFilter: Boolean!
}

Expand Down Expand Up @@ -211,6 +212,16 @@ type SQLScriptQuery {
start: Int!
end: Int!
}

####################################################
# Dynamic trace info
####################################################
type DynamicTraceProperty {
name: String!
value: String
description: String
}

####################################################
# Query and Mutation
####################################################
Expand Down Expand Up @@ -402,6 +413,14 @@ extend type Mutation {

asyncSqlRowDataCountResult(taskId: ID!): Int!

@since(version: "24.1.2")
sqlGetDynamicTrace(
projectId: ID,
connectionId: ID!,
contextId: ID!,
resultsId: ID!
): [DynamicTraceProperty!]!

@since(version: "24.0.1")
asyncSqlSetAutoCommit(
projectId: ID!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.exec.DBCLogicalOperator;
import org.jkiss.dbeaver.model.exec.trace.DBCTraceProperty;
import org.jkiss.dbeaver.model.sql.registry.SQLGeneratorDescriptor;

import java.util.List;
Expand Down Expand Up @@ -106,6 +107,17 @@ WebAsyncTaskInfo asyncReadDataFromContainer(
@Nullable WebSQLDataFilter filter,
@Nullable WebDataFormat dataFormat) throws DBWebException;

/**
* Reads dynamic trace from provided database results.
*/
@NotNull
@WebAction
List<DBCTraceProperty> readDynamicTrace(
@NotNull WebSession webSession,
@NotNull WebSQLContextInfo contextInfo,
@NotNull String resultsId
) throws DBException;

@WebAction
Boolean closeResult(@NotNull WebSQLContextInfo sqlContext, @NotNull String resultId) throws DBWebException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.exec.trace.DBCTrace;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.qm.QMTransactionState;
import org.jkiss.dbeaver.model.qm.QMUtils;
Expand Down Expand Up @@ -142,13 +143,21 @@ public void setDefaults(String catalogName, String schemaName) throws DBWebExcep
}
}

/**
* Saves results info into cache.
* Helps to find it with results id sent by front-end.
*/
@NotNull
public WebSQLResultsInfo saveResult(@NotNull DBSDataContainer dataContainer, @NotNull DBDAttributeBinding[] attributes) {
public WebSQLResultsInfo saveResult(
@NotNull DBSDataContainer dataContainer,
@NotNull DBCTrace trace,
@NotNull DBDAttributeBinding[] attributes) {
WebSQLResultsInfo resultInfo = new WebSQLResultsInfo(
dataContainer,
String.valueOf(resultId.incrementAndGet())
);
resultInfo.setAttributes(attributes);
resultInfo.setTrace(trace);
yagudin10 marked this conversation as resolved.
Show resolved Hide resolved
resultInfoMap.put(resultInfo.getId(), resultInfo);
return resultInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.data.*;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.exec.trace.DBCTrace;
import org.jkiss.dbeaver.model.exec.trace.DBCTraceDynamic;
import org.jkiss.dbeaver.model.impl.data.DBDValueError;
import org.jkiss.dbeaver.model.meta.MetaData;
import org.jkiss.dbeaver.model.sql.DBQuotaException;
Expand All @@ -48,6 +50,7 @@ class WebSQLQueryDataReceiver implements DBDDataReceiver {
private final WebSQLQueryResultSet webResultSet = new WebSQLQueryResultSet();

private DBDAttributeBinding[] bindings;
private DBCTrace trace;
private List<WebSQLQueryResultSetRow> rows = new ArrayList<>();
private final Number rowLimit;

Expand All @@ -71,6 +74,9 @@ public void fetchStart(@NotNull DBCSession session, @NotNull DBCResultSet dbResu
DBCAttributeMetaData attrMeta = attributes.get(i);
bindings[i] = new DBDAttributeBindingMeta(dataContainer, dbResult.getSession(), attrMeta);
}
if (dbResult instanceof DBCResultSetTrace resultSetTrace) {
this.trace = resultSetTrace.getExecutionTrace();
}
}

@Override
Expand Down Expand Up @@ -153,8 +159,9 @@ public void fetchEnd(@NotNull DBCSession session, @NotNull DBCResultSet resultSe
webResultSet.setRows(List.of(rows.toArray(new WebSQLQueryResultSetRow[0])));
webResultSet.setHasChildrenCollection(resultSet instanceof DBDSubCollectionResultSet);
webResultSet.setSupportsDataFilter(dataContainer.isFeatureSupported(DBSDataContainer.FEATURE_DATA_FILTER));
webResultSet.setHasDynamicTrace(trace instanceof DBCTraceDynamic);

WebSQLResultsInfo resultsInfo = contextInfo.saveResult(dataContainer, bindings);
WebSQLResultsInfo resultsInfo = contextInfo.saveResult(dataContainer, trace, bindings);
webResultSet.setResultsInfo(resultsInfo);

boolean isSingleEntity = DBExecUtils.detectSingleSourceTable(bindings) != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class WebSQLQueryResultSet {

private boolean hasChildrenCollection;
private boolean isSupportsDataFilter;
private boolean hasDynamicTrace;

public WebSQLQueryResultSet() {
}
Expand Down Expand Up @@ -132,4 +133,13 @@ public boolean isSupportsDataFilter() {
public void setSupportsDataFilter(boolean supportsDataFilter) {
isSupportsDataFilter = supportsDataFilter;
}

@Property
public boolean isHasDynamicTrace() {
return hasDynamicTrace;
}

public void setHasDynamicTrace(boolean hasDynamicTrace) {
this.hasDynamicTrace = hasDynamicTrace;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ public void bindWiring(DBWBindingContext model) throws DBWebException {
env.getArgument("resultsId"),
env.getArgument("columnIndex"),
new WebSQLResultsRow(env.getArgument("row"))))
.dataFetcher("sqlGetDynamicTrace", env ->
getService(env).readDynamicTrace(
getWebSession(env),
getSQLContext(env),
env.getArgument("resultsId")
))
.dataFetcher("updateResultsDataBatch", env ->
getService(env).updateResultsDataBatch(
getSQLContext(env),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.DBCLogicalOperator;
import org.jkiss.dbeaver.model.exec.DBExecUtils;
import org.jkiss.dbeaver.model.exec.trace.DBCTrace;
import org.jkiss.dbeaver.model.exec.trace.DBCTraceDynamic;
import org.jkiss.dbeaver.model.exec.trace.DBCTraceProperty;
import org.jkiss.dbeaver.model.impl.sql.BasicSQLDialect;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
Expand Down Expand Up @@ -455,6 +458,21 @@ public void run(DBRProgressMonitor monitor) throws InvocationTargetException, In
return contextInfo.getProcessor().getWebSession().createAndRunAsyncTask("Read data from container " + nodePath, runnable);
}

@NotNull
@Override
public List<DBCTraceProperty> readDynamicTrace(
@NotNull WebSession webSession,
@NotNull WebSQLContextInfo contextInfo,
@NotNull String resultsId
) throws DBException {
WebSQLResultsInfo resultsInfo = contextInfo.getResults(resultsId);
DBCTrace trace = resultsInfo.getTrace();
if (trace instanceof DBCTraceDynamic traceDynamic) {
return traceDynamic.getTraceProperties(webSession.getProgressMonitor());
}
throw new DBWebException("Dynamic trace is not found in provided results info");
}

@Override
public WebSQLExecuteInfo asyncGetQueryResults(@NotNull WebSession webSession, @NotNull String taskId) throws DBWebException {
WebAsyncTaskInfo taskStatus = webSession.asyncTaskStatus(taskId, false);
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export default [
['ui_rename_processing', 'Renaming...'],
['ui_interval', 'Interval'],
['ui_name', 'Name'],
['ui_value', 'Value'],
['ui_description', 'Description'],
['ui_cant_delete_item', "This item can't be deleted"],
['ui_no_items_placeholder', 'There are no items yet.'],
['ui_search_no_result_placeholder', 'No results have been found.'],
Expand Down
20 changes: 11 additions & 9 deletions webapp/packages/core-localization/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export default [
['ui_data_saving_error', 'Erreur de sauvegarde'],
['ui_data_remove_confirmation', 'Confirmation de suppression'],
['ui_data_delete_confirmation', 'Confirmation de suppression'],
['ui_no_matches_placeholder', 'Votre recherche n\'a retourné aucun résultat.'],
['ui_no_matches_placeholder', "Votre recherche n'a retourné aucun résultat."],
['ui_information', 'Information'],
['ui_clipboard', 'Presse-papiers'],
['ui_copy_to_clipboard', 'Copier'],
['ui_copy_to_clipboard_copied', 'Copié'],
['ui_copy_to_clipboard_failed_to_copy', 'Échec de la copie'],
['ui_clipboard_access_denied_title', 'Accès au presse-papiers refusé'],
['ui_clipboard_access_denied_message', 'Vous devez donner accès au presse-papiers pour utiliser certaines fonctionnalités de l\'application'],
['ui_clipboard_access_denied_message', "Vous devez donner accès au presse-papiers pour utiliser certaines fonctionnalités de l'application"],
['ui_reveal_password', 'Afficher ou masquer le mot de passe'],
['ui_capslock_on', 'Verr Maj est activé'],
['ui_page_not_found', 'Page non trouvée'],
Expand All @@ -77,8 +77,10 @@ export default [
['ui_rename_processing', 'Renommage...'],
['ui_interval', 'Intervalle'],
['ui_name', 'Nom'],
['ui_value', 'Value'],
['ui_description', 'Description'],
['ui_cant_delete_item', 'Cet élément ne peut pas être supprimé'],
['ui_no_items_placeholder', 'Il n\'y a pas encore d\'éléments.'],
['ui_no_items_placeholder', "Il n'y a pas encore d'éléments."],
['ui_search_no_result_placeholder', 'Aucun résultat trouvé.'],
['ui_save_reminder', 'Vous avez des modifications non sauvegardées.'],
['ui_yes', 'Oui'],
Expand Down Expand Up @@ -125,17 +127,17 @@ export default [
['ui_export', 'Exporter'],
['ui_you', 'Vous'],

['root_permission_denied', 'Vous n\'avez pas les permissions'],
['root_permission_no_permission', 'Vous n\'avez pas la permission pour cette action'],
['app_root_session_expire_warning_title', 'La session est sur le point d\'expirer'],
['root_permission_denied', "Vous n'avez pas les permissions"],
['root_permission_no_permission', "Vous n'avez pas la permission pour cette action"],
['app_root_session_expire_warning_title', "La session est sur le point d'expirer"],
['app_root_session_expire_warning_message', 'Votre session expirera dans moins de 5 minutes. Pour continuer à travailler, fermez cette popup.'],
['app_root_session_expire_warning_button', 'Je suis ici'],
['app_root_session_expired_title', 'Session expirée'],
['app_root_session_expired_message', 'La session a expiré. Voulez-vous recharger ?'],
['app_root_session_expired_reload', 'Recharger'],
['app_root_server_node_changed_title', 'L\'application a été relancée'],
['app_root_server_node_changed_message', 'L\'application a été relancée. Veuillez recharger la page.'],
['app_root_server_node_changed_title', "L'application a été relancée"],
['app_root_server_node_changed_message', "L'application a été relancée. Veuillez recharger la page."],
['app_root_quota_exceeded', 'Quota dépassé'],
['app_root_event_permissions_changed_message', 'Vos permissions ont été modifiées'],
['core_eventsLog_dbeaverErrorDetails', 'Détails de l\'erreur'],
['core_eventsLog_dbeaverErrorDetails', "Détails de l'erreur"],
];
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export default [
['ui_rename_processing', 'Renaming...'],
['ui_interval', 'Interval'],
['ui_name', 'Name'],
['ui_value', 'Value'],
['ui_description', 'Description'],
['ui_cant_delete_item', "This item can't be deleted"],
['ui_no_items_placeholder', 'Non ci sono ancora elementi.'],
['ui_search_no_result_placeholder', 'Nessun risultato trovato.'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export default [
['ui_folder_new', 'Новая папка'],
['ui_rename_processing', 'Переименование...'],
['ui_name', 'Название'],
['ui_value', 'Значение'],
['ui_description', 'Описание'],
['ui_interval', 'Интервал'],
['ui_cant_delete_item', 'Этот элемент нельзя удалить'],
['ui_no_items_placeholder', 'Вы еще ничего не добавили.'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export default [
['ui_rename', '重命名'],
['ui_rename_processing', '重命名中...'],
['ui_name', '名称'],
['ui_value', 'Value'],
['ui_description', 'Description'],
['ui_interval', 'Interval'],
['ui_cant_delete_item', '此项目不能删除'],
['ui_no_items_placeholder', '还没有项目'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation getSqlDynamicTrace($projectId: ID, $connectionId: ID!, $contextId: ID!, $resultsId: ID!) {
trace: sqlGetDynamicTrace(projectId: $projectId, connectionId: $connectionId, contextId: $contextId, resultsId: $resultsId) {
name
value
description
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mutation getSqlExecuteTaskResults($taskId: ID!) {
hasRowIdentifier
isSupportsDataFilter
hasChildrenCollection
hasDynamicTrace
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ mutation updateResultsDataBatch(
hasRowIdentifier
isSupportsDataFilter
hasChildrenCollection
hasDynamicTrace
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions webapp/packages/core-utils/src/ILoadableState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*/

export interface ILoadableState {
readonly promise?: Promise<any> | null;
readonly exception?: (Error | null)[] | Error | null;
lazy?: boolean;
isLoading: () => boolean;
isLoaded: () => boolean;
isError: () => boolean;
readonly exception?: (Error | null)[] | Error | null;
load: () => void | Promise<void>;
reload?: () => void | Promise<void>;

promise?: Promise<any> | null;
isOutdated?: () => boolean;
isCancelled?: () => boolean;
cancel?: () => void;
Expand Down
17 changes: 17 additions & 0 deletions webapp/packages/plugin-data-viewer-result-trace-details/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# dependencies
/node_modules

# testing
/coverage

# production
/lib

# misc
.DS_Store
.env*

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Loading