Skip to content

Commit

Permalink
correct fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Apr 12, 2024
1 parent b5c0597 commit bb10723
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,16 @@ export async function getDataViewByTextBasedQueryLang(
if ('esql' in query) {
indexPatternFromQuery = getIndexPatternFromESQLQuery(query.esql);
}
// we should find a better way to work with ESQL queries which dont need a dataview
if (!indexPatternFromQuery && currentDataView) {
// Here the user used either the ROW or SHOW META / SHOW INFO commands
// if we use the current dataview will create this error https://github.com/elastic/kibana/issues/163417
// so we are creating an adhoc dataview without an @timestamp timeFieldName
return await getESQLAdHocDataview(currentDataView.name, services.dataViews);
}

if (
currentDataView?.isPersisted() ||
indexPatternFromQuery !== currentDataView?.getIndexPattern()
) {
const dataViewObj = await getESQLAdHocDataview(indexPatternFromQuery, services.dataViews);

if (dataViewObj.fields.getByName('@timestamp')?.type === 'date') {
// If the indexPatternFromQuery is empty string means that the user used either the ROW or SHOW META / SHOW INFO commands
// we don't want to add the @timestamp field in this case https://github.com/elastic/kibana/issues/163417
if (indexPatternFromQuery && dataViewObj.fields.getByName('@timestamp')?.type === 'date') {
dataViewObj.timeFieldName = '@timestamp';
}
return dataViewObj;
Expand Down

0 comments on commit bb10723

Please sign in to comment.