UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

46 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ODD = void 0; const constants_1 = require("../constants"); const utils_1 = require("../utils"); /** * `ODD` Returns a number rounded to the next greatest odd integer. */ exports.ODD = { identifier: 'ODD', parameters: [ { identifier: 'VALUE', optional: false, expectedPrimitive: constants_1.AST_PRIMITIVES.NUMBER, validator: [utils_1.isNumberParam], }, ], transpiler: { elasticsearch, snowflake, redshift, postgresql, }, primitiveResult: constants_1.AST_PRIMITIVES.NUMBER, }; function elasticsearch(value) { return `ODD(${value})`; } function SQL(value) { return ` (((CASE WHEN ${value} IS NULL THEN NULL ELSE CEIL((ABS(${value}) + 1 ) / 2.0) END) * 2 - 1) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`.trim(); } function snowflake(value) { return SQL(value); } function redshift(value) { return SQL(value); } function postgresql(value) { return SQL(value); } //# sourceMappingURL=odd.js.map