This is an automated email from the ASF dual-hosted git repository.
vogievetsky pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 4354e43 Use existing queryId if it exists (#11834)
4354e43 is described below
commit 4354e43983c884ff83c6646c9dedf69afc307291
Author: Vadim Ogievetsky <[email protected]>
AuthorDate: Sat Oct 23 19:02:39 2021 -0700
Use existing queryId if it exists (#11834)
---
web-console/src/views/query-view/query-view.tsx | 32 +++++++++++--------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/web-console/src/views/query-view/query-view.tsx
b/web-console/src/views/query-view/query-view.tsx
index d8ca935..44fee19 100644
--- a/web-console/src/views/query-view/query-view.tsx
+++ b/web-console/src/views/query-view/query-view.tsx
@@ -48,7 +48,7 @@ import {
RowColumn,
stringifyValue,
} from '../../utils';
-import { isEmptyContext, QueryContext } from '../../utils/query-context';
+import { QueryContext } from '../../utils/query-context';
import { QueryRecord, QueryRecordUtil } from '../../utils/query-history';
import { ColumnTree } from './column-tree/column-tree';
@@ -203,31 +203,27 @@ export class QueryView extends
React.PureComponent<QueryViewProps, QueryViewStat
cancelToken,
): Promise<QueryResult> => {
const { queryString, queryContext, wrapQueryLimit } = queryWithContext;
-
const isSql = !QueryView.isJsonLike(queryString);
-
const query = isSql ? queryString : Hjson.parse(queryString);
+ const context = { ...queryContext, ...(mandatoryQueryContext || {}) };
- const queryId = uuidv4();
-
- let context: Record<string, any> | undefined;
- if (!isEmptyContext(queryContext) || wrapQueryLimit ||
mandatoryQueryContext) {
- context = { ...queryContext, ...(mandatoryQueryContext || {}) };
-
- if (isSql) {
- context.sqlQueryId = queryId;
- } else {
- context.queryId = queryId;
- }
+ if (typeof wrapQueryLimit !== 'undefined') {
+ context.sqlOuterLimit = wrapQueryLimit + 1;
+ }
- if (typeof wrapQueryLimit !== 'undefined') {
- context.sqlOuterLimit = wrapQueryLimit + 1;
- }
+ const queryIdKey = isSql ? 'sqlQueryId' : 'queryId';
+ // Look for the queryId in the JSON itself (if native) or in the
context object.
+ let cancelQueryId = (isSql ? undefined : query.context?.queryId) ||
context[queryIdKey];
+ if (!cancelQueryId) {
+ // If the queryId (sqlQueryId) is not explicitly set on the context
generate one so it is possible to cancel the query.
+ cancelQueryId = context[queryIdKey] = uuidv4();
}
void cancelToken.promise
.then(() => {
- return Api.instance.delete(`/druid/v2${isSql ? '/sql' :
''}/${queryId}`);
+ return Api.instance.delete(
+ `/druid/v2${isSql ? '/sql' :
''}/${Api.encodePath(cancelQueryId)}`,
+ );
})
.catch(() => {});
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]