Skip to content

Commit

Permalink
fix formula generate error (#134434)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Jun 15, 2022
1 parent 6c1b616 commit 39d84bc
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -194,6 +194,30 @@ describe('formula', () => {
});
});

it("should start with an empty formula if previous operation can't be converted", () => {
expect(
formulaOperation.buildColumn({
previousColumn: {
...layer.columns.col1,
dataType: 'date',
filter: { language: 'kuery', query: 'ABC: DEF' },
},
layer,
indexPattern,
})
).toEqual({
label: 'Formula',
dataType: 'number',
operationType: 'formula',
isBucketed: false,
filter: undefined,
timeScale: undefined,
scale: 'ratio',
params: {},
references: [],
});
});

it('it should move over explicit format param if set', () => {
expect(
formulaOperation.buildColumn({
Original file line number Diff line number Diff line change
@@ -55,6 +55,9 @@ export function generateFormula(
} else {
if (previousColumn && 'sourceField' in previousColumn && previousColumn.dataType === 'number') {
previousFormula += `${previousColumn.operationType}(${getSafeFieldName(previousColumn)}`;
} else {
// couldn't find formula function to call, exit early because adding args is going to fail anyway
return '';
}
}
const formulaNamedArgs = extractParamsForFormula(previousColumn, operationDefinitionMap);

0 comments on commit 39d84bc

Please sign in to comment.