Skip to content

Commit

Permalink
Address Pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Jan 20, 2024
1 parent b5fe67b commit e843fec
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-field-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export {
getKbnFieldType,
getKbnTypeNames,
getFilterableKbnTypeNames,
normalizeType,
esFieldTypeToKibanaFieldType,
} from './src/kbn_field_types';

export type { KbnFieldTypeOptions } from './src/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-field-types/src/kbn_field_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const castEsToKbnFieldTypeName = (esType: ES_FIELD_TYPES | string): KBN_F
export const getFilterableKbnTypeNames = (): string[] =>
registeredKbnTypes.filter((type) => type.filterable).map((type) => type.name);

export function normalizeType(type: string) {
export function esFieldTypeToKibanaFieldType(type: string) {
switch (type) {
case ES_FIELD_TYPES._INDEX:
case ES_FIELD_TYPES.GEO_POINT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { Suggestion } from '../src/types';
import type { TableChangeType } from '../src/types';

export const currentSuggestionMock = {
title: 'Heat map',
Expand Down Expand Up @@ -130,5 +130,5 @@ export const currentSuggestionMock = {
},
datasourceId: 'textBased',
columns: 2,
changeType: 'initial',
} as Suggestion;
changeType: 'initial' as TableChangeType,
};
4 changes: 2 additions & 2 deletions src/plugins/data/common/search/expressions/esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import type { KibanaRequest } from '@kbn/core/server';
import { normalizeType } from '@kbn/field-types';
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import { i18n } from '@kbn/i18n';
import type { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
Expand Down Expand Up @@ -217,7 +217,7 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
body.columns?.map(({ name, type }) => ({
id: name,
name,
meta: { type: normalizeType(type) },
meta: { type: esFieldTypeToKibanaFieldType(type) },
})) ?? [];
const columnNames = columns.map(({ name }) => name);
const rows = body.values.map((row) => zipObject(columnNames, row));
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/common/search/expressions/essql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import type { KibanaRequest } from '@kbn/core/server';
import { buildEsQuery } from '@kbn/es-query';
import { normalizeType } from '@kbn/field-types';
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import { i18n } from '@kbn/i18n';
import type { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
Expand Down Expand Up @@ -241,7 +241,7 @@ export const getEssqlFn = ({ getStartDependencies }: EssqlFnArguments) => {
body.columns?.map(({ name, type }) => ({
id: sanitize(name),
name: sanitize(name),
meta: { type: normalizeType(type) },
meta: { type: esFieldTypeToKibanaFieldType(type) },
})) ?? [];
const columnNames = columns.map(({ name }) => name);
const rows = body.rows.map((row) => zipObject(columnNames, row));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { normalizeType } from '@kbn/field-types';
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import type { ESQLSearchReponse } from '@kbn/es-types';
import { visualizeESQLFunction } from '../../common/functions/visualize_esql';
import type { FunctionRegistrationParameters } from '.';
Expand Down Expand Up @@ -34,7 +34,7 @@ export function registerVisualizeESQLFunction({
response.columns?.map(({ name, type }) => ({
id: name,
name,
meta: { type: normalizeType(type) },
meta: { type: esFieldTypeToKibanaFieldType(type) },
})) ?? [];
return { content: columns };
}
Expand Down

0 comments on commit e843fec

Please sign in to comment.