Skip to content

Commit

Permalink
[8.x] [ES|QL] Enable cursor sync for timeseries charts (#192837) (#19…
Browse files Browse the repository at this point in the history
…2982)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Enable cursor sync for timeseries charts
(#192837)](#192837)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-16T10:03:58Z","message":"[ES|QL]
Enable cursor sync for timeseries charts (#192837)\n\n##
Summary\r\n\r\nSyncs the cursor for timeseries charts powered by
ES|QL\r\n\r\n\r\n![meow](https://github.com/user-attachments/assets/62664b27-ce95-493d-863a-b5ecaa8006ed)\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Marco Vettorello
<[email protected]>","sha":"a581087f530ce4a9143d54d76147b7b645a39da4","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Visualizations","Feature:Lens","v9.0.0","backport:prev-minor","Feature:ES|QL","v8.16.0"],"title":"[ES|QL]
Enable cursor sync for timeseries
charts","number":192837,"url":"https://github.com/elastic/kibana/pull/192837","mergeCommit":{"message":"[ES|QL]
Enable cursor sync for timeseries charts (#192837)\n\n##
Summary\r\n\r\nSyncs the cursor for timeseries charts powered by
ES|QL\r\n\r\n\r\n![meow](https://github.com/user-attachments/assets/62664b27-ce95-493d-863a-b5ecaa8006ed)\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Marco Vettorello
<[email protected]>","sha":"a581087f530ce4a9143d54d76147b7b645a39da4"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192837","number":192837,"mergeCommit":{"message":"[ES|QL]
Enable cursor sync for timeseries charts (#192837)\n\n##
Summary\r\n\r\nSyncs the cursor for timeseries charts powered by
ES|QL\r\n\r\n\r\n![meow](https://github.com/user-attachments/assets/62664b27-ce95-493d-863a-b5ecaa8006ed)\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Marco Vettorello
<[email protected]>","sha":"a581087f530ce4a9143d54d76147b7b645a39da4"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <[email protected]>
  • Loading branch information
kibanamachine and stratoula authored Sep 16, 2024
1 parent 82c12a6 commit 8f01c22
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,39 @@ describe('active_cursor_utils', () => {
}
`);
});

test('should return isDateHistogram true in case the datatable is powered by ES|QL', () => {
expect(
parseSyncOptions({
datatables: [
{
columns: [
{
id: 'timestamp',
meta: {
type: 'date',
},
},
{
id: 'count',
meta: {
type: 'number',
},
},
],
meta: {
type: 'es_ql',
},
},
] as unknown as Datatable[],
})
).toMatchInlineSnapshot(`
Object {
"accessors": Array [],
"isDateHistogram": true,
}
`);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { uniq } from 'lodash';

import type { Datatable } from '@kbn/expressions-plugin/public';
import { ESQL_TABLE_TYPE } from '@kbn/data-plugin/common';
import type { ActiveCursorSyncOption, DateHistogramSyncOption } from './types';
import type { ActiveCursorPayload } from './types';

Expand All @@ -20,6 +21,16 @@ function isDateHistogramSyncOption(
}

const parseDatatable = (dataTables: Datatable[]) => {
const isEsqlMode = dataTables.some((t) => t?.meta?.type === ESQL_TABLE_TYPE);

if (isEsqlMode) {
return {
isDateHistogram:
Boolean(dataTables.length) &&
dataTables.every((t) => t.columns.some((c) => c.meta.type === 'date')),
accessors: [],
};
}
const isDateHistogram =
Boolean(dataTables.length) &&
dataTables.every((dataTable) =>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/charts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@kbn/ui-theme",
"@kbn/shared-ux-utility",
"@kbn/config-schema",
"@kbn/data-plugin",
],
"exclude": [
"target/**/*",
Expand Down

0 comments on commit 8f01c22

Please sign in to comment.