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

[TSVB] Allow string fields on value count aggregation #79267

Merged
merged 4 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -25,6 +25,7 @@ export function getSupportedFieldsByMetricType(type) {
case METRIC_TYPES.CARDINALITY:
return Object.values(KBN_FIELD_TYPES).filter((t) => t !== KBN_FIELD_TYPES.HISTOGRAM);
case METRIC_TYPES.VALUE_COUNT:
return [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM, KBN_FIELD_TYPES.STRING];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like value count works for all field types - I changed this to return KBN_FIELD_TYPES and got nice looking charts as well:
Screenshot 2020-10-05 at 15 28 11

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No if it supports them all then I will change it to support them all 🙂 Thanx for that

case METRIC_TYPES.AVERAGE:
case METRIC_TYPES.SUM:
return [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ describe('getSupportedFieldsByMetricType', () => {
it(`should return numbers and histogram for ${type}`, () => {
expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram']);
});
const shouldHaveHistogramNumbersAndStrings = (type) =>
it(`should return numbers, histogram and strings for ${type}`, () => {
expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram', 'string']);
});
const shouldHaveOnlyNumbers = (type) =>
it(`should return only numbers for ${type}`, () => {
expect(getSupportedFieldsByMetricType(type)).toEqual(['number']);
});

shouldHaveHistogramAndNumbers('value_count');
shouldHaveHistogramNumbersAndStrings('value_count');
shouldHaveHistogramAndNumbers('avg');
shouldHaveHistogramAndNumbers('sum');

Expand Down