Skip to content

Commit

Permalink
Fix handling of null values in groupby
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdemartini committed Sep 29, 2020
1 parent 3bac4c9 commit ed29251
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/data-mate/src/aggregation-frame/AggregationFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ export class AggregationFrame<T extends Record<string, any>> {
row[field] = res.value;
}

if (!key && keyAggs.size) continue;

for (const [field, col] of otherCols) {
row[field] = col.vector.get(i);
}
Expand Down
50 changes: 47 additions & 3 deletions packages/data-mate/test/aggregation-frame-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ describe('AggregationFrame', () => {
scores: [1, 0, 0],
date: '2020-07-15T16:39:11.195Z', // minus two months
},
{
name: 'Nick',
age: null as any,
gender: null as any,
scores: [1, 1, 10, null as any],
date: '2018-01-15T10:39:11.195Z', // minus 2 years
},
]);
});

Expand Down Expand Up @@ -123,7 +130,7 @@ describe('AggregationFrame', () => {
name: 'Billy',
age: 64,
gender: 'M',
scores: 165,
scores: 177,
date: '2020-09-15T17:39:11.195Z'
}
]);
Expand Down Expand Up @@ -182,7 +189,7 @@ describe('AggregationFrame', () => {
name: 'Billy',
age: 64,
gender: 'M',
scores: 7.857142857142857,
scores: 7.375,
date: '2020-09-15T17:39:11.195Z'
}
]);
Expand Down Expand Up @@ -338,7 +345,7 @@ describe('AggregationFrame', () => {
);
expect(resultFrame.toJSON()).toEqual([
{
name: 7,
name: 8,
age: 64,
gender: 'M',
scores: [4, 9, 3],
Expand Down Expand Up @@ -397,6 +404,11 @@ describe('AggregationFrame', () => {
gender: 'F',
scores: [1, 0, 0],
date: '2019-09-15T17:39:11.195Z',
},
{
name: 'Nick',
scores: [1, 1, 10, null],
date: '2018-01-15T10:39:11.195Z',
}
]);
});
Expand Down Expand Up @@ -448,6 +460,11 @@ describe('AggregationFrame', () => {
gender: 'F',
scores: [1, 0, 0],
date: '2019-09-15T17:39:11.195Z',
},
{
name: 1,
scores: [1, 1, 10, null],
date: '2018-01-15T10:39:11.195Z',
}
]);
});
Expand Down Expand Up @@ -501,6 +518,11 @@ describe('AggregationFrame', () => {
gender: 'F',
scores: [1, 0, 0],
date: '2019-09-15T17:39:11.195Z',
},
{
name: 'Nick',
scores: [1, 1, 10, null],
date: '2018-01-15T10:39:11.195Z',
}
]);
});
Expand Down Expand Up @@ -554,6 +576,11 @@ describe('AggregationFrame', () => {
gender: 'M',
scores: [1, 0, 0],
date: '2020-07-15T16:39:11.195Z'
},
{
name: 1,
scores: [1, 1, 10, null],
date: '2018-01-15T10:39:11.195Z',
}
]);
});
Expand Down Expand Up @@ -597,6 +624,12 @@ describe('AggregationFrame', () => {
gender: 'M',
scores: [1, 0, 0],
date: '2020-07-15T16:39:11.195Z'
},
{
name: 'Nick',
count: 1,
scores: [1, 1, 10, null],
date: '2018-01-15T10:39:11.195Z',
}
]);
});
Expand Down Expand Up @@ -629,6 +662,11 @@ describe('AggregationFrame', () => {
gender: 'M',
scores: [1, 0, 0],
date: '2020-07-15T16:39:11.195Z'
},
{
name: 1,
scores: [1, 1, 10, null],
date: '2018-01-15T10:39:11.195Z',
}
]);
});
Expand Down Expand Up @@ -656,6 +694,12 @@ describe('AggregationFrame', () => {
gender: 'F',
scores: [1, 0, 0],
date: '2019-09-15T17:39:11.195Z'
},
{
name: 'Nick',
count: 1,
scores: [1, 1, 10, null],
date: '2018-01-15T10:39:11.195Z',
}
]);
});
Expand Down

0 comments on commit ed29251

Please sign in to comment.