forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[maps] fix no geometry column found when editing ES|QL layers (elasti…
…c#176231) Resolves elastic#176227 PR updates maps ES|QL code to handle response shape when `drop_null_values` is used. PR adds an integration test that will fail if the ES|QL response shape changes. #### Test steps 1. install sample web logs 2. create new map, add `ES|QL` layer 3. Edit query, changing limit from default of "10,000" to "1,000". Click "run". Verify results are displayed 4. Set query that returns no results like, "bytes > 100000000". Verify layer displays no results. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
79dbc47
commit 3e55ab5
Showing
5 changed files
with
137 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import request from 'superagent'; | ||
import { inflateResponse } from '@kbn/bfetch-plugin/public/streaming'; | ||
import expect from '@kbn/expect'; | ||
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; | ||
import { BFETCH_ROUTE_VERSION_LATEST } from '@kbn/bfetch-plugin/common'; | ||
import type { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
function parseBfetchResponse(resp: request.Response, compressed: boolean = false) { | ||
return resp.text | ||
.trim() | ||
.split('\n') | ||
.map((item) => { | ||
return JSON.parse(compressed ? inflateResponse<any>(item) : item); | ||
}); | ||
} | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
|
||
describe('bsearch', () => { | ||
describe('ES|QL', () => { | ||
it(`should return getColumns response in expected shape`, async () => { | ||
const resp = await supertest | ||
.post(`/internal/bsearch`) | ||
.set('kbn-xsrf', 'kibana') | ||
.set(ELASTIC_HTTP_VERSION_HEADER, BFETCH_ROUTE_VERSION_LATEST) | ||
.send({ | ||
batch: [ | ||
{ | ||
request: { | ||
params: { | ||
query: 'from logstash-* | keep geo.coordinates | limit 0', | ||
}, | ||
}, | ||
options: { | ||
strategy: 'esql', | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
const jsonBody = parseBfetchResponse(resp); | ||
expect(resp.status).to.be(200); | ||
expect(jsonBody[0].result.rawResponse).to.eql({ | ||
columns: [ | ||
{ | ||
name: 'geo.coordinates', | ||
type: 'geo_point', | ||
}, | ||
], | ||
values: [], | ||
}); | ||
}); | ||
|
||
it(`should return getValues response in expected shape`, async () => { | ||
const resp = await supertest | ||
.post(`/internal/bsearch`) | ||
.set('kbn-xsrf', 'kibana') | ||
.set(ELASTIC_HTTP_VERSION_HEADER, BFETCH_ROUTE_VERSION_LATEST) | ||
.send({ | ||
batch: [ | ||
{ | ||
request: { | ||
params: { | ||
dropNullColumns: true, | ||
query: | ||
'from logstash-* | keep geo.coordinates, @timestamp | sort @timestamp | limit 1', | ||
}, | ||
}, | ||
options: { | ||
strategy: 'esql', | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
const jsonBody = parseBfetchResponse(resp); | ||
expect(resp.status).to.be(200); | ||
expect(jsonBody[0].result.rawResponse).to.eql({ | ||
all_columns: [ | ||
{ | ||
name: 'geo.coordinates', | ||
type: 'geo_point', | ||
}, | ||
{ | ||
name: '@timestamp', | ||
type: 'date', | ||
}, | ||
], | ||
columns: [ | ||
{ | ||
name: 'geo.coordinates', | ||
type: 'geo_point', | ||
}, | ||
{ | ||
name: '@timestamp', | ||
type: 'date', | ||
}, | ||
], | ||
values: [['POINT (-120.9871642 38.68407028)', '2015-09-20T00:00:00.000Z']], | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters