@qrvey/formula-lang
Version:
QFormula support for qrvey projects
45 lines • 1.05 kB
JavaScript
import { AST_PRIMITIVES, OPERATION_SCOPE } from '../constants';
import { isNumberParam } from '../utils';
/**
* `ABS` Returns the absolute value of a number.
*/
export const ABS = {
identifier: 'ABS',
operationScope: OPERATION_SCOPE.RAW,
functionScope: [OPERATION_SCOPE.RAW, OPERATION_SCOPE.AGGREGATE],
parameters: [
{
identifier: 'VALUE',
optional: false,
expectedPrimitive: AST_PRIMITIVES.NUMBER,
validator: [isNumberParam],
},
],
transpiler: {
elasticsearch,
snowflake,
redshift,
postgresql,
databricks,
},
primitiveResult: AST_PRIMITIVES.NUMBER,
};
function elasticsearch(value) {
return `Math.abs(${value})`;
}
function SQL(value) {
return `ABS(${value})`;
}
function snowflake(value) {
return SQL(value);
}
function redshift(value) {
return SQL(value);
}
function postgresql(value) {
return SQL(value);
}
function databricks(value) {
return SQL(value);
}
//# sourceMappingURL=abs.js.map