mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[ES|QL] Fixes the mapping of ES fields (#176665)
## Summary When we created the ESQL strategy we used the same logic with SQL. But this is not 100% correct. For example it converts the ip type fields to strings, same as geo_points. This PR is fixing it. So now if you run for example ``` from kibana_sample_data_logs | WHERE CIDR_MATCH(ip, "153.189.234.161/32", "127.0.0.3/32") | stats count(*) ``` the client side validation won't fail.
This commit is contained in:
parent
d676f169f0
commit
8a651ea5be
4 changed files with 7 additions and 28 deletions
|
@ -52,8 +52,6 @@ export const getFilterableKbnTypeNames = (): string[] =>
|
|||
export function esFieldTypeToKibanaFieldType(type: string) {
|
||||
switch (type) {
|
||||
case ES_FIELD_TYPES._INDEX:
|
||||
case ES_FIELD_TYPES.GEO_POINT:
|
||||
case ES_FIELD_TYPES.IP:
|
||||
return KBN_FIELD_TYPES.STRING;
|
||||
case '_version':
|
||||
return KBN_FIELD_TYPES.NUMBER;
|
||||
|
|
|
@ -7,13 +7,9 @@
|
|||
*/
|
||||
|
||||
import type { KibanaRequest } from '@kbn/core/server';
|
||||
import { castEsToKbnFieldTypeName, ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type {
|
||||
Datatable,
|
||||
DatatableColumnType,
|
||||
ExpressionFunctionDefinition,
|
||||
} from '@kbn/expressions-plugin/common';
|
||||
import type { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
|
||||
import { RequestAdapter } from '@kbn/inspector-plugin/common';
|
||||
|
||||
import { zipObject } from 'lodash';
|
||||
|
@ -61,21 +57,6 @@ interface EsqlStartDependencies {
|
|||
uiSettings: UiSettingsCommon;
|
||||
}
|
||||
|
||||
function normalizeType(type: string): DatatableColumnType {
|
||||
switch (type) {
|
||||
case ES_FIELD_TYPES._INDEX:
|
||||
case ES_FIELD_TYPES.GEO_POINT:
|
||||
case ES_FIELD_TYPES.IP:
|
||||
return KBN_FIELD_TYPES.STRING;
|
||||
case '_version':
|
||||
return KBN_FIELD_TYPES.NUMBER;
|
||||
case 'datetime':
|
||||
return KBN_FIELD_TYPES.DATE;
|
||||
default:
|
||||
return castEsToKbnFieldTypeName(type) as DatatableColumnType;
|
||||
}
|
||||
}
|
||||
|
||||
function extractTypeAndReason(attributes: any): { type?: string; reason?: string } {
|
||||
if (['type', 'reason'].every((prop) => prop in attributes)) {
|
||||
return attributes;
|
||||
|
@ -252,7 +233,7 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
|
|||
(body.all_columns ?? body.columns)?.map(({ name, type }) => ({
|
||||
id: name,
|
||||
name,
|
||||
meta: { type: normalizeType(type) },
|
||||
meta: { type: esFieldTypeToKibanaFieldType(type) },
|
||||
isNull: hasEmptyColumns ? !lookup.has(name) : false,
|
||||
})) ?? [];
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await PageObjects.unifiedFieldList.clickFieldListItemAdd('ip');
|
||||
await PageObjects.unifiedFieldList.clickFieldListItemAdd('geo.coordinates');
|
||||
|
||||
expect(await findFirstColumnTokens()).to.eql(['Number', 'String', 'String', 'String']);
|
||||
expect(await findFirstColumnTokens()).to.eql(['Number', 'String', 'IP address', 'Geo point']);
|
||||
|
||||
expect(await findFirstDocViewerTokens()).to.eql([
|
||||
'String',
|
||||
|
@ -138,9 +138,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
'Date',
|
||||
'String',
|
||||
'Number',
|
||||
'IP address',
|
||||
'String',
|
||||
'String',
|
||||
'String',
|
||||
'Geo point',
|
||||
'String',
|
||||
'String',
|
||||
]);
|
||||
|
|
|
@ -114,7 +114,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded();
|
||||
await PageObjects.unifiedFieldList.openSidebarFieldFilter();
|
||||
options = await find.allByCssSelector('[data-test-subj*="typeFilter"]');
|
||||
expect(options).to.have.length(3);
|
||||
expect(options).to.have.length(5);
|
||||
|
||||
expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be(
|
||||
'82 available fields.'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue