Skip to content

Commit

Permalink
support saved sql vis
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <[email protected]>
  • Loading branch information
joshuali925 committed Mar 12, 2024
1 parent be67c7e commit e94ec3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions public/components/event_analytics/explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e94ec3f

Please sign in to comment.