Skip to content

Commit be9accf

Browse files
committed
conflicts
1 parent 0e765f2 commit be9accf

File tree

24 files changed

+1683
-280
lines changed

24 files changed

+1683
-280
lines changed

x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const initialState: IndexPatternPrivateState = {
8484
id: '1',
8585
title: 'idx1',
8686
timeFieldName: 'timestamp',
87+
hasRestrictions: false,
8788
fields: [
8889
{
8990
name: 'timestamp',
@@ -134,6 +135,7 @@ const initialState: IndexPatternPrivateState = {
134135
id: '2',
135136
title: 'idx2',
136137
timeFieldName: 'timestamp',
138+
hasRestrictions: true,
137139
fields: [
138140
{
139141
name: 'timestamp',
@@ -191,6 +193,7 @@ const initialState: IndexPatternPrivateState = {
191193
id: '3',
192194
title: 'idx3',
193195
timeFieldName: 'timestamp',
196+
hasRestrictions: false,
194197
fields: [
195198
{
196199
name: 'timestamp',
@@ -322,8 +325,20 @@ describe('IndexPattern Data Panel', () => {
322325
isFirstExistenceFetch: false,
323326
currentIndexPatternId: 'a',
324327
indexPatterns: {
325-
a: { id: 'a', title: 'aaa', timeFieldName: 'atime', fields: [] },
326-
b: { id: 'b', title: 'bbb', timeFieldName: 'btime', fields: [] },
328+
a: {
329+
id: 'a',
330+
title: 'aaa',
331+
timeFieldName: 'atime',
332+
fields: [],
333+
hasRestrictions: false,
334+
},
335+
b: {
336+
id: 'b',
337+
title: 'bbb',
338+
timeFieldName: 'btime',
339+
fields: [],
340+
hasRestrictions: false,
341+
},
327342
},
328343
layers: {
329344
1: {

x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
599599
Math.max(PAGINATION_SIZE, Math.min(pageSize * 1.5, displayedFieldLength))
600600
);
601601
}}
602-
showExistenceFetchError={fieldInfoUnavailable}
602+
showExistenceFetchError={existenceFetchFailed}
603603
renderCallout={
604604
<NoFieldsCallout
605605
isAffectedByGlobalFilter={!!filters.length}

x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const expectedIndexPatterns = {
4242
title: 'my-fake-index-pattern',
4343
timeFieldName: 'timestamp',
4444
hasExistence: true,
45+
hasRestrictions: false,
4546
fields: [
4647
{
4748
name: 'timestamp',
@@ -1256,6 +1257,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
12561257
foo: {
12571258
id: 'foo',
12581259
title: 'Foo pattern',
1260+
hasRestrictions: false,
12591261
fields: [
12601262
{
12611263
aggregatable: true,

x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const expectedIndexPatterns = {
2121
id: '1',
2222
title: 'my-fake-index-pattern',
2323
timeFieldName: 'timestamp',
24+
hasRestrictions: false,
2425
fields: [
2526
{
2627
name: 'timestamp',
@@ -70,6 +71,7 @@ const expectedIndexPatterns = {
7071
id: '2',
7172
title: 'my-fake-restricted-pattern',
7273
timeFieldName: 'timestamp',
74+
hasRestrictions: true,
7375
fields: [
7476
{
7577
name: 'timestamp',

x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const expectedIndexPatterns = {
2020
id: '1',
2121
title: 'my-fake-index-pattern',
2222
timeFieldName: 'timestamp',
23+
hasRestrictions: false,
2324
fields: [
2425
{
2526
name: 'timestamp',
@@ -68,6 +69,7 @@ const expectedIndexPatterns = {
6869
2: {
6970
id: '2',
7071
title: 'my-fake-restricted-pattern',
72+
hasRestrictions: true,
7173
timeFieldName: 'timestamp',
7274
fields: [
7375
{
@@ -322,6 +324,7 @@ describe('IndexPattern Data Source suggestions', () => {
322324
1: {
323325
id: '1',
324326
title: 'no timefield',
327+
hasRestrictions: false,
325328
fields: [
326329
{
327330
name: 'bytes',
@@ -532,6 +535,7 @@ describe('IndexPattern Data Source suggestions', () => {
532535
1: {
533536
id: '1',
534537
title: 'no timefield',
538+
hasRestrictions: false,
535539
fields: [
536540
{
537541
name: 'bytes',
@@ -1350,6 +1354,7 @@ describe('IndexPattern Data Source suggestions', () => {
13501354
1: {
13511355
id: '1',
13521356
title: 'my-fake-index-pattern',
1357+
hasRestrictions: false,
13531358
fields: [
13541359
{
13551360
name: 'field1',
@@ -1493,6 +1498,7 @@ describe('IndexPattern Data Source suggestions', () => {
14931498
1: {
14941499
id: '1',
14951500
title: 'my-fake-index-pattern',
1501+
hasRestrictions: false,
14961502
fields: [
14971503
{
14981504
name: 'field1',
@@ -1555,6 +1561,7 @@ describe('IndexPattern Data Source suggestions', () => {
15551561
1: {
15561562
id: '1',
15571563
title: 'my-fake-index-pattern',
1564+
hasRestrictions: false,
15581565
fields: [
15591566
{
15601567
name: 'field1',

x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const initialState: IndexPatternPrivateState = {
6262
id: '1',
6363
title: 'my-fake-index-pattern',
6464
timeFieldName: 'timestamp',
65+
hasRestrictions: false,
6566
fields: [
6667
{
6768
name: 'timestamp',
@@ -103,6 +104,7 @@ const initialState: IndexPatternPrivateState = {
103104
'2': {
104105
id: '2',
105106
title: 'my-fake-restricted-pattern',
107+
hasRestrictions: true,
106108
timeFieldName: 'timestamp',
107109
fields: [
108110
{
@@ -160,6 +162,7 @@ const initialState: IndexPatternPrivateState = {
160162
id: '3',
161163
title: 'my-compatible-pattern',
162164
timeFieldName: 'timestamp',
165+
hasRestrictions: false,
163166
fields: [
164167
{
165168
name: 'timestamp',

x-pack/plugins/lens/public/indexpattern_datasource/loader.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const indexPattern1 = ({
4040
id: '1',
4141
title: 'my-fake-index-pattern',
4242
timeFieldName: 'timestamp',
43+
hasRestrictions: false,
4344
fields: [
4445
{
4546
name: 'timestamp',
@@ -105,6 +106,7 @@ const indexPattern2 = ({
105106
id: '2',
106107
title: 'my-fake-restricted-pattern',
107108
timeFieldName: 'timestamp',
109+
hasRestrictions: true,
108110
fields: [
109111
{
110112
name: 'timestamp',
@@ -733,9 +735,9 @@ describe('loader', () => {
733735
dateRange: { fromDate: '1900-01-01', toDate: '2000-01-01' },
734736
fetchJson,
735737
indexPatterns: [
736-
{ id: '1', title: '1', fields: [] },
737-
{ id: '2', title: '1', fields: [] },
738-
{ id: '3', title: '1', fields: [] },
738+
{ id: '1', title: '1', fields: [], hasRestrictions: false },
739+
{ id: '2', title: '1', fields: [], hasRestrictions: false },
740+
{ id: '3', title: '1', fields: [], hasRestrictions: false },
739741
],
740742
setState,
741743
dslQuery,
@@ -783,9 +785,9 @@ describe('loader', () => {
783785
dateRange: { fromDate: '1900-01-01', toDate: '2000-01-01' },
784786
fetchJson,
785787
indexPatterns: [
786-
{ id: '1', title: '1', fields: [] },
787-
{ id: '2', title: '1', fields: [] },
788-
{ id: 'c', title: '1', fields: [] },
788+
{ id: '1', title: '1', fields: [], hasRestrictions: false },
789+
{ id: '2', title: '1', fields: [], hasRestrictions: false },
790+
{ id: 'c', title: '1', fields: [], hasRestrictions: false },
789791
],
790792
setState,
791793
dslQuery,
@@ -817,6 +819,7 @@ describe('loader', () => {
817819
{
818820
id: '1',
819821
title: '1',
822+
hasRestrictions: false,
820823
fields: [{ name: 'field1' }, { name: 'field2' }] as IndexPatternField[],
821824
},
822825
],

x-pack/plugins/lens/public/indexpattern_datasource/loader.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export async function loadIndexPatterns({
9191
timeFieldName,
9292
fieldFormatMap,
9393
fields: newFields,
94-
hasRestrictions: !!typeMeta?.aggs
94+
hasRestrictions: !!typeMeta?.aggs,
9595
};
9696

9797
return {
@@ -410,59 +410,3 @@ function isSingleEmptyLayer(layerMap: IndexPatternPrivateState['layers']) {
410410
const layers = Object.values(layerMap);
411411
return layers.length === 1 && layers[0].columnOrder.length === 0;
412412
}
413-
<<<<<<< HEAD
414-
=======
415-
416-
function fromSavedObject(
417-
savedObject: SimpleSavedObject<SavedIndexPatternAttributes>
418-
): IndexPattern {
419-
const { id, attributes, type } = savedObject;
420-
const indexPattern = {
421-
...attributes,
422-
id,
423-
type,
424-
title: attributes.title,
425-
fields: (JSON.parse(attributes.fields) as IFieldType[])
426-
.filter(
427-
(field) =>
428-
!indexPatternsUtils.isNestedField(field) && (!!field.aggregatable || !!field.scripted)
429-
)
430-
.concat(documentField) as IndexPatternField[],
431-
typeMeta: attributes.typeMeta
432-
? (JSON.parse(attributes.typeMeta) as IndexPatternTypeMeta)
433-
: undefined,
434-
fieldFormatMap: attributes.fieldFormatMap ? JSON.parse(attributes.fieldFormatMap) : undefined,
435-
};
436-
437-
const { typeMeta } = indexPattern;
438-
if (!typeMeta) {
439-
return { ...indexPattern, hasRestrictions: false };
440-
}
441-
442-
const newFields = [...(indexPattern.fields as IndexPatternField[])];
443-
444-
if (typeMeta.aggs) {
445-
const aggs = Object.keys(typeMeta.aggs);
446-
newFields.forEach((field, index) => {
447-
const restrictionsObj: IndexPatternField['aggregationRestrictions'] = {};
448-
aggs.forEach((agg) => {
449-
const restriction = typeMeta.aggs && typeMeta.aggs[agg] && typeMeta.aggs[agg][field.name];
450-
if (restriction) {
451-
restrictionsObj[agg] = restriction;
452-
}
453-
});
454-
if (Object.keys(restrictionsObj).length) {
455-
newFields[index] = { ...field, aggregationRestrictions: restrictionsObj };
456-
}
457-
});
458-
}
459-
460-
return {
461-
id: indexPattern.id,
462-
title: indexPattern.title,
463-
timeFieldName: indexPattern.timeFieldName || undefined,
464-
fields: newFields,
465-
hasRestrictions: true,
466-
};
467-
}
468-
>>>>>>> fix some rollup related bugs

x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const createMockedIndexPattern = (): IndexPattern => ({
1111
id: '1',
1212
title: 'my-fake-index-pattern',
1313
timeFieldName: 'timestamp',
14+
hasRestrictions: false,
1415
fields: [
1516
{
1617
name: 'timestamp',
@@ -70,6 +71,7 @@ export const createMockedRestrictedIndexPattern = () => ({
7071
id: '2',
7172
title: 'my-fake-restricted-pattern',
7273
timeFieldName: 'timestamp',
74+
hasRestrictions: true,
7375
fields: [
7476
{
7577
name: 'timestamp',

x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('date_histogram', () => {
5555
id: '1',
5656
title: 'Mock Indexpattern',
5757
timeFieldName: 'timestamp',
58+
hasRestrictions: false,
5859
fields: [
5960
{
6061
name: 'timestamp',
@@ -69,6 +70,7 @@ describe('date_histogram', () => {
6970
2: {
7071
id: '2',
7172
title: 'Mock Indexpattern 2',
73+
hasRestrictions: false,
7274
fields: [
7375
{
7476
name: 'other_timestamp',
@@ -229,13 +231,49 @@ describe('date_histogram', () => {
229231
it('should reflect params correctly', () => {
230232
const esAggsConfig = dateHistogramOperation.toEsAggsConfig(
231233
state.layers.first.columns.col1 as DateHistogramIndexPatternColumn,
232-
'col1'
234+
'col1',
235+
state.indexPatterns['1']
233236
);
234237
expect(esAggsConfig).toEqual(
235238
expect.objectContaining({
236239
params: expect.objectContaining({
237240
interval: '42w',
238241
field: 'timestamp',
242+
useNormalizedEsInterval: true,
243+
}),
244+
})
245+
);
246+
});
247+
248+
it('should not use normalized es interval for rollups', () => {
249+
const esAggsConfig = dateHistogramOperation.toEsAggsConfig(
250+
state.layers.first.columns.col1 as DateHistogramIndexPatternColumn,
251+
'col1',
252+
{
253+
...state.indexPatterns['1'],
254+
fields: [
255+
{
256+
name: 'timestamp',
257+
aggregatable: true,
258+
searchable: true,
259+
type: 'date',
260+
aggregationRestrictions: {
261+
date_histogram: {
262+
agg: 'date_histogram',
263+
time_zone: 'UTC',
264+
calendar_interval: '42w',
265+
},
266+
},
267+
},
268+
],
269+
}
270+
);
271+
expect(esAggsConfig).toEqual(
272+
expect.objectContaining({
273+
params: expect.objectContaining({
274+
interval: '42w',
275+
field: 'timestamp',
276+
useNormalizedEsInterval: false,
239277
}),
240278
})
241279
);
@@ -300,6 +338,7 @@ describe('date_histogram', () => {
300338
{
301339
title: '',
302340
id: '',
341+
hasRestrictions: true,
303342
fields: [
304343
{
305344
name: 'dateField',
@@ -343,6 +382,7 @@ describe('date_histogram', () => {
343382
{
344383
title: '',
345384
id: '',
385+
hasRestrictions: false,
346386
fields: [
347387
{
348388
name: 'dateField',

0 commit comments

Comments
 (0)