Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Enable cursor sync for timeseries charts #192837

Merged
merged 7 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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