Skip to content

Commit

Permalink
[ES|QL] Use the function from the editor plugin (elastic#174738)
Browse files Browse the repository at this point in the history
## Summary

This is a cleanup. I realized that the fetchFieldsFromESQL function is
already exported by the editor plugin so we can use it from there rather
than duplicating the code.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
2 people authored and semd committed Jan 12, 2024
1 parent 1011e3b commit 7e042e5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
import { fetchFieldsFromESQL } from '@kbn/text-based-editor';
import type { LensPluginStartDependencies } from '../../../plugin';
import { createMockStartDependencies } from '../../../editor_frame_service/mocks';
import {
Expand All @@ -14,7 +15,6 @@ import {
mockAllSuggestions,
} from '../../../mocks';
import { suggestionsApi } from '../../../lens_suggestions_api';
import { fetchFieldsFromESQL } from '../../../datasources/text_based/fetch_fields_from_esql';
import { getSuggestions } from './helpers';

const mockSuggestionApi = suggestionsApi as jest.Mock;
Expand All @@ -24,7 +24,7 @@ jest.mock('../../../lens_suggestions_api', () => ({
suggestionsApi: jest.fn(() => mockAllSuggestions),
}));

jest.mock('../../../datasources/text_based/fetch_fields_from_esql', () => ({
jest.mock('@kbn/text-based-editor', () => ({
fetchFieldsFromESQL: jest.fn(() => {
return {
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import { i18n } from '@kbn/i18n';
import { getIndexPatternFromSQLQuery, getIndexPatternFromESQLQuery } from '@kbn/es-query';
import type { AggregateQuery, Query, Filter } from '@kbn/es-query';
import { fetchFieldsFromESQL } from '@kbn/text-based-editor';
import type { DataView, DataViewSpec } from '@kbn/data-views-plugin/public';
import type { Suggestion } from '../../../types';
import type { TypedLensByValueInput } from '../../../embeddable/embeddable_component';
import type { LensPluginStartDependencies } from '../../../plugin';
import type { DatasourceMap, VisualizationMap } from '../../../types';
import { fetchFieldsFromESQL } from '../../../datasources/text_based/fetch_fields_from_esql';
import { suggestionsApi } from '../../../lens_suggestions_api';

export const getQueryColumns = async (query: AggregateQuery, deps: LensPluginStartDependencies) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React, { useEffect, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { fetchFieldsFromESQL } from '@kbn/text-based-editor';
import { DimensionTrigger } from '@kbn/visualization-ui-components';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import type { DatasourceDimensionTriggerProps } from '../../../types';
Expand All @@ -16,7 +17,6 @@ import {
addColumnsToCache,
retrieveLayerColumnsFromCache,
} from '../fieldlist_cache';
import { fetchFieldsFromESQL } from '../fetch_fields_from_esql';

export type TextBasedDimensionTrigger = DatasourceDimensionTriggerProps<TextBasedPrivateState> & {
columnLabelMap: Record<string, string>;
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion x-pack/plugins/lens/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"@kbn/lens-formula-docs",
"@kbn/visualization-utils",
"@kbn/test-eui-helpers",
"@kbn/shared-ux-utility"
"@kbn/shared-ux-utility",
"@kbn/text-based-editor"
],
"exclude": [
"target/**/*"
Expand Down

0 comments on commit 7e042e5

Please sign in to comment.