@qrvey/formula-lang 2.0.1-rc.491 → 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/even.js +3 -4
- package/dist/cjs/functions/even.js.map +1 -1
- package/dist/cjs/functions/log.js +1 -2
- package/dist/cjs/functions/log.js.map +1 -1
- package/dist/cjs/functions/odd.js +3 -4
- package/dist/cjs/functions/odd.js.map +1 -1
- package/dist/cjs/functions/round.js +9 -4
- package/dist/cjs/functions/round.js.map +1 -1
- package/dist/cjs/functions/rounddown.js +12 -7
- package/dist/cjs/functions/rounddown.js.map +1 -1
- package/dist/cjs/functions/roundup.js +12 -7
- package/dist/cjs/functions/roundup.js.map +1 -1
- package/dist/cjs/utils/elasticsearch/scripts.d.ts +5 -5
- package/dist/cjs/utils/elasticsearch/scripts.js +27 -17
- package/dist/cjs/utils/elasticsearch/scripts.js.map +1 -1
- package/dist/module/functions/even.js +3 -4
- package/dist/module/functions/even.js.map +1 -1
- package/dist/module/functions/log.js +1 -2
- package/dist/module/functions/log.js.map +1 -1
- package/dist/module/functions/odd.js +3 -4
- package/dist/module/functions/odd.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 +12 -7
- package/dist/module/functions/rounddown.js.map +1 -1
- package/dist/module/functions/roundup.js +12 -7
- package/dist/module/functions/roundup.js.map +1 -1
- package/dist/module/utils/elasticsearch/scripts.d.ts +5 -5
- package/dist/module/utils/elasticsearch/scripts.js +26 -16
- package/dist/module/utils/elasticsearch/scripts.js.map +1 -1
- package/package.json +1 -1
|
@@ -28,11 +28,10 @@ function elasticsearch(value) {
|
|
|
28
28
|
}
|
|
29
29
|
function SQL(value) {
|
|
30
30
|
return `
|
|
31
|
-
((CASE
|
|
31
|
+
(((CASE
|
|
32
32
|
WHEN ${value} IS NULL THEN NULL
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
END) * 2)`.trim();
|
|
33
|
+
ELSE CEIL(ABS(${value}) / 2.0)
|
|
34
|
+
END) * 2) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`.trim();
|
|
36
35
|
}
|
|
37
36
|
function snowflake(value) {
|
|
38
37
|
return SQL(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"even.js","sourceRoot":"","sources":["../../../src/functions/even.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AAEzC;;GAEG;AACU,QAAA,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;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;IAChC,OAAO,QAAQ,KAAK,GAAG,CAAC;AAC5B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;
|
|
1
|
+
{"version":3,"file":"even.js","sourceRoot":"","sources":["../../../src/functions/even.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AAEzC;;GAEG;AACU,QAAA,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;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;IAChC,OAAO,QAAQ,KAAK,GAAG,CAAC;AAC5B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;oBACI,KAAK;yBACA,KAAK,2BAA2B,CAAC,IAAI,EAAE,CAAC;AACjE,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LOG = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const greaterThanOrEqualToReference_1 = require("../utils/greaterThanOrEqualToReference");
|
|
7
6
|
const greaterThanReference_1 = require("../utils/greaterThanReference");
|
|
8
7
|
/**
|
|
9
8
|
* `LOG` Returns a number rounded to the next greatest even integer.
|
|
@@ -14,7 +13,7 @@ exports.LOG = {
|
|
|
14
13
|
{
|
|
15
14
|
identifier: 'NUM_1',
|
|
16
15
|
optional: false,
|
|
17
|
-
validator: [utils_1.isNumberParam, (0,
|
|
16
|
+
validator: [utils_1.isNumberParam, (0, greaterThanReference_1.greaterThanReference)(0)],
|
|
18
17
|
},
|
|
19
18
|
{
|
|
20
19
|
identifier: 'BASE',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/functions/log.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/functions/log.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,wEAAqE;AAErE;;GAEG;AACU,QAAA,GAAG,GAAuB;IACnC,UA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AAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -28,11 +28,10 @@ function elasticsearch(value) {
|
|
|
28
28
|
}
|
|
29
29
|
function SQL(value) {
|
|
30
30
|
return `
|
|
31
|
-
((CASE
|
|
31
|
+
(((CASE
|
|
32
32
|
WHEN ${value} IS NULL THEN NULL
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
END) * 2 - 1)`.trim();
|
|
33
|
+
ELSE CEIL((ABS(${value}) + 1 ) / 2.0)
|
|
34
|
+
END) * 2 - 1) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`.trim();
|
|
36
35
|
}
|
|
37
36
|
function snowflake(value) {
|
|
38
37
|
return SQL(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odd.js","sourceRoot":"","sources":["../../../src/functions/odd.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AAEzC;;GAEG;AACU,QAAA,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;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;IAChC,OAAO,OAAO,KAAK,GAAG,CAAC;AAC3B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;
|
|
1
|
+
{"version":3,"file":"odd.js","sourceRoot":"","sources":["../../../src/functions/odd.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AAEzC;;GAEG;AACU,QAAA,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;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;IAChC,OAAO,OAAO,KAAK,GAAG,CAAC;AAC3B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;qBACK,KAAK;6BACG,KAAK,2BAA2B,CAAC,IAAI,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -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,15 +35,15 @@ 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
|
-
return `(CASE
|
|
41
|
+
return `((CASE
|
|
37
42
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
38
|
-
WHEN ${digits} > 10 THEN FLOOR(${value} * POWER(10, 10)) / POWER(10, 10)
|
|
39
|
-
WHEN ${digits} < 0 THEN FLOOR(${value})
|
|
40
|
-
ELSE FLOOR(${value} * POWER(10, ${digits})) / POWER(10, ${digits})
|
|
41
|
-
END)`;
|
|
43
|
+
WHEN ${digits} > 10 THEN FLOOR(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
44
|
+
WHEN ${digits} < 0 THEN FLOOR(ABS(${value}))
|
|
45
|
+
ELSE FLOOR(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
46
|
+
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
42
47
|
}
|
|
43
48
|
function snowflake(value, digits) {
|
|
44
49
|
return SQL(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,15 +35,15 @@ 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
|
-
return `(CASE
|
|
41
|
+
return `((CASE
|
|
37
42
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
38
|
-
WHEN ${digits} > 10 THEN CEIL(${value}
|
|
39
|
-
WHEN ${digits} < 0 THEN CEIL(${value}
|
|
40
|
-
ELSE CEIL(${value}
|
|
41
|
-
END)`;
|
|
43
|
+
WHEN ${digits} > 10 THEN CEIL(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
44
|
+
WHEN ${digits} < 0 THEN CEIL(ABS(${value}))
|
|
45
|
+
ELSE CEIL(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
46
|
+
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
42
47
|
}
|
|
43
48
|
function snowflake(value, digits) {
|
|
44
49
|
return SQL(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","sourceRoot":"","sources":["../../../src/functions/roundup.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,oCAAyC;AACzC,8EAA2E;AAC3E,kDAA+C;AAE/C;;GAEG;AACU,QAAA,OAAO,GAAuB;IACvC,UAAU,EAAE,SAAS;IACrB,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,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"}
|
|
@@ -20,10 +20,10 @@ export declare const sqrtScript = "def SQRT(def num){return num == null || num <
|
|
|
20
20
|
export declare const expScript = "def EXP(def num){return num != null ? Math.exp(num) : null}";
|
|
21
21
|
export declare const replaceScript = "def REPLACE(def str, def target, def replacement) {\n if (str == null || target == null || replacement == null) return null;\n if (target == '') return str;\n return str.replace(target, replacement);\n}";
|
|
22
22
|
export declare const includeScript = "def INCLUDE(def str, def targetSearch) { if (str == null || targetSearch == null) return null; return str.contains(targetSearch);}";
|
|
23
|
-
export declare const evenScript = "def EVEN(def value) {\n if (value == null) return null;\n
|
|
23
|
+
export declare const evenScript = "def EVEN(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 / 2.0) * 2) * sign;\n}";
|
|
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
|
-
export declare const oddScript = "def ODD(def value) {\n if (value == null) return null;\n
|
|
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
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const roundUpScript
|
|
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}";
|
|
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}")`;
|
|
@@ -152,8 +152,9 @@ exports.replaceScript = `def REPLACE(def str, def target, def replacement) {
|
|
|
152
152
|
exports.includeScript = `def INCLUDE(def str, def targetSearch) { if (str == null || targetSearch == null) return null; return str.contains(targetSearch);}`;
|
|
153
153
|
exports.evenScript = `def EVEN(def value) {
|
|
154
154
|
if (value == null) return null;
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
def _value = Math.abs(value);
|
|
156
|
+
def sign = value < 0 ? -1 : 1;
|
|
157
|
+
return ((long) Math.ceil(_value / 2.0) * 2) * sign;
|
|
157
158
|
}`;
|
|
158
159
|
exports.logScript = `def LOG(def base, def value) {
|
|
159
160
|
if (base == null || value == null) return null;
|
|
@@ -162,33 +163,42 @@ exports.logScript = `def LOG(def base, def value) {
|
|
|
162
163
|
}`;
|
|
163
164
|
exports.oddScript = `def ODD(def value) {
|
|
164
165
|
if (value == null) return null;
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
def _value = Math.abs(value);
|
|
167
|
+
def sign = value < 0 ? -1 : 1;
|
|
168
|
+
return ((long) Math.ceil((_value + 1)/ 2.0) * 2 - 1) * sign;
|
|
167
169
|
}`;
|
|
168
170
|
exports.powerScript = `def POWER(def value, def numberToRaise) {
|
|
169
171
|
if (value == null || numberToRaise == null) return null;
|
|
170
172
|
if (value == 0 && numberToRaise < 0) return null;
|
|
171
173
|
return Math.pow(value, numberToRaise);
|
|
172
174
|
}`;
|
|
173
|
-
exports.
|
|
174
|
-
if (value == null || places == null) return null;
|
|
175
|
+
exports.roundDownScript = `def ROUNDDOWN(def value, def places) {
|
|
176
|
+
if (value == null || places == null) return null;
|
|
175
177
|
if (places > 10) places = 10;
|
|
176
178
|
if (places < 0) places = 0;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
def _value = Math.abs(value);
|
|
180
|
+
def sign = value < 0 ? -1 : 1;
|
|
181
|
+
def scale = Math.pow(10, places);
|
|
182
|
+
return (Math.floor(_value * scale) / scale) * sign;
|
|
179
183
|
}`;
|
|
180
|
-
exports.
|
|
181
|
-
|
|
184
|
+
exports.roundScript = `${exports.roundDownScript}
|
|
185
|
+
def ROUND(def value, def places) {
|
|
186
|
+
if (value == null || places == null) return null;
|
|
182
187
|
if (places > 10) places = 10;
|
|
183
188
|
if (places < 0) places = 0;
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
def _value = Math.abs(value);
|
|
190
|
+
def sign = value < 0 ? -1 : 1;
|
|
191
|
+
def scale = Math.pow(10, places);
|
|
192
|
+
return (Math.round(_value * scale) / scale) * sign;
|
|
186
193
|
}`;
|
|
187
|
-
exports.roundUpScript =
|
|
188
|
-
|
|
194
|
+
exports.roundUpScript = `${exports.roundDownScript}
|
|
195
|
+
def ROUNDUP(def value, def places) {
|
|
196
|
+
if (value == null || places == null) return null;
|
|
189
197
|
if (places > 10) places = 10;
|
|
190
198
|
if (places < 0) places = 0;
|
|
191
|
-
|
|
192
|
-
|
|
199
|
+
def _value = Math.abs(value);
|
|
200
|
+
def sign = value < 0 ? -1 : 1;
|
|
201
|
+
def scale = Math.pow(10, places);
|
|
202
|
+
return (Math.ceil(_value * scale) / scale) * sign;
|
|
193
203
|
}`;
|
|
194
204
|
//# sourceMappingURL=scripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/elasticsearch/scripts.ts"],"names":[],"mappings":";;;AACA,+CAA6E;AAE7E,SAAgB,MAAM,CAAC,KAAa;IAChC,OAAO,wBAAwB,KAAK,IAAI,CAAC;AAC7C,CAAC;AAFD,wBAEC;AAEY,QAAA,uBAAuB,GAAG;MACjC,sCAAY,CAAC,WAAW;;;;;;;;;;;CAW7B,CAAC;AAEW,QAAA,gBAAgB,GAAG;SACvB,sCAAY,CAAC,UAAU;;;;;;;;CAQ/B,CAAC;AAEW,QAAA,eAAe,GAAG;SACtB,sCAAY,CAAC,SAAS;;;;;;;;;;;;;;CAc9B,CAAC;AAEF,SAAS,eAAe,CAAC,KAAU,EAAE,MAAc;IAC/C,OAAO,oBAAoB,sCAAY,CAAC,UAAU,IAAI,KAAK,MAAM,MAAM,KAAK,CAAC;AACjF,CAAC;AAEM,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAAzD,QAAA,SAAS,aAAgD;AAE/D,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAA3D,QAAA,WAAW,eAAgD;AAEjE,MAAM,UAAU,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAA5D,QAAA,UAAU,cAAkD;AAElE,MAAM,UAAU,GAAG,CAA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
|
WHEN ${value} IS NULL THEN NULL
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
END) * 2)`.trim();
|
|
30
|
+
ELSE CEIL(ABS(${value}) / 2.0)
|
|
31
|
+
END) * 2) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`.trim();
|
|
33
32
|
}
|
|
34
33
|
function snowflake(value) {
|
|
35
34
|
return SQL(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"even.js","sourceRoot":"","sources":["../../../src/functions/even.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;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;IAChC,OAAO,QAAQ,KAAK,GAAG,CAAC;AAC5B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;
|
|
1
|
+
{"version":3,"file":"even.js","sourceRoot":"","sources":["../../../src/functions/even.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;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;IAChC,OAAO,QAAQ,KAAK,GAAG,CAAC;AAC5B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;oBACI,KAAK;yBACA,KAAK,2BAA2B,CAAC,IAAI,EAAE,CAAC;AACjE,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AST_PRIMITIVES } from '../constants';
|
|
2
2
|
import { isNumberParam } from '../utils';
|
|
3
|
-
import { greaterThanOrEqualToReference } from '../utils/greaterThanOrEqualToReference';
|
|
4
3
|
import { greaterThanReference } from '../utils/greaterThanReference';
|
|
5
4
|
/**
|
|
6
5
|
* `LOG` Returns a number rounded to the next greatest even integer.
|
|
@@ -11,7 +10,7 @@ export const LOG = {
|
|
|
11
10
|
{
|
|
12
11
|
identifier: 'NUM_1',
|
|
13
12
|
optional: false,
|
|
14
|
-
validator: [isNumberParam,
|
|
13
|
+
validator: [isNumberParam, greaterThanReference(0)],
|
|
15
14
|
},
|
|
16
15
|
{
|
|
17
16
|
identifier: 'BASE',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/functions/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,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,SAAS,QAAQ,CAAC,KAAa,EAAE,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC;IAC3B,OAAO;;gBAEK,KAAK,eAAe,KAAK,iBAAiB,KAAK,YAAY,KAAK;mBAC7D,KAAK,UAAU,KAAK;SAC9B,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,IAAY;IAC3C,OAAO,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -25,11 +25,10 @@ function elasticsearch(value) {
|
|
|
25
25
|
}
|
|
26
26
|
function SQL(value) {
|
|
27
27
|
return `
|
|
28
|
-
((CASE
|
|
28
|
+
(((CASE
|
|
29
29
|
WHEN ${value} IS NULL THEN NULL
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
END) * 2 - 1)`.trim();
|
|
30
|
+
ELSE CEIL((ABS(${value}) + 1 ) / 2.0)
|
|
31
|
+
END) * 2 - 1) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`.trim();
|
|
33
32
|
}
|
|
34
33
|
function snowflake(value) {
|
|
35
34
|
return SQL(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odd.js","sourceRoot":"","sources":["../../../src/functions/odd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;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;IAChC,OAAO,OAAO,KAAK,GAAG,CAAC;AAC3B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;
|
|
1
|
+
{"version":3,"file":"odd.js","sourceRoot":"","sources":["../../../src/functions/odd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;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;IAChC,OAAO,OAAO,KAAK,GAAG,CAAC;AAC3B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO;;WAEA,KAAK;qBACK,KAAK;6BACG,KAAK,2BAA2B,CAAC,IAAI,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,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
|
+
{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,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,15 +32,15 @@ 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
|
-
return `(CASE
|
|
38
|
+
return `((CASE
|
|
34
39
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
35
|
-
WHEN ${digits} > 10 THEN FLOOR(${value} * POWER(10, 10)) / POWER(10, 10)
|
|
36
|
-
WHEN ${digits} < 0 THEN FLOOR(${value})
|
|
37
|
-
ELSE FLOOR(${value} * POWER(10, ${digits})) / POWER(10, ${digits})
|
|
38
|
-
END)`;
|
|
40
|
+
WHEN ${digits} > 10 THEN FLOOR(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
41
|
+
WHEN ${digits} < 0 THEN FLOOR(ABS(${value}))
|
|
42
|
+
ELSE FLOOR(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
43
|
+
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
39
44
|
}
|
|
40
45
|
function snowflake(value, digits) {
|
|
41
46
|
return SQL(value, digits);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rounddown.js","sourceRoot":"","sources":["../../../src/functions/rounddown.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":"rounddown.js","sourceRoot":"","sources":["../../../src/functions/rounddown.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,SAAS,GAAuB;IACzC,UAAU,EAAE,WAAW;IACvB,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,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"}
|
|
@@ -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,15 +32,15 @@ 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
|
-
return `(CASE
|
|
38
|
+
return `((CASE
|
|
34
39
|
WHEN ${value} IS NULL OR ${digits} IS NULL THEN NULL
|
|
35
|
-
WHEN ${digits} > 10 THEN CEIL(${value}
|
|
36
|
-
WHEN ${digits} < 0 THEN CEIL(${value}
|
|
37
|
-
ELSE CEIL(${value}
|
|
38
|
-
END)`;
|
|
40
|
+
WHEN ${digits} > 10 THEN CEIL(ABS(${value}) * POWER(10, 10)) / POWER(10, 10)
|
|
41
|
+
WHEN ${digits} < 0 THEN CEIL(ABS(${value}))
|
|
42
|
+
ELSE CEIL(ABS(${value}) * POWER(10, TRUNC(${digits})::INTEGER)) / POWER(10, TRUNC(${digits})::INTEGER)
|
|
43
|
+
END) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
39
44
|
}
|
|
40
45
|
function snowflake(value, digits) {
|
|
41
46
|
return SQL(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,C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+20,10 @@ export declare const sqrtScript = "def SQRT(def num){return num == null || num <
|
|
|
20
20
|
export declare const expScript = "def EXP(def num){return num != null ? Math.exp(num) : null}";
|
|
21
21
|
export declare const replaceScript = "def REPLACE(def str, def target, def replacement) {\n if (str == null || target == null || replacement == null) return null;\n if (target == '') return str;\n return str.replace(target, replacement);\n}";
|
|
22
22
|
export declare const includeScript = "def INCLUDE(def str, def targetSearch) { if (str == null || targetSearch == null) return null; return str.contains(targetSearch);}";
|
|
23
|
-
export declare const evenScript = "def EVEN(def value) {\n if (value == null) return null;\n
|
|
23
|
+
export declare const evenScript = "def EVEN(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 / 2.0) * 2) * sign;\n}";
|
|
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
|
-
export declare const oddScript = "def ODD(def value) {\n if (value == null) return null;\n
|
|
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
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const roundUpScript
|
|
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}";
|
|
28
|
+
export declare const roundScript: string;
|
|
29
|
+
export declare const roundUpScript: string;
|
|
@@ -141,8 +141,9 @@ export const replaceScript = `def REPLACE(def str, def target, def replacement)
|
|
|
141
141
|
export const includeScript = `def INCLUDE(def str, def targetSearch) { if (str == null || targetSearch == null) return null; return str.contains(targetSearch);}`;
|
|
142
142
|
export const evenScript = `def EVEN(def value) {
|
|
143
143
|
if (value == null) return null;
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
def _value = Math.abs(value);
|
|
145
|
+
def sign = value < 0 ? -1 : 1;
|
|
146
|
+
return ((long) Math.ceil(_value / 2.0) * 2) * sign;
|
|
146
147
|
}`;
|
|
147
148
|
export const logScript = `def LOG(def base, def value) {
|
|
148
149
|
if (base == null || value == null) return null;
|
|
@@ -151,33 +152,42 @@ export const logScript = `def LOG(def base, def value) {
|
|
|
151
152
|
}`;
|
|
152
153
|
export const oddScript = `def ODD(def value) {
|
|
153
154
|
if (value == null) return null;
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
def _value = Math.abs(value);
|
|
156
|
+
def sign = value < 0 ? -1 : 1;
|
|
157
|
+
return ((long) Math.ceil((_value + 1)/ 2.0) * 2 - 1) * sign;
|
|
156
158
|
}`;
|
|
157
159
|
export const powerScript = `def POWER(def value, def numberToRaise) {
|
|
158
160
|
if (value == null || numberToRaise == null) return null;
|
|
159
161
|
if (value == 0 && numberToRaise < 0) return null;
|
|
160
162
|
return Math.pow(value, numberToRaise);
|
|
161
163
|
}`;
|
|
162
|
-
export const
|
|
163
|
-
if (value == null || places == null) return null;
|
|
164
|
+
export const roundDownScript = `def ROUNDDOWN(def value, def places) {
|
|
165
|
+
if (value == null || places == null) return null;
|
|
164
166
|
if (places > 10) places = 10;
|
|
165
167
|
if (places < 0) places = 0;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
def _value = Math.abs(value);
|
|
169
|
+
def sign = value < 0 ? -1 : 1;
|
|
170
|
+
def scale = Math.pow(10, places);
|
|
171
|
+
return (Math.floor(_value * scale) / scale) * sign;
|
|
168
172
|
}`;
|
|
169
|
-
export const
|
|
170
|
-
|
|
173
|
+
export const roundScript = `${roundDownScript}
|
|
174
|
+
def ROUND(def value, def places) {
|
|
175
|
+
if (value == null || places == null) return null;
|
|
171
176
|
if (places > 10) places = 10;
|
|
172
177
|
if (places < 0) places = 0;
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
def _value = Math.abs(value);
|
|
179
|
+
def sign = value < 0 ? -1 : 1;
|
|
180
|
+
def scale = Math.pow(10, places);
|
|
181
|
+
return (Math.round(_value * scale) / scale) * sign;
|
|
175
182
|
}`;
|
|
176
|
-
export const roundUpScript =
|
|
177
|
-
|
|
183
|
+
export const roundUpScript = `${roundDownScript}
|
|
184
|
+
def ROUNDUP(def value, def places) {
|
|
185
|
+
if (value == null || places == null) return null;
|
|
178
186
|
if (places > 10) places = 10;
|
|
179
187
|
if (places < 0) places = 0;
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
def _value = Math.abs(value);
|
|
189
|
+
def sign = value < 0 ? -1 : 1;
|
|
190
|
+
def scale = Math.pow(10, places);
|
|
191
|
+
return (Math.ceil(_value * scale) / scale) * sign;
|
|
182
192
|
}`;
|
|
183
193
|
//# sourceMappingURL=scripts.js.map
|
|
@@ -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;;;;;;;;;;;;;;CA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