forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[data.search.aggs]: Expression functions for bucket agg types (elasti…
…c#64772) * [data.search.aggs]: Expression functions for bucket agg types - ranges agg types + significant terms * new portion of changes * add geo_tile_fn * add geo_hash_fn * Update src/plugins/data/public/search/aggs/buckets/filter_fn.ts Co-authored-by: Luke Elmers <[email protected]> * Update src/plugins/data/public/search/aggs/buckets/geo_tile_fn.ts Co-authored-by: Luke Elmers <[email protected]> * Update src/plugins/data/public/search/aggs/buckets/geo_hash_fn.ts Co-authored-by: Luke Elmers <[email protected]> * Update src/plugins/data/public/search/aggs/buckets/ip_range_fn.ts Co-authored-by: Luke Elmers <[email protected]> * Update src/plugins/data/public/search/aggs/buckets/geo_hash_fn.ts Co-authored-by: Luke Elmers <[email protected]> * Update src/plugins/data/public/search/aggs/buckets/geo_hash_fn.ts Co-authored-by: Luke Elmers <[email protected]> * Update src/plugins/data/public/search/aggs/buckets/geo_hash_fn.ts Co-authored-by: Luke Elmers <[email protected]> * create BaseAggParams * add filters_fn * add histogram / date_histogram expression functions * cleanup * terms - order should be optional * add custom label params Co-authored-by: Luke Elmers <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
ea04828
commit dfac2b8
Showing
43 changed files
with
2,551 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
src/plugins/data/public/search/aggs/buckets/date_histogram_fn.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { functionWrapper } from '../test_helpers'; | ||
import { aggDateHistogram } from './date_histogram_fn'; | ||
|
||
describe('agg_expression_functions', () => { | ||
describe('aggDateHistogram', () => { | ||
const fn = functionWrapper(aggDateHistogram()); | ||
|
||
test('fills in defaults when only required args are provided', () => { | ||
const actual = fn({}); | ||
expect(actual).toMatchInlineSnapshot(` | ||
Object { | ||
"type": "agg_type", | ||
"value": Object { | ||
"enabled": true, | ||
"id": undefined, | ||
"params": Object { | ||
"customLabel": undefined, | ||
"drop_partials": undefined, | ||
"extended_bounds": undefined, | ||
"field": undefined, | ||
"format": undefined, | ||
"interval": undefined, | ||
"json": undefined, | ||
"min_doc_count": undefined, | ||
"scaleMetricValues": undefined, | ||
"timeRange": undefined, | ||
"time_zone": undefined, | ||
"useNormalizedEsInterval": undefined, | ||
}, | ||
"schema": undefined, | ||
"type": "date_histogram", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
test('includes optional params when they are provided', () => { | ||
const actual = fn({ | ||
field: 'field', | ||
timeRange: JSON.stringify({ | ||
from: 'from', | ||
to: 'to', | ||
}), | ||
useNormalizedEsInterval: true, | ||
scaleMetricValues: true, | ||
interval: 'interval', | ||
time_zone: 'time_zone', | ||
drop_partials: false, | ||
format: 'format', | ||
min_doc_count: 1, | ||
extended_bounds: JSON.stringify({ | ||
min: 1, | ||
max: 2, | ||
}), | ||
}); | ||
|
||
expect(actual.value).toMatchInlineSnapshot(` | ||
Object { | ||
"enabled": true, | ||
"id": undefined, | ||
"params": Object { | ||
"customLabel": undefined, | ||
"drop_partials": false, | ||
"extended_bounds": Object { | ||
"max": 2, | ||
"min": 1, | ||
}, | ||
"field": "field", | ||
"format": "format", | ||
"interval": "interval", | ||
"json": undefined, | ||
"min_doc_count": 1, | ||
"scaleMetricValues": true, | ||
"timeRange": Object { | ||
"from": "from", | ||
"to": "to", | ||
}, | ||
"time_zone": "time_zone", | ||
"useNormalizedEsInterval": true, | ||
}, | ||
"schema": undefined, | ||
"type": "date_histogram", | ||
} | ||
`); | ||
}); | ||
|
||
test('correctly parses json string argument', () => { | ||
const actual = fn({ | ||
json: '{ "foo": true }', | ||
}); | ||
|
||
expect(actual.value.params.json).toEqual({ foo: true }); | ||
|
||
expect(() => { | ||
fn({ | ||
json: '/// intentionally malformed json ///', | ||
}); | ||
}).toThrowErrorMatchingInlineSnapshot(`"Unable to parse json argument string"`); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.