@qrvey/formula-lang 2.0.1-rc.498 → 2.0.1-rc.502
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/functions/round.js +9 -4
- package/dist/cjs/functions/round.js.map +1 -1
- package/dist/cjs/functions/rounddown.js +8 -3
- package/dist/cjs/functions/rounddown.js.map +1 -1
- package/dist/cjs/functions/roundup.js +8 -3
- package/dist/cjs/functions/roundup.js.map +1 -1
- package/dist/cjs/utils/elasticsearch/scripts.d.ts +2 -2
- package/dist/cjs/utils/elasticsearch/scripts.js +8 -6
- package/dist/cjs/utils/elasticsearch/scripts.js.map +1 -1
- package/dist/module/functions/round.js +9 -4
- package/dist/module/functions/round.js.map +1 -1
- package/dist/module/functions/rounddown.js +8 -3
- package/dist/module/functions/rounddown.js.map +1 -1
- package/dist/module/functions/roundup.js +8 -3
- package/dist/module/functions/roundup.js.map +1 -1
- package/dist/module/utils/elasticsearch/scripts.d.ts +2 -2
- package/dist/module/utils/elasticsearch/scripts.js +7 -5
- package/dist/module/utils/elasticsearch/scripts.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.ROUND = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const isBetweenInclusiveRange_1 = require("../utils/isBetweenInclusiveRange");
|
|
7
|
+
const isInteger_1 = require("../utils/isInteger");
|
|
7
8
|
/**
|
|
8
9
|
* `ROUND` Returns a number rounded to the next greatest even integer.
|
|
9
10
|
*/
|
|
@@ -18,7 +19,11 @@ exports.ROUND = {
|
|
|
18
19
|
{
|
|
19
20
|
identifier: 'DIGITS',
|
|
20
21
|
optional: false,
|
|
21
|
-
validator: [
|
|
22
|
+
validator: [
|
|
23
|
+
utils_1.isNumberParam,
|
|
24
|
+
(0, isBetweenInclusiveRange_1.isBetweenInclusiveRange)(0, 10),
|
|
25
|
+
isInteger_1.isInteger,
|
|
26
|
+
],
|
|
22
27
|
},
|
|
23
28
|
],
|
|
24
29
|
transpiler: {
|
|
@@ -30,15 +35,15 @@ exports.ROUND = {
|
|
|
30
35
|
primitiveResult: constants_1.AST_PRIMITIVES.NUMBER,
|
|
31
36
|
};
|
|
32
37
|
function elasticsearch(value, digits) {
|
|
33
|
-
return `ROUND(${value}, ${digits})`;
|
|
38
|
+
return `ROUND(${value}, ROUNDDOWN(${digits}, 0))`;
|
|
34
39
|
}
|
|
35
40
|
function SQL(value, digits) {
|
|
36
|
-
return `ROUND(${value}, (CASE
|
|
41
|
+
return `ROUND(${value}, TRUNC(CASE
|
|
37
42
|
WHEN ${digits} IS NULL THEN NULL
|
|
38
43
|
WHEN ${digits} > 10 THEN 10
|
|
39
44
|
WHEN ${digits} < 0 THEN 0
|
|
40
45
|
ELSE ${digits}
|
|
41
|
-
END))`;
|
|
46
|
+
END)::INTEGER)`;
|
|
42
47
|
}
|
|
43
48
|
function snowflake(value, digits) {
|
|
44
49
|
return SQL(value, digits);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.js","sourceRoot":"","sources":["../../../src/functions/round.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,8EAA2E;
|
|
1
|
+
{"version":3,"file":"round.js","sourceRoot":"","sources":["../../../src/functions/round.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,8EAA2E;AAC3E,kDAA+C;AAE/C;;GAEG;AACU,QAAA,KAAK,GAAuB;IACrC,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE;gBACP,qBAAa;gBACb,IAAA,iDAAuB,EAAC,CAAC,EAAE,EAAE,CAAC;gBAC9B,qBAAS;aACZ;SACJ;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,0BAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa,EAAE,MAAc;IAChD,OAAO,SAAS,KAAK,eAAe,MAAM,OAAO,CAAC;AACtD,CAAC;AAED,SAAS,GAAG,CAAC,KAAa,EAAE,MAAc;IACtC,OAAO,SAAS,KAAK;eACV,MAAM;eACN,MAAM;eACN,MAAM;eACN,MAAM;mBACF,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,MAAc;IAC5C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,MAAc;IAC3C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.ROUNDDOWN = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const isBetweenInclusiveRange_1 = require("../utils/isBetweenInclusiveRange");
|
|
7
|
+
const isInteger_1 = require("../utils/isInteger");
|
|
7
8
|
/**
|
|
8
9
|
* `ROUNDDOWN` Returns a number rounded to the next greatest even integer.
|
|
9
10
|
*/
|
|
@@ -18,7 +19,11 @@ exports.ROUNDDOWN = {
|
|
|
18
19
|
{
|
|
19
20
|
identifier: 'DIGITS',
|
|
20
21
|
optional: false,
|
|
21
|
-
validator: [
|
|
22
|
+
validator: [
|
|
23
|
+
utils_1.isNumberParam,
|
|
24
|
+
(0, isBetweenInclusiveRange_1.isBetweenInclusiveRange)(0, 10),
|
|
25
|
+
isInteger_1.isInteger,
|
|
26
|
+
],
|
|
22
27
|
},
|
|
23
28
|
],
|
|
24
29
|
transpiler: {
|
|
@@ -30,14 +35,14 @@ exports.ROUNDDOWN = {
|
|
|
30
35
|
primitiveResult: constants_1.AST_PRIMITIVES.NUMBER,
|
|
31
36
|
};
|
|
32
37
|
function elasticsearch(value, digits) {
|
|
33
|
-
return `ROUNDDOWN(${value}, ${digits})`;
|
|
38
|
+
return `ROUNDDOWN(${value}, ROUNDDOWN(${digits}, 0))`;
|
|
34
39
|
}
|
|
35
40
|
function SQL(value, digits) {
|
|
36
41
|
return `((CASE
|
|
37
42
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
38
43
|
WHEN ${digits} > 10 THEN FLOOR(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
39
44
|
WHEN ${digits} < 0 THEN FLOOR(ABS(${value}))
|
|
40
|
-
ELSE FLOOR(ABS(${value}) * POWER(10, ${digits})) / POWER(10, ${digits})
|
|
45
|
+
ELSE FLOOR(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
41
46
|
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
42
47
|
}
|
|
43
48
|
function snowflake(value, digits) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rounddown.js","sourceRoot":"","sources":["../../../src/functions/rounddown.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,8EAA2E;
|
|
1
|
+
{"version":3,"file":"rounddown.js","sourceRoot":"","sources":["../../../src/functions/rounddown.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,8EAA2E;AAC3E,kDAA+C;AAE/C;;GAEG;AACU,QAAA,SAAS,GAAuB;IACzC,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE;gBACP,qBAAa;gBACb,IAAA,iDAAuB,EAAC,CAAC,EAAE,EAAE,CAAC;gBAC9B,qBAAS;aACZ;SACJ;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,0BAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa,EAAE,MAAc;IAChD,OAAO,aAAa,KAAK,eAAe,MAAM,OAAO,CAAC;AAC1D,CAAC;AAED,SAAS,GAAG,CAAC,KAAa,EAAE,MAAc;IACtC,OAAO;eACI,KAAK,eAAe,MAAM;eAC1B,MAAM,wBAAwB,KAAK;eACnC,MAAM,uBAAuB,KAAK;yBACxB,KAAK,uBAAuB,MAAM,kCAAkC,MAAM;wBAC3E,KAAK,2BAA2B,CAAC;AACzD,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,MAAc;IAC5C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,MAAc;IAC3C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.ROUNDUP = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const isBetweenInclusiveRange_1 = require("../utils/isBetweenInclusiveRange");
|
|
7
|
+
const isInteger_1 = require("../utils/isInteger");
|
|
7
8
|
/**
|
|
8
9
|
* `ROUNDUP` Rounds a number up to a specified number of digits.
|
|
9
10
|
*/
|
|
@@ -18,7 +19,11 @@ exports.ROUNDUP = {
|
|
|
18
19
|
{
|
|
19
20
|
identifier: 'DIGITS',
|
|
20
21
|
optional: false,
|
|
21
|
-
validator: [
|
|
22
|
+
validator: [
|
|
23
|
+
utils_1.isNumberParam,
|
|
24
|
+
(0, isBetweenInclusiveRange_1.isBetweenInclusiveRange)(0, 10),
|
|
25
|
+
isInteger_1.isInteger,
|
|
26
|
+
],
|
|
22
27
|
},
|
|
23
28
|
],
|
|
24
29
|
transpiler: {
|
|
@@ -30,14 +35,14 @@ exports.ROUNDUP = {
|
|
|
30
35
|
primitiveResult: constants_1.AST_PRIMITIVES.NUMBER,
|
|
31
36
|
};
|
|
32
37
|
function elasticsearch(value, digits) {
|
|
33
|
-
return `ROUNDUP(${value}, ${digits})`;
|
|
38
|
+
return `ROUNDUP(${value}, ROUNDDOWN(${digits}, 0))`;
|
|
34
39
|
}
|
|
35
40
|
function SQL(value, digits) {
|
|
36
41
|
return `((CASE
|
|
37
42
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
38
43
|
WHEN ${digits} > 10 THEN CEIL(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
39
44
|
WHEN ${digits} < 0 THEN CEIL(ABS(${value}))
|
|
40
|
-
ELSE CEIL(ABS(${value}) * POWER(10, ${digits})) / POWER(10, ${digits})
|
|
45
|
+
ELSE CEIL(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
41
46
|
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
42
47
|
}
|
|
43
48
|
function snowflake(value, digits) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundup.js","sourceRoot":"","sources":["../../../src/functions/roundup.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,8EAA2E;
|
|
1
|
+
{"version":3,"file":"roundup.js","sourceR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 @@ export declare const evenScript = "def EVEN(def value) {\n if (value == null) r
|
|
|
24
24
|
export declare const logScript = "def LOG(def base, def value) {\n if (base == null || value == null) return null;\n if (base <= 1 || value <= 0) return null;\n return (Math.log(value) / Math.log(base));\n}";
|
|
25
25
|
export declare const oddScript = "def ODD(def value) {\n if (value == null) return null;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n return ((long) Math.ceil((_value + 1)/ 2.0) * 2 - 1) * sign;\n}";
|
|
26
26
|
export declare const powerScript = "def POWER(def value, def numberToRaise) {\n if (value == null || numberToRaise == null) return null;\n if (value == 0 && numberToRaise < 0) return null;\n return Math.pow(value, numberToRaise);\n}";
|
|
27
|
-
export declare const roundScript = "def ROUND(def value, def places) {\n if (value == null || places == null) return null; \n if (places > 10) places = 10;\n if (places < 0) places = 0;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n def scale = Math.pow(10, places);\n return (Math.round(_value * scale) / scale) * sign;\n}";
|
|
28
27
|
export declare const roundDownScript = "def ROUNDDOWN(def value, def places) {\n if (value == null || places == null) return null; \n if (places > 10) places = 10;\n if (places < 0) places = 0;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n def scale = Math.pow(10, places);\n return (Math.floor(_value * scale) / scale) * sign;\n}";
|
|
29
|
-
export declare const
|
|
28
|
+
export declare const roundScript: string;
|
|
29
|
+
export declare const roundUpScript: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roundUpScript = exports.
|
|
3
|
+
exports.roundUpScript = exports.roundScript = exports.roundDownScript = exports.powerScript = exports.oddScript = exports.logScript = exports.evenScript = exports.includeScript = exports.replaceScript = exports.expScript = exports.sqrtScript = exports.lengthScript = exports.leastScript = exports.greatestScript = exports.properScript = exports.isNullScript = exports.getValueScript = exports.dateDif = exports.secondScript = exports.minuteScript = exports.hourScript = exports.yearScript = exports.monthScript = exports.dayScript = exports.subStringScript = exports.dateFormatScript = exports.setTimezoneToColumnDate = exports.toDate = void 0;
|
|
4
4
|
const constants_1 = require("../../constants");
|
|
5
5
|
function toDate(value) {
|
|
6
6
|
return `ZonedDateTime.parse("${value}")`;
|
|
@@ -172,25 +172,27 @@ exports.powerScript = `def POWER(def value, def numberToRaise) {
|
|
|
172
172
|
if (value == 0 && numberToRaise < 0) return null;
|
|
173
173
|
return Math.pow(value, numberToRaise);
|
|
174
174
|
}`;
|
|
175
|
-
exports.
|
|
175
|
+
exports.roundDownScript = `def ROUNDDOWN(def value, def places) {
|
|
176
176
|
if (value == null || places == null) return null;
|
|
177
177
|
if (places > 10) places = 10;
|
|
178
178
|
if (places < 0) places = 0;
|
|
179
179
|
def _value = Math.abs(value);
|
|
180
180
|
def sign = value < 0 ? -1 : 1;
|
|
181
181
|
def scale = Math.pow(10, places);
|
|
182
|
-
return (Math.
|
|
182
|
+
return (Math.floor(_value * scale) / scale) * sign;
|
|
183
183
|
}`;
|
|
184
|
-
exports.
|
|
184
|
+
exports.roundScript = `${exports.roundDownScript}
|
|
185
|
+
def ROUND(def value, def places) {
|
|
185
186
|
if (value == null || places == null) return null;
|
|
186
187
|
if (places > 10) places = 10;
|
|
187
188
|
if (places < 0) places = 0;
|
|
188
189
|
def _value = Math.abs(value);
|
|
189
190
|
def sign = value < 0 ? -1 : 1;
|
|
190
191
|
def scale = Math.pow(10, places);
|
|
191
|
-
return (Math.
|
|
192
|
+
return (Math.round(_value * scale) / scale) * sign;
|
|
192
193
|
}`;
|
|
193
|
-
exports.roundUpScript =
|
|
194
|
+
exports.roundUpScript = `${exports.roundDownScript}
|
|
195
|
+
def ROUNDUP(def value, def places) {
|
|
194
196
|
if (value == null || places == null) return null;
|
|
195
197
|
if (places > 10) places = 10;
|
|
196
198
|
if (places < 0) places = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/elasticsearch/scripts.ts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CAAC,CAAC;IAChC,OAAO,cAAc,WAAW,YAAY,KAAK,KAAK,GAAG,GAAG,CAAC;AACjE,CAAC;AARD,0BAQC;AAEY,QAAA,cAAc,GAAG,yDAAyD,CAAC;AAE3E,QAAA,YAAY,GAAG,iFAAiF,CAAC;AAEjG,QAAA,YAAY,GAAG;;;;;;;;;;;;;;;;;;IAkBxB,CAAC;AAEQ,QAAA,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;EAwB5B,CAAC;AAEU,QAAA,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;EAwBzB,CAAC;AAEU,QAAA,YAAY,GAAG,4DAA4D,CAAC;AAE5E,QAAA,UAAU,GAAG,2EAA2E,CAAC;AAEzF,QAAA,SAAS,GAAG,6DAA6D,CAAC;AAE1E,QAAA,aAAa,GAAG;;;;EAI3B,CAAC;AAEU,QAAA,aAAa,GAAG,oIAAoI,CAAC;AAErJ,QAAA,UAAU,GAAG;;;;;EAKxB,CAAC;AAEU,QAAA,SAAS,GAAG;;;;EAIvB,CAAC;AAEU,QAAA,SAAS,GAAG;;;;;EAKvB,CAAC;AAEU,QAAA,WAAW,GAAG;;;;EAIzB,CAAC;AAEU,QAAA,eAAe,GAAG;;;;;;;;EAQ7B,CAAC;AAEU,QAAA,WAAW,GAAG,GAAG,uBAAe;;;;;;;;;EAS3C,CAAC;AAEU,QAAA,aAAa,GAAG,GAAG,uBAAe;;;;;;;;;EAS7C,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AST_PRIMITIVES } from '../constants';
|
|
2
2
|
import { isNumberParam } from '../utils';
|
|
3
3
|
import { isBetweenInclusiveRange } from '../utils/isBetweenInclusiveRange';
|
|
4
|
+
import { isInteger } from '../utils/isInteger';
|
|
4
5
|
/**
|
|
5
6
|
* `ROUND` Returns a number rounded to the next greatest even integer.
|
|
6
7
|
*/
|
|
@@ -15,7 +16,11 @@ export const ROUND = {
|
|
|
15
16
|
{
|
|
16
17
|
identifier: 'DIGITS',
|
|
17
18
|
optional: false,
|
|
18
|
-
validator: [
|
|
19
|
+
validator: [
|
|
20
|
+
isNumberParam,
|
|
21
|
+
isBetweenInclusiveRange(0, 10),
|
|
22
|
+
isInteger,
|
|
23
|
+
],
|
|
19
24
|
},
|
|
20
25
|
],
|
|
21
26
|
transpiler: {
|
|
@@ -27,15 +32,15 @@ export const ROUND = {
|
|
|
27
32
|
primitiveResult: AST_PRIMITIVES.NUMBER,
|
|
28
33
|
};
|
|
29
34
|
function elasticsearch(value, digits) {
|
|
30
|
-
return `ROUND(${value}, ${digits})`;
|
|
35
|
+
return `ROUND(${value}, ROUNDDOWN(${digits}, 0))`;
|
|
31
36
|
}
|
|
32
37
|
function SQL(value, digits) {
|
|
33
|
-
return `ROUND(${value}, (CASE
|
|
38
|
+
return `ROUND(${value}, TRUNC(CASE
|
|
34
39
|
WHEN ${digits} IS NULL THEN NULL
|
|
35
40
|
WHEN ${digits} > 10 THEN 10
|
|
36
41
|
WHEN ${digits} < 0 THEN 0
|
|
37
42
|
ELSE ${digits}
|
|
38
|
-
END))`;
|
|
43
|
+
END)::INTEGER)`;
|
|
39
44
|
}
|
|
40
45
|
function snowflake(value, digits) {
|
|
41
46
|
return SQL(value, digits);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.js","sourceRoot":"","sources":["../../../src/functions/round.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"round.js","sourceRoot":"","sources":["../../../src/functions/round.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAuB;IACrC,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE;gBACP,aAAa;gBACb,uBAAuB,CAAC,CAAC,EAAE,EAAE,CAAC;gBAC9B,SAAS;aACZ;SACJ;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,cAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa,EAAE,MAAc;IAChD,OAAO,SAAS,KAAK,eAAe,MAAM,OAAO,CAAC;AACtD,CAAC;AAED,SAAS,GAAG,CAAC,KAAa,EAAE,MAAc;IACtC,OAAO,SAAS,KAAK;eACV,MAAM;eACN,MAAM;eACN,MAAM;eACN,MAAM;mBACF,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,MAAc;IAC5C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,MAAc;IAC3C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AST_PRIMITIVES } from '../constants';
|
|
2
2
|
import { isNumberParam } from '../utils';
|
|
3
3
|
import { isBetweenInclusiveRange } from '../utils/isBetweenInclusiveRange';
|
|
4
|
+
import { isInteger } from '../utils/isInteger';
|
|
4
5
|
/**
|
|
5
6
|
* `ROUNDDOWN` Returns a number rounded to the next greatest even integer.
|
|
6
7
|
*/
|
|
@@ -15,7 +16,11 @@ export const ROUNDDOWN = {
|
|
|
15
16
|
{
|
|
16
17
|
identifier: 'DIGITS',
|
|
17
18
|
optional: false,
|
|
18
|
-
validator: [
|
|
19
|
+
validator: [
|
|
20
|
+
isNumberParam,
|
|
21
|
+
isBetweenInclusiveRange(0, 10),
|
|
22
|
+
isInteger,
|
|
23
|
+
],
|
|
19
24
|
},
|
|
20
25
|
],
|
|
21
26
|
transpiler: {
|
|
@@ -27,14 +32,14 @@ export const ROUNDDOWN = {
|
|
|
27
32
|
primitiveResult: AST_PRIMITIVES.NUMBER,
|
|
28
33
|
};
|
|
29
34
|
function elasticsearch(value, digits) {
|
|
30
|
-
return `ROUNDDOWN(${value}, ${digits})`;
|
|
35
|
+
return `ROUNDDOWN(${value}, ROUNDDOWN(${digits}, 0))`;
|
|
31
36
|
}
|
|
32
37
|
function SQL(value, digits) {
|
|
33
38
|
return `((CASE
|
|
34
39
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
35
40
|
WHEN ${digits} > 10 THEN FLOOR(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
36
41
|
WHEN ${digits} < 0 THEN FLOOR(ABS(${value}))
|
|
37
|
-
ELSE FLOOR(ABS(${value}) * POWER(10, ${digits})) / POWER(10, ${digits})
|
|
42
|
+
ELSE FLOOR(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
38
43
|
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
39
44
|
}
|
|
40
45
|
function snowflake(value, digits) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rounddown.js","sourceRoot":"","sources":["../../../src/functions/rounddown.ts"],"names":[],"mappings":"AAAA,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Aa,EAAE,MAAc;IAC5C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,MAAc;IAC3C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AST_PRIMITIVES } from '../constants';
|
|
2
2
|
import { isNumberParam } from '../utils';
|
|
3
3
|
import { isBetweenInclusiveRange } from '../utils/isBetweenInclusiveRange';
|
|
4
|
+
import { isInteger } from '../utils/isInteger';
|
|
4
5
|
/**
|
|
5
6
|
* `ROUNDUP` Rounds a number up to a specified number of digits.
|
|
6
7
|
*/
|
|
@@ -15,7 +16,11 @@ export const ROUNDUP = {
|
|
|
15
16
|
{
|
|
16
17
|
identifier: 'DIGITS',
|
|
17
18
|
optional: false,
|
|
18
|
-
validator: [
|
|
19
|
+
validator: [
|
|
20
|
+
isNumberParam,
|
|
21
|
+
isBetweenInclusiveRange(0, 10),
|
|
22
|
+
isInteger,
|
|
23
|
+
],
|
|
19
24
|
},
|
|
20
25
|
],
|
|
21
26
|
transpiler: {
|
|
@@ -27,14 +32,14 @@ export const ROUNDUP = {
|
|
|
27
32
|
primitiveResult: AST_PRIMITIVES.NUMBER,
|
|
28
33
|
};
|
|
29
34
|
function elasticsearch(value, digits) {
|
|
30
|
-
return `ROUNDUP(${value}, ${digits})`;
|
|
35
|
+
return `ROUNDUP(${value}, ROUNDDOWN(${digits}, 0))`;
|
|
31
36
|
}
|
|
32
37
|
function SQL(value, digits) {
|
|
33
38
|
return `((CASE
|
|
34
39
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
35
40
|
WHEN ${digits} > 10 THEN CEIL(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
36
41
|
WHEN ${digits} < 0 THEN CEIL(ABS(${value}))
|
|
37
|
-
ELSE CEIL(ABS(${value}) * POWER(10, ${digits})) / POWER(10, ${digits})
|
|
42
|
+
ELSE CEIL(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
38
43
|
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
39
44
|
}
|
|
40
45
|
function snowflake(value, digits) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundup.js","sourceRoot":"","sources":["../../../src/functions/roundup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"roundup.js","sourceRoot":"","sources":["../../../src/functions/roundup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAuB;IACvC,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE;gBACP,aAAa;gBACb,uBAAuB,CAAC,CAAC,EAAE,EAAE,CAAC;gBAC9B,SAAS;aACZ;SACJ;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,cAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa,EAAE,MAAc;IAChD,OAAO,WAAW,KAAK,eAAe,MAAM,OAAO,CAAC;AACxD,CAAC;AAED,SAAS,GAAG,CAAC,KAAa,EAAE,MAAc;IACtC,OAAO;eACI,KAAK,eAAe,MAAM;eAC1B,MAAM,uBAAuB,KAAK;eAClC,MAAM,sBAAsB,KAAK;wBACxB,KAAK,uBAAuB,MAAM,kCAAkC,MAAM;wBAC1E,KAAK,2BAA2B,CAAC;AACzD,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,MAAc;IAC5C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,MAAc;IAC3C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -24,6 +24,6 @@ export declare const evenScript = "def EVEN(def value) {\n if (value == null) r
|
|
|
24
24
|
export declare const logScript = "def LOG(def base, def value) {\n if (base == null || value == null) return null;\n if (base <= 1 || value <= 0) return null;\n return (Math.log(value) / Math.log(base));\n}";
|
|
25
25
|
export declare const oddScript = "def ODD(def value) {\n if (value == null) return null;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n return ((long) Math.ceil((_value + 1)/ 2.0) * 2 - 1) * sign;\n}";
|
|
26
26
|
export declare const powerScript = "def POWER(def value, def numberToRaise) {\n if (value == null || numberToRaise == null) return null;\n if (value == 0 && numberToRaise < 0) return null;\n return Math.pow(value, numberToRaise);\n}";
|
|
27
|
-
export declare const roundScript = "def ROUND(def value, def places) {\n if (value == null || places == null) return null; \n if (places > 10) places = 10;\n if (places < 0) places = 0;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n def scale = Math.pow(10, places);\n return (Math.round(_value * scale) / scale) * sign;\n}";
|
|
28
27
|
export declare const roundDownScript = "def ROUNDDOWN(def value, def places) {\n if (value == null || places == null) return null; \n if (places > 10) places = 10;\n if (places < 0) places = 0;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n def scale = Math.pow(10, places);\n return (Math.floor(_value * scale) / scale) * sign;\n}";
|
|
29
|
-
export declare const
|
|
28
|
+
export declare const roundScript: string;
|
|
29
|
+
export declare const roundUpScript: string;
|
|
@@ -161,25 +161,27 @@ export const powerScript = `def POWER(def value, def numberToRaise) {
|
|
|
161
161
|
if (value == 0 && numberToRaise < 0) return null;
|
|
162
162
|
return Math.pow(value, numberToRaise);
|
|
163
163
|
}`;
|
|
164
|
-
export const
|
|
164
|
+
export const roundDownScript = `def ROUNDDOWN(def value, def places) {
|
|
165
165
|
if (value == null || places == null) return null;
|
|
166
166
|
if (places > 10) places = 10;
|
|
167
167
|
if (places < 0) places = 0;
|
|
168
168
|
def _value = Math.abs(value);
|
|
169
169
|
def sign = value < 0 ? -1 : 1;
|
|
170
170
|
def scale = Math.pow(10, places);
|
|
171
|
-
return (Math.
|
|
171
|
+
return (Math.floor(_value * scale) / scale) * sign;
|
|
172
172
|
}`;
|
|
173
|
-
export const
|
|
173
|
+
export const roundScript = `${roundDownScript}
|
|
174
|
+
def ROUND(def value, def places) {
|
|
174
175
|
if (value == null || places == null) return null;
|
|
175
176
|
if (places > 10) places = 10;
|
|
176
177
|
if (places < 0) places = 0;
|
|
177
178
|
def _value = Math.abs(value);
|
|
178
179
|
def sign = value < 0 ? -1 : 1;
|
|
179
180
|
def scale = Math.pow(10, places);
|
|
180
|
-
return (Math.
|
|
181
|
+
return (Math.round(_value * scale) / scale) * sign;
|
|
181
182
|
}`;
|
|
182
|
-
export const roundUpScript =
|
|
183
|
+
export const roundUpScript = `${roundDownScript}
|
|
184
|
+
def ROUNDUP(def value, def places) {
|
|
183
185
|
if (value == null || places == null) return null;
|
|
184
186
|
if (places > 10) places = 10;
|
|
185
187
|
if (places < 0) places = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/elasticsearch/scripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,UAAU,MAAM,CAAC,KAAa;IAChC,OAAO,wBAAwB,KAAK,IAAI,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;MACjC,YAAY,CAAC,WAAW;;;;;;;;;;;CAW7B,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;SACvB,YAAY,CAAC,UAAU;;;;;;;;CAQ/B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;SACtB,YAAY,CAAC,SAAS;;;;;;;;;;;;;;CAc9B,CAAC;AAEF,SAAS,eAAe,CAAC,KAAU,EAAE,MAAc;IAC/C,OAAO,oBAAoB,YAAY,CAAC,UAAU,IAAI,KAAK,MAAM,MAAM,KAAK,CAAC;AACjF,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEzE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEvE,MAAM,CAAC,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