diff --git a/public/components/event_analytics/explorer/explorer.tsx b/public/components/event_analytics/explorer/explorer.tsx index cc831200ee..f1d0a6db75 100644 --- a/public/components/event_analytics/explorer/explorer.tsx +++ b/public/components/event_analytics/explorer/explorer.tsx @@ -643,9 +643,9 @@ export const Explorer = ({ ? { ...userVizConfigs[curVisId] } : { dataConfig: getDefaultVisConfig( - explorerSearchMeta.lang === QUERY_LANGUAGE.PPL - ? queryManager.queryParser().parse(tempQuery).getStats() - : getGroupBy(tempQuery) + explorerSearchMeta.lang === QUERY_LANGUAGE.SQL + ? getGroupBy(tempQuery) + : queryManager.queryParser().parse(tempQuery).getStats() ), }; diff --git a/public/services/saved_objects/saved_object_loaders/explorer_saved_object_loader.ts b/public/services/saved_objects/saved_object_loaders/explorer_saved_object_loader.ts index a33b65201c..206850b64e 100644 --- a/public/services/saved_objects/saved_object_loaders/explorer_saved_object_loader.ts +++ b/public/services/saved_objects/saved_object_loaders/explorer_saved_object_loader.ts @@ -11,6 +11,7 @@ import { ASYNC_POLLING_INTERVAL, DEFAULT_DATA_SOURCE_NAME, DEFAULT_DATA_SOURCE_TYPE, + QUERY_LANGUAGE, } from '../../../../common/constants/data_sources'; import { AGGREGATIONS, @@ -28,6 +29,7 @@ import { } from '../../../../common/constants/explorer'; import { QueryManager } from '../../../../common/query_manager'; import { statsChunk } from '../../../../common/query_manager/ast/types/stats'; +import { getGroupBy } from '../../../../common/query_manager/query_parser/sql_query_parser'; import { DirectQueryRequest, IField, @@ -252,7 +254,11 @@ export class ExplorerSavedObjectLoader extends SavedObjectLoaderBase implements if (!isEmpty(customConfig.dataConfig) && !isEmpty(customConfig.dataConfig?.series)) { visConfig = { ...customConfig }; } else { - const statsTokens = queryManager.queryParser().parse(objectData.query).getStats(); + // although type says it's objectData.queryLang, the field is query_lang + const statsTokens = + objectData.query_lang === QUERY_LANGUAGE.SQL + ? getGroupBy(objectData.query) + : queryManager.queryParser().parse(objectData.query).getStats(); visConfig = { dataConfig: { ...getDefaultVisConfig(statsTokens) } }; } await dispatch(