diff --git a/public/app/core/utils/explore.ts b/public/app/core/utils/explore.ts index be771c1b232..e268508b833 100644 --- a/public/app/core/utils/explore.ts +++ b/public/app/core/utils/explore.ts @@ -130,10 +130,15 @@ export function ensureQueries(queries?: DataQuery[]): DataQuery[] { } /** - * A target is non-empty when it has keys other than refId and key. + * A target is non-empty when it has keys (with non-empty values) other than refId and key. */ export function hasNonEmptyQuery(queries: DataQuery[]): boolean { - return queries.some(query => Object.keys(query).length > 2); + return queries.some( + query => + Object.keys(query) + .map(k => query[k]) + .filter(v => v).length > 2 + ); } export function calculateResultsFromQueryTransactions( diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 71e23640bec..23a06a5acc9 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -772,6 +772,9 @@ export class Explore extends React.PureComponent { async runQueries(resultType: ResultType, queryOptions: any, resultGetter?: any) { const queries = [...this.modifiedQueries]; if (!hasNonEmptyQuery(queries)) { + this.setState({ + queryTransactions: [], + }); return; } const { datasource } = this.state;