Skip to content

Commit

Permalink
[TSVB] Visualize runtime fields
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Mar 30, 2021
1 parent e91d0d4 commit 1e982ae
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class IndexPattern implements IIndexPattern {
private shortDotsEnable: boolean = false;
private fieldFormats: FieldFormatsStartCommon;
private fieldAttrs: FieldAttrs;
private runtimeFieldMap: Record<string, RuntimeField>;
public runtimeFieldMap: Record<string, RuntimeField>;

/**
* prevents errors when index pattern exists before indices
Expand Down
13 changes: 1 addition & 12 deletions src/plugins/vis_type_timeseries/common/fields_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { toSanitizedFieldType } from './fields_utils';
import type { FieldSpec, RuntimeField } from '../../data/common';
import type { FieldSpec } from '../../data/common';

describe('fields_utils', () => {
describe('toSanitizedFieldType', () => {
Expand All @@ -34,17 +34,6 @@ describe('fields_utils', () => {
`);
});

test('should filter runtime fields', async () => {
const fields: FieldSpec[] = [
{
...mockedField,
runtimeField: {} as RuntimeField,
},
];

expect(toSanitizedFieldType(fields)).toMatchInlineSnapshot(`Array []`);
});

test('should filter non-aggregatable fields', async () => {
const fields: FieldSpec[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_timeseries/common/fields_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const toSanitizedFieldType = (fields: FieldSpec[]) => {
.filter(
(field) =>
// Make sure to only include mapped fields, e.g. no index pattern runtime fields
!field.runtimeField && field.aggregatable && !isNestedField(field)
field.aggregatable && !isNestedField(field)
)
.map(
(field) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export class TablePanelConfig extends Component<
fields={this.props.fields}
model={this.props.model}
onChange={this.props.onChange}
allowIndexSwitchingMode={true}
/>

<EuiHorizontalRule />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export async function getAnnotationRequestParams(
index: indexPatternString,
body: {
...request,
runtime_mappings: indexPattern?.runtimeFieldMap || {},
timeout: esShardTimeout > 0 ? `${esShardTimeout}ms` : undefined,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export async function getTableData(

const [resp] = await searchStrategy.search(requestContext, req, [
{
body,
body: {
...body,
runtime_mappings: panelIndex.indexPattern?.runtimeFieldMap || {},
},
index: panelIndex.indexPatternString,
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function getSeriesRequestParams(
index: seriesIndex.indexPatternString,
body: {
...request,
runtime_mappings: seriesIndex.indexPattern?.runtimeFieldMap || {},
timeout: esShardTimeout > 0 ? `${esShardTimeout}ms` : undefined,
},
};
Expand Down

0 comments on commit 1e982ae

Please sign in to comment.