Skip to content

Commit

Permalink
[Discover] Enables the inspector for the text based languages (#147833)
Browse files Browse the repository at this point in the history
## Summary

Enables the inspector on the text based languages (it already works in
Lens)

<img width="888" alt="image"
src="https://user-images.githubusercontent.com/17003240/208626066-24d20605-2b68-45e8-9aff-b17f9f6b297c.png">
  • Loading branch information
stratoula authored Dec 20, 2022
1 parent 612b16b commit a6c6efb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/plugins/discover/public/application/main/utils/fetch_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ export function fetchAll(
reset = false,
fetchDeps: FetchDeps
): Promise<void> {
const { initialFetchStatus, appStateContainer, services, useNewFieldsApi, data } = fetchDeps;
const {
initialFetchStatus,
appStateContainer,
services,
useNewFieldsApi,
data,
inspectorAdapters,
} = fetchDeps;

try {
const dataView = searchSource.getField('index')!;
Expand Down Expand Up @@ -81,7 +88,7 @@ export function fetchAll(
// Start fetching all required requests
const documents =
useSql && query
? fetchSql(query, services.dataViews, data, services.expressions)
? fetchSql(query, services.dataViews, data, services.expressions, inspectorAdapters)
: fetchDocuments(searchSource.createCopy(), fetchDeps);

// Handle results of the individual queries and forward the results to the corresponding dataSubjects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { pluck } from 'rxjs/operators';
import { lastValueFrom } from 'rxjs';
import { Query, AggregateQuery, Filter } from '@kbn/es-query';
import type { Adapters } from '@kbn/inspector-plugin/common';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import type { Datatable } from '@kbn/expressions-plugin/public';
Expand All @@ -27,6 +28,7 @@ export function fetchSql(
dataViewsService: DataViewsContract,
data: DataPublicPluginStart,
expressions: ExpressionsStart,
inspectorAdapters: Adapters,
filters?: Filter[],
inputQuery?: Query
) {
Expand All @@ -40,7 +42,9 @@ export function fetchSql(
})
.then((ast) => {
if (ast) {
const execution = expressions.run(ast, null);
const execution = expressions.run(ast, null, {
inspectorAdapters,
});
let finalData: DataTableRecord[] = [];
let error: string | undefined;
execution.pipe(pluck('result')).subscribe((resp) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export class SavedSearchEmbeddable
this.services.dataViews,
this.services.data,
this.services.expressions,
this.services.inspector,
this.input.filters,
this.input.query
);
Expand Down

0 comments on commit a6c6efb

Please sign in to comment.