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

[ML] Changes group-by and agg names. #36686

Merged
merged 3 commits into from
May 21, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/plugins/ml/public/data_frame/common/pivot_aggs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface PivotAggsConfig {
agg: PIVOT_SUPPORTED_AGGS;
field: FieldName;
aggName: AggName;
dropDownName: string;
}

export type PivotAggsConfigDict = Dictionary<PivotAggsConfig>;
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const pivotGroupByFieldSupport = {
interface GroupByConfigBase {
field: FieldName;
aggName: AggName;
dropDownName: string;
}

// Don't allow an interval of '0', but allow a float interval of '0.1' with a leading zero.
Expand Down
24 changes: 16 additions & 8 deletions x-pack/plugins/ml/public/data_frame/common/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@ describe('Data Frame: Common', () => {
{
agg: PIVOT_SUPPORTED_GROUP_BY_AGGS.TERMS,
field: 'the-group-by-field',
aggName: 'the-group-by-label',
aggName: 'the-group-by-agg-name',
dropDownName: 'the-group-by-drop-down-name',
},
];
const aggs: PivotAggsConfig[] = [
{ agg: PIVOT_SUPPORTED_AGGS.AVG, field: 'the-agg-field', aggName: 'the-agg-label' },
{
agg: PIVOT_SUPPORTED_AGGS.AVG,
field: 'the-agg-field',
aggName: 'the-agg-agg-name',
dropDownName: 'the-agg-drop-down-name',
},
];
const request = getDataFramePreviewRequest('the-index-pattern-title', query, groupBy, aggs);

expect(request).toEqual({
pivot: {
aggregations: { 'the-agg-label': { avg: { field: 'the-agg-field' } } },
group_by: { 'the-group-by-label': { terms: { field: 'the-group-by-field' } } },
aggregations: { 'the-agg-agg-name': { avg: { field: 'the-agg-field' } } },
group_by: { 'the-group-by-agg-name': { terms: { field: 'the-group-by-field' } } },
},
source: {
index: 'the-index-pattern-title',
Expand All @@ -55,12 +61,14 @@ describe('Data Frame: Common', () => {
const groupBy: PivotGroupByConfig = {
agg: PIVOT_SUPPORTED_GROUP_BY_AGGS.TERMS,
field: 'the-group-by-field',
aggName: 'the-group-by-label',
aggName: 'the-group-by-agg-name',
dropDownName: 'the-group-by-drop-down-name',
};
const agg: PivotAggsConfig = {
agg: PIVOT_SUPPORTED_AGGS.AVG,
field: 'the-agg-field',
aggName: 'the-agg-label',
aggName: 'the-agg-agg-name',
dropDownName: 'the-agg-drop-down-name',
};
const pivotState: DefinePivotExposedState = {
aggList: { 'the-agg-name': agg },
Expand All @@ -81,8 +89,8 @@ describe('Data Frame: Common', () => {
expect(request).toEqual({
dest: { index: 'the-target-index' },
pivot: {
aggregations: { 'the-agg-label': { avg: { field: 'the-agg-field' } } },
group_by: { 'the-group-by-label': { terms: { field: 'the-group-by-field' } } },
aggregations: { 'the-agg-agg-name': { avg: { field: 'the-agg-field' } } },
group_by: { 'the-group-by-agg-name': { terms: { field: 'the-group-by-field' } } },
},
source: {
index: 'the-index-pattern-title',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ describe('Data Frame: <AggLabelForm />', () => {
const item: PivotAggsConfig = {
agg: PIVOT_SUPPORTED_AGGS.CARDINALITY,
field: 'the-group-by-field',
aggName: 'the-group-by-label',
aggName: 'the-group-by-agg-name',
dropDownName: 'the-group-by-drop-down-name',
};
const props = {
item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ describe('Data Frame: <AggListForm />', () => {
const item: PivotAggsConfig = {
agg: PIVOT_SUPPORTED_AGGS.AVG,
field: 'the-field',
aggName: 'the-form-row-label',
aggName: 'the-group-by-agg-name',
dropDownName: 'the-group-by-drop-down-name',
};
const props: ListProps = {
list: { 'the-agg': item },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ describe('Data Frame: <AggListSummary />', () => {
const item: PivotAggsConfig = {
agg: PIVOT_SUPPORTED_AGGS.AVG,
field: 'the-field',
aggName: 'the-form-row-label',
aggName: 'the-group-by-agg-name',
dropDownName: 'the-group-by-drop-down-name',
};
const props: AggListSummaryProps = {
list: { 'the-agg': item },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ describe('Data Frame: Aggregation <PopoverForm />', () => {
test('Minimal initialization', () => {
const defaultData: PivotAggsConfig = {
agg: PIVOT_SUPPORTED_AGGS.CARDINALITY,
aggName: 'the-agg-name',
aggName: 'the-group-by-agg-name',
dropDownName: 'the-group-by-drop-down-name',
field: 'the-field',
};
const otherAggNames: AggName[] = [];
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,75 @@ import { getPivotPreviewDevConsoleStatement, getPivotDropdownOptions } from './c

describe('Data Frame: Define Pivot Common', () => {
test('getPivotDropdownOptions()', () => {
// The field name includes the characters []> which cannot be used for aggregation names.
// The test results verifies that the characters should still be present in field and dropDownName values,
// but should be stripped for aggName values.
const indexPattern: StaticIndexPattern = {
title: 'the-index-pattern-title',
fields: [{ name: 'the-field', type: 'number', aggregatable: true, searchable: true }],
fields: [{ name: 'the-f[i]e>ld', type: 'number', aggregatable: true, searchable: true }],
};

const options = getPivotDropdownOptions(indexPattern);

expect(options).toEqual({
aggOptions: [
{
label: 'the-field',
label: 'the-f[i]e>ld',
options: [
{ label: 'avg(the-field)' },
{ label: 'cardinality(the-field)' },
{ label: 'max(the-field)' },
{ label: 'min(the-field)' },
{ label: 'sum(the-field)' },
{ label: 'value_count(the-field)' },
{ label: 'avg(the-f[i]e>ld)' },
{ label: 'cardinality(the-f[i]e>ld)' },
{ label: 'max(the-f[i]e>ld)' },
{ label: 'min(the-f[i]e>ld)' },
{ label: 'sum(the-f[i]e>ld)' },
{ label: 'value_count(the-f[i]e>ld)' },
],
},
],
aggOptionsData: {
'avg(the-field)': { agg: 'avg', field: 'the-field', aggName: 'avg(the-field)' },
'cardinality(the-field)': {
'avg(the-f[i]e>ld)': {
agg: 'avg',
field: 'the-f[i]e>ld',
aggName: 'the-field.avg',
dropDownName: 'avg(the-f[i]e>ld)',
},
'cardinality(the-f[i]e>ld)': {
agg: 'cardinality',
field: 'the-field',
aggName: 'cardinality(the-field)',
field: 'the-f[i]e>ld',
aggName: 'the-field.cardinality',
dropDownName: 'cardinality(the-f[i]e>ld)',
},
'max(the-f[i]e>ld)': {
agg: 'max',
field: 'the-f[i]e>ld',
aggName: 'the-field.max',
dropDownName: 'max(the-f[i]e>ld)',
},
'min(the-f[i]e>ld)': {
agg: 'min',
field: 'the-f[i]e>ld',
aggName: 'the-field.min',
dropDownName: 'min(the-f[i]e>ld)',
},
'sum(the-f[i]e>ld)': {
agg: 'sum',
field: 'the-f[i]e>ld',
aggName: 'the-field.sum',
dropDownName: 'sum(the-f[i]e>ld)',
},
'max(the-field)': { agg: 'max', field: 'the-field', aggName: 'max(the-field)' },
'min(the-field)': { agg: 'min', field: 'the-field', aggName: 'min(the-field)' },
'sum(the-field)': { agg: 'sum', field: 'the-field', aggName: 'sum(the-field)' },
'value_count(the-field)': {
'value_count(the-f[i]e>ld)': {
agg: 'value_count',
field: 'the-field',
aggName: 'value_count(the-field)',
field: 'the-f[i]e>ld',
aggName: 'the-field.value_count',
dropDownName: 'value_count(the-f[i]e>ld)',
},
},
groupByOptions: [{ label: 'histogram(the-field)' }],
groupByOptions: [{ label: 'histogram(the-f[i]e>ld)' }],
groupByOptionsData: {
'histogram(the-field)': {
'histogram(the-f[i]e>ld)': {
agg: 'histogram',
field: 'the-field',
aggName: 'histogram(the-field)',
field: 'the-f[i]e>ld',
aggName: 'the-field',
dropDownName: 'histogram(the-f[i]e>ld)',
interval: '10',
},
},
Expand All @@ -78,12 +104,14 @@ describe('Data Frame: Define Pivot Common', () => {
const groupBy: PivotGroupByConfig = {
agg: PIVOT_SUPPORTED_GROUP_BY_AGGS.TERMS,
field: 'the-group-by-field',
aggName: 'the-group-by-label',
aggName: 'the-group-by-agg-name',
dropDownName: 'the-group-by-drop-down-name',
};
const agg: PivotAggsConfig = {
agg: PIVOT_SUPPORTED_AGGS.AVG,
field: 'the-agg-field',
aggName: 'the-agg-label',
aggName: 'the-agg-agg-name',
dropDownName: 'the-agg-drop-down-name',
};
const request = getDataFramePreviewRequest('the-index-pattern-title', query, [groupBy], [agg]);
const pivotPreviewDevConsoleStatement = getPivotPreviewDevConsoleStatement(request);
Expand All @@ -101,14 +129,14 @@ describe('Data Frame: Define Pivot Common', () => {
},
"pivot": {
"group_by": {
"the-group-by-label": {
"the-group-by-agg-name": {
"terms": {
"field": "the-group-by-field"
}
}
},
"aggregations": {
"the-agg-label": {
"the-agg-agg-name": {
"avg": {
"field": "the-agg-field"
}
Expand Down